MCP: Connect Any AI to Your Tools

How to add a server in Cursor or VS Code

By mcp-guide · 0 stars

The config key differs: Cursor uses `mcpServers`, VS Code's `.vscode/mcp.json` uses `servers`.

### Cursor

1. Create `.cursor/mcp.json` in the project, or `~/.cursor/mcp.json` for all projects.
2. Add the server:

~~~json
{
  "mcpServers": {
    "local-db": {
      "command": "npx",
      "args": ["-y", "some-db-mcp"],
      "env": { "DB_URL": "${env:DB_URL}" }
    },
    "linear": { "url": "https://mcp.linear.app/mcp" }
  }
}
~~~

3. Open Cursor's MCP settings. You should see the server and its tools.
4. Sign in if a remote server asks for OAuth.

- Cursor treats an entry with `url` as remote. Transports: stdio, SSE, Streamable HTTP.
- For providers without dynamic registration, add an `auth` block with `CLIENT_ID`, `CLIENT_SECRET` and `scopes`.
- Variables: `${env:NAME}`, `${userHome}`, `${workspaceFolder}`, `${workspaceFolderBasename}`, `${pathSeparator}`.
- One-click installs: Cursor Marketplace and "Add to Cursor" links.
- Tools ask for approval by default; auto-run follows run mode and the allowlist.

### VS Code (Copilot agent mode)

1. Create `.vscode/mcp.json` in the workspace. For your user profile instead, run "MCP: Open User Configuration".
2. Add the server under `servers`:

~~~json
{
  "inputs": [
    { "type": "promptString", "id": "token", "description": "API token", "password": true }
  ],
  "servers": {
    "memory": {
      "type": "stdio",
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-memory"]
    },
    "remote": {
      "type": "http",
      "url": "https://api.example.com/mcp",
      "headers": { "Authorization": "Bearer ${input:token}" }
    }
  }
}
~~~

3. Start the server and accept the trust prompt.
4. Run "MCP: List Servers". You should see the server running.

- `inputs` asks for the secret once and stores it outside the file.
- Other routes: "MCP: Add Server", or `code --add-mcp '{"name":"fetch","command":"uvx","args":["mcp-server-fetch"]}'`.
- A root `.mcp.json` with `mcpServers` also works, for configs shared with other tools.
- VS Code discovers Claude Desktop servers; Settings Sync carries MCP config across machines.
- Local servers can run sandboxed on macOS and Linux (filesystem and network limits).

### Sources

- https://cursor.com/docs/context/mcp
- https://code.visualstudio.com/docs/copilot/customization/mcp-servers
- https://code.visualstudio.com/docs/copilot/reference/mcp-configuration