
# Cursor MCP: How to Add an MCP Server with mcp.json

**Cursor MCP servers are configured in a JSON file: `.cursor/mcp.json` inside a project, or `~/.cursor/mcp.json` for every project.** A remote server needs a `url` and, if required, `headers` with your key; a local server needs a `command` and `args`. Save the file and the server shows up in Cursor's settings, ready for the agent to use.

Below: the formats from the [Cursor docs](https://cursor.com/docs/mcp), how to keep keys out of the file, common errors, and a working example with the 0x.cloud MCP server, which lets the Cursor agent create a VPS and deploy your project to it.


## Where mcp.json lives: project vs global

| File | Scope | Use it when |
|---|---|---|
| `.cursor/mcp.json` in the project root | this project only | the tools belong to one project; commit the file, without keys |
| `~/.cursor/mcp.json` in your home folder | all projects | you want the service everywhere: GitHub, your cloud, docs |

On Windows the global file is `C:\Users\you\.cursor\mcp.json`. If it doesn't exist, create it by hand or use the add-server button in Cursor's MCP settings, which opens the right file.

## Add a remote MCP server by URL

A remote server speaks HTTP and needs nothing installed locally:

```json
{
  "mcpServers": {
    "my-service": {
      "url": "https://api.example.com/mcp",
      "headers": {
        "Authorization": "Bearer ${env:MY_SERVICE_TOKEN}"
      }
    }
  }
}
```

- `my-service` is the name you'll see in the UI.
- `url` is the MCP server address.
- `headers` are request headers; here the key comes from the `MY_SERVICE_TOKEN` environment variable.

If the service supports OAuth, leave the headers out. Cursor opens the sign-in page itself (authorization code flow with PKCE).

## Add a local MCP server (npx, Python)

Cursor launches a local server as a process on your machine:

```json
{
  "mcpServers": {
    "local-tool": {
      "command": "npx",
      "args": ["-y", "some-mcp-package"],
      "env": {
        "API_KEY": "${env:LOCAL_TOOL_KEY}"
      }
    }
  }
}
```

Python servers usually use `uvx` or `python` as the `command`, with the package name or script path in `args`. Local servers also accept `envFile`, a path to a `.env` file.

## Config variables: keep keys out of mcp.json

Cursor resolves these in `command`, `args`, `env`, `url`, and `headers`:

| Syntax | Resolves to |
|---|---|
| `${env:NAME}` | the `NAME` environment variable |
| `${userHome}` | your home folder |
| `${workspaceFolder}` | the open project's root |
| `${workspaceFolderBasename}` | the project folder's name |
| `${pathSeparator}` or `${/}` | your OS path separator |

Cursor itself has to see the variable. On macOS and Linux, export it in your shell profile (`~/.zshrc`, `~/.bashrc`) and launch Cursor from the terminal with `cursor .`, or restart the app. On Windows, add it to your user environment variables.

## Cursor MCP settings: enable, check, approve

1. Open **Customize** in Cursor's sidebar (in older versions, **Cursor Settings > MCP**). You can also install official servers from the Cursor Marketplace there in one click.
2. Find your server. A green dot and a tool list mean it works.
3. Use the toggle to turn a server off. Disabled servers don't load or appear in chat.

The agent calls tools from the available list when they fit the task, including in Plan Mode. You can also ask for a tool by name. By default, Cursor asks for approval before running an MCP tool. Click the arrow next to a tool name to see its arguments. Auto-run follows the same Run Modes as terminal commands; keep it off for tools that spend money or delete data.

When something breaks, open the Output panel (`Cmd+Shift+U` on macOS, `Ctrl+Shift+U` on Windows and Linux) and pick **MCP Logs** from the dropdown. It shows connection errors, auth failures, and server crashes.

## Example: the 0x.cloud MCP server in Cursor

The 0x.cloud MCP server covers the whole loop: an exact price with `dry_run`, creating a server, listing servers and balance, running commands inside a server without SSH, snapshots, and deleting servers. The agent only sees tools the connection has permission for. Details on the [0x.cloud MCP server](https://0x.cloud/mcp) page.

**Option 1: sign in, no key (OAuth).** The 0x.cloud server supports OAuth 2.1 with dynamic client registration, so the URL alone is enough in `~/.cursor/mcp.json`:

```json
{
  "mcpServers": {
    "0x-cloud": {
      "url": "https://0x.cloud/v1/mcp"
    }
  }
}
```

Cursor opens the 0x.cloud sign-in page, where you choose the permissions, monthly spend cap, expiry, and "own servers only" restriction yourself. The connection then shows up in your dashboard as a regular API key you can edit or revoke.

**Option 2: API key in a header.**

1. Create a dedicated key for Cursor with `servers.read` and `servers.create`, without `servers.delete`, plus a monthly spend cap such as $20. Create is also what `dry_run` needs, and keys get `servers.*` (delete included) by default, so remove delete explicitly. See [API key permissions](https://0x.cloud/kb/api-mcp/api-keys).
2. Save the key in an `OX_API_KEY` environment variable.
3. Add the server to `~/.cursor/mcp.json`:

```json
{
  "mcpServers": {
    "0x-cloud": {
      "url": "https://0x.cloud/v1/mcp",
      "headers": {
        "Authorization": "Bearer ${env:OX_API_KEY}"
      }
    }
  }
}
```

4. Restart Cursor and check that `0x-cloud` has a green dot.
5. Give the agent a task:


```text
Using the 0x.cloud MCP server, create an s1-2 server with Ubuntu 24.04 and hourly billing for this project. Show me the dry_run price first and wait for my approval. Then walk me through deploying this project to it.
```


The agent gets the exact price, asks you, and creates the server only after you confirm. For a small web app or bot, s1-2 (1 vCPU, 2 GB RAM, 30 GB NVMe) at $7.99 a month is enough; on hourly billing a test costs about $0.054725 per hour, and deleting the server returns the unused remainder to your balance. This flow fits vibe coding well: see VPS for vibe coding.

## Troubleshooting MCP in Cursor

| Problem | Fix |
|---|---|
| Server doesn't appear | validate the JSON (trailing commas, quotes), check the file path, restart Cursor |
| Red dot on a remote server | check the `url` and MCP Logs; on a 401, check the key (not revoked or expired) and the `Bearer key` format, or sign in again with OAuth |
| `envFile` ignored for a remote server | `envFile` only works for local (stdio) servers; use `${env:NAME}` for URL servers |
| `${env:...}` isn't resolved | Cursor can't see the variable: set it in your profile and relaunch Cursor from the terminal |
| Windows: `Client closed` on an `npx` server | use `"command": "cmd"` with `"args": ["/c", "npx", "-y", "package"]` |
| Agent ignores the tools | enable the server, check its tool list, ask the agent to use the tool explicitly |

The same server works in other clients too: [Claude and Claude Desktop](https://0x.cloud/kb/api-mcp/mcp-claude) and [Claude Code](https://0x.cloud/kb/api-mcp/mcp-claude-code).


[Create server: s1-2, $7.99/mo](https://0x.cloud/cabinet/create?plan=s1-2)


## FAQ

**Where is the mcp.json file in Cursor?**
Per project: .cursor/mcp.json in the project root. Global: ~/.cursor/mcp.json in your home folder (C:\Users\you\.cursor\mcp.json on Windows).

**How do I pass an API key to an MCP server in Cursor without hardcoding it?**
Use environment variable interpolation: "Authorization": "Bearer ${env:OX_API_KEY}". Cursor fills in the value when it starts the server.

**Does Cursor ask before running MCP tools?**
Yes. By default Cursor asks for approval before using MCP tools. Auto-run follows the same run modes as terminal commands.

**Why isn't Cursor using my MCP tools?**
Make sure the server is enabled and shows a tool list in settings. Then ask the agent directly: name the tool or describe the task it's for.
