Cursor CLI: Install, Commands, Headless Mode and MCP

Raghav Chamadiya8 min read
On this page

Cursor CLI is Cursor's coding agent in your terminal: you install it with one command, run agent in a repository, and it reads, writes and runs code the way the editor's agent does. It also has a print mode (agent -p "...") for scripts and CI, and it picks up the same rules and MCP servers your Cursor project already uses.

bash
curl https://cursor.com/install -fsS | bash
agent

Setting up MCP in the editor first? See Cursor MCP: give Cursor real codebase context.

Cursor CLI quick reference

These are the commands and flags you will use in the first week, all from Cursor's CLI docs as of November 2026.

TaskCommand
Start an interactive sessionagent or agent "fix the flaky login test"
Run headless and print the resultagent -p "find and fix performance issues"
Let a headless run apply every actionagent -p --force "..."
Machine-readable outputagent -p --output-format json (or stream-json)
Plan or ask without editingagent --mode=plan, agent --mode=ask
Pick a modelagent --model "<name>", agent --list-models
List and resume sessionsagent ls, agent resume, agent --continue
Manage MCP serversagent mcp list, agent mcp list-tools <id>
Log in, check, updateagent login, agent status, agent update

Scroll the table sideways to see every column.

How to install Cursor CLI

On macOS, Linux and WSL, one curl command installs the agent binary; native Windows uses a PowerShell one-liner. Both come from the installation page.

bash
# macOS, Linux, WSL
curl https://cursor.com/install -fsS | bash
powershell
# Windows, native PowerShell
irm 'https://cursor.com/install?win32=true' | iex

Check it with agent --version. If your shell cannot find agent, add ~/.local/bin to your PATH:

bash
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc   # ~/.zshrc on zsh

Then run agent login to authenticate with your Cursor account. agent status shows who you are logged in as. The CLI updates itself by default; agent update forces it.

The CLI binary is agent, and it is installed separately from the Cursor editor. From inside a CLI session, /open (alias /cursor) opens the repository's git root in the editor.

Interactive mode: how to use Cursor CLI day to day

Run agent in a repository and you get a chat in the terminal that can read files, edit them and run shell commands, asking before anything that needs approval. Three modes cover most work: Agent (the default), Plan (/plan or Shift+Tab) and Ask (/ask), which answers without editing.

The slash commands worth learning early:

  • /model switches models mid-session.
  • /shell runs a command in your $SHELL. Shell mode has a 30-second timeout, does not keep cd between commands and is checked against your permissions.
  • /resume picks up an earlier session.
  • /mcp shows the MCP servers the session can use.

My advice: start every non-trivial task in Plan mode. The agent reads before it writes, and you see its approach before it touches a file.

Headless mode: Cursor CLI in scripts and CI

agent -p runs one prompt with no interactive UI and prints the result, which is what you want in a script, a git hook or a CI job. Without --force, print mode runs only the actions that need no approval and rejects the rest, though it can still write files in the workspace. With --force (alias --yolo) it runs every action except those your permissions.deny list or team policy blocks. The headless docs cover the details.

bash
agent -p --force "Refactor src/utils to modern ES syntax and run the tests"
agent -p --force --output-format stream-json --stream-partial-output "..."

For CI, authenticate with an API key instead of agent login: set CURSOR_API_KEY in the environment, or pass --api-key. Cursor's GitHub Actions page documents this job shape:

yaml
- name: Install Cursor CLI
  run: |
    curl https://cursor.com/install -fsS | bash
    echo "$HOME/.cursor/bin" >> $GITHUB_PATH
- name: Run Cursor Agent
  env:
    CURSOR_API_KEY: ${{ secrets.CURSOR_API_KEY }}
  run: |
    agent -p "Your prompt here" --model gpt-5

Store the key with gh secret set CURSOR_API_KEY --repo OWNER/REPO. A headless agent in CI is one control inside a larger system; harness engineering covers how to design the checks around it.

Rules and permissions the CLI reads

The CLI reads .cursor/rules, plus AGENTS.md and CLAUDE.md at the project root, so instructions you wrote for the editor or for another agent apply in the terminal too. That is the using the CLI page's wording, and it means one instruction file can serve Cursor and Claude Code together.

Permissions live in ~/.cursor/cli-config.json globally and .cursor/cli.json per project. Each rule is a token such as Shell(git), Read(src/**/*.ts), Write(package.json) or Mcp(server:tool), and deny beats allow (permissions reference):

json
{
  "permissions": {
    "allow": ["Shell(git)", "Read(src/**)", "Mcp(repowise:*)"],
    "deny": ["Shell(rm)", "Read(.env*)", "Write(**/*.key)"]
  }
}

Set the deny list before you use --force anywhere. Along with team policy, it is all a forced run still respects.

MCP in Cursor CLI

The CLI detects your mcp.json automatically and uses the same precedence as the editor: project, then global, then nested. A server you added for the editor is already available in the terminal (CLI MCP docs).

bash
agent mcp list                 # servers the CLI sees
agent mcp list-tools <id>      # tools one server exposes
agent mcp disable <id>         # stop loading a server

The first time a session uses a server, the CLI asks you to approve it. agent mcp enable <id> adds it to your approved list, and --approve-mcps skips the prompt, which a headless run needs.

Give Cursor CLI codebase context with repowise

A terminal agent starts every session knowing nothing about your repository, so it greps and reads whole files to find out; an MCP server that answers from an index skips that step. repowise indexes the repository once (dependency graph, git history, ownership, code health, recorded decisions) and serves it to the agent as MCP tools.

Setup is two commands after installing repowise:

bash
repowise init                              # builds the index
repowise agents add --target=cursor --yes  # writes .cursor/mcp.json and a rule

The second command merges a repowise server into the project's .cursor/mcp.json, keeping your other entries, and writes a rule at .cursor/rules/repowise.mdc that tells the agent when to call the tools. The CLI reads both files, so there is no extra step for the terminal. Run agent mcp list and you will see repowise.

What the agent can then ask:

  • get_answer takes a how, where or why question and returns a cited answer with a confidence level.
  • get_context returns a card for a file or symbol: summary, signatures, callers, owners and the decisions that govern it. include=["skeleton"] gives the structure without reading the whole file.
  • get_why returns the decision records and git history behind how the code is shaped.
  • search_codebase and get_symbol find a symbol and return its body.

Cursor sends every tool schema with every request, so repowise gives it a compact core profile by default and keeps that per-request cost low. For change checks in the terminal, switch to the standard set:

bash
repowise config set mcp.tools standard

Restart the agent after changing it. The standard set includes get_risk, which says what history records about touching a file (hotspot, bug-fix record, owners, co-change partners, dependents), and get_change_risk, which reviews uncommitted work or a range such as main..HEAD: what the change made worse and which tests cover the changed lines. Then a headless run can check its own diff:

bash
agent -p --force --approve-mcps \
  "Fix the failing test in tests/test_billing.py. Before committing, call get_change_risk and fix anything it reports as worse."

For noisy commands inside a prompt, repowise distill <cmd> runs the command and returns a compact result, so a long test log does not fill the window. In our published benchmarks, agents on repowise opened up to 99% fewer files per question, the largest cut of the five models tested. Change risk explains how a review is scored, and repowise for agents covers setup for every host.

Pitfalls

Most Cursor CLI problems come from PATH, approvals or a forced run with no deny list.

  • agent: command not found. The install page puts the binary on ~/.local/bin; Cursor's GitHub Actions example adds ~/.cursor/bin to the path. Check which one your install used.
  • A headless run that does nothing. Without --force, print mode rejects every action that needs approval. Add --force, or allow the specific commands in cli.json.
  • MCP tools missing in CI. The approval prompt cannot be answered in a pipeline. Pass --approve-mcps, or enable the server ahead of time.
  • Shell commands that hang. Shell mode times out at 30 seconds and does not support interactive or long-running commands. Run those yourself.

FAQ

What is the Cursor CLI?
Cursor CLI is a command-line program, run as agent, that gives you Cursor's AI coding agent in the terminal. It can read and edit files and run shell commands interactively, or run a single prompt headless with agent -p for scripts and CI. It uses your Cursor account, your project rules and your MCP servers.
Can I use Cursor CLI on macOS?
Yes. Cursor's installation page lists macOS, Linux and WSL for the install script, curl https://cursor.com/install -fsS | bash. After installing, run agent --version to check it, and add ~/.local/bin to your PATH if the shell cannot find it.
How do I open Cursor from the command line?
The terminal agent and the editor are separate installs. agent starts the Cursor CLI agent in the current directory. Inside an agent session, the /open slash command (alias /cursor) opens the repository's git root in the Cursor editor.
Does Cursor CLI work on Windows?
Yes. On native Windows, install it from PowerShell with irm 'https://cursor.com/install?win32=true' | iex. You can also run the curl installer inside WSL. The global config file lives at $env:USERPROFILE\.cursor\cli-config.json.
Does Cursor CLI support MCP?
Yes. The CLI reads the same mcp.json files as the editor, in the same order: project, global, then nested. agent mcp list shows the servers it found, agent mcp list-tools <id> lists a server's tools, and --approve-mcps skips the approval prompt in headless runs.
Cursor CLI vs Claude Code: which should I use?
Both are terminal coding agents that read project instruction files, run shell commands and connect to MCP servers, and Cursor CLI reads CLAUDE.md as well as AGENTS.md. Pick Cursor CLI if your team already pays for Cursor and wants the same rules, models and MCP setup in the editor and terminal. Pick Claude Code if you work terminal-first and want Anthropic's models with no editor in the picture. Either one can use the same repowise index over MCP.