---
title: "Cursor MCP 配置：文件路径、键和示例 · DotsAgent"
description: "从 Anysphere 向 Cursor 添加 MCP 服务器：了解配置文件位置、顶层键和格式、远程 OAuth 支持，以及配置示例。"
url: https://dotsagent.io/zh/mcp/clients/cursor
---

Anysphere

# 向 Cursor 添加 MCP 服务器

Cursor 会读取项目中 .cursor/ 下的 mcp.json，也会读取 ~/.cursor/ 下供所有项目使用的配置。

- **macOS**: `~/.cursor/mcp.json`
- **Windows**: `~/.cursor/mcp.json`
- **Linux**: `~/.cursor/mcp.json`
- **项目文件**: `.cursor/mcp.json`
- **顶层键**: `mcpServers`
- **格式**: json
- **远程服务器的 OAuth**: 

## 配置示例

此示例按该客户端所需的格式，添加 GitHub 托管的服务器和作为本地服务器的 Playwright。

`.cursor/mcp.json`

```
{
  "mcpServers": {
    "github": {
      "url": "https://api.githubcopilot.com/mcp/"
    },
    "playwright": {
      "command": "npx",
      "args": [
        "@playwright/mcp@latest"
      ]
    }
  }
}
```

## 注意事项和特殊情况

- 值可以使用 ${env:NAME}、${userHome} 和 ${workspaceFolder}。
- 远程条目需要 url，可选的 headers，以及包含 CLIENT_ID、CLIENT_SECRET 和 scopes 的 auth 配置块，供预先注册的 OAuth 应用使用。
- 如果服务提供方要求固定的重定向 URL，请注册 https://www.cursor.com/agents/mcp/oauth/callback 和 http://localhost:8787/callback。
- 官方文档未说明可使用命令行添加服务器。

[生成 Cursor 配置 →](https://dotsagent.io/zh/mcp/config#client=cursor)

## 其他客户端

[Claude Desktop](https://dotsagent.io/zh/mcp/clients/claude-desktop)

[Claude Code](https://dotsagent.io/zh/mcp/clients/claude-code)

[VS Code (GitHub Copilot)](https://dotsagent.io/zh/mcp/clients/vscode-copilot)

[Windsurf / Devin Desktop](https://dotsagent.io/zh/mcp/clients/windsurf)

[Zed](https://dotsagent.io/zh/mcp/clients/zed)

[OpenAI Codex CLI](https://dotsagent.io/zh/mcp/clients/codex-cli)

[Gemini CLI](https://dotsagent.io/zh/mcp/clients/gemini-cli)

[ChatGPT](https://dotsagent.io/zh/mcp/clients/chatgpt)

[OpenClaw](https://dotsagent.io/zh/mcp/clients/openclaw)

[Cline](https://dotsagent.io/zh/mcp/clients/cline)

[Continue](https://dotsagent.io/zh/mcp/clients/continue)

[JetBrains AI Assistant](https://dotsagent.io/zh/mcp/clients/jetbrains-ai)

## 来源

1. [cursor.com](https://cursor.com/docs/context/mcp)/docs/context/mcp

为 AI agent 开发者提供的独立参考资料。与此处提及的任何厂商均无关联。

© 2026 DotsAgent · 事实核查日期：2026年10月1日
