MCP Server Generator
Guide · Claude Desktop & Cursor

Connect an MCP Server to Claude Desktop and Cursor

把 MCP Server 接入 Claude Desktop 和 Cursor

Both hosts launch a local MCP server from an mcpServers entry: a command plus args, spoken to over stdio. Claude Desktop reads claude_desktop_config.json; Cursor reads ~/.cursor/mcp.json or a project's .cursor/mcp.json. Use absolute paths to the interpreter and entry file, restart the host, and your tools appear.

两个主机都通过 mcpServers 配置(command + args,stdio 通信)启动本地 MCP server。Claude Desktop 读 claude_desktop_config.json,Cursor 读 ~/.cursor/mcp.json 或项目内 .cursor/mcp.json。使用绝对路径并重启主机即可。

Steps

步骤

  1. Install the server's dependencies

    In the unzipped folder run npm install (TypeScript) or create a venv and pip install -r requirements.txt (Python).

  2. Test it outside the host

    Run npx @modelcontextprotocol/inspector npm start (or python server.py) and call a tool once.

  3. Write the mcpServers entry with absolute paths

    Point command at the project's tsx binary or venv Python and pass the absolute path to src/index.ts or server.py.

  4. Add it to the host config

    Claude Desktop: Settings, Developer, Edit Config (claude_desktop_config.json). Cursor: ~/.cursor/mcp.json or .cursor/mcp.json in a project.

  5. Restart the host and call a tool

    Fully quit and reopen Claude Desktop, or reload in Cursor, then ask for something that needs your tool.

Don't have a server yet? Generate one with MCP Server Generator in TypeScript or Python; the examples below use its default weather-helper project.

Config that works in both hosts

两个主机通用的配置

Replace /Users/you/mcp/weather-helper with your folder. Get it with pwd (macOS/Linux) or cd (Windows) inside the project.

TypeScript project (after npm install)

{
  "mcpServers": {
    "weather-helper": {
      "command": "/Users/you/mcp/weather-helper/node_modules/.bin/tsx",
      "args": ["/Users/you/mcp/weather-helper/src/index.ts"]
    }
  }
}

Python project (after creating .venv and pip install)

{
  "mcpServers": {
    "weather-helper": {
      "command": "/Users/you/mcp/weather-helper/.venv/bin/python",
      "args": ["/Users/you/mcp/weather-helper/server.py"]
    }
  }
}

On Windows use node_modules\.bin\tsx.cmd and .venv\Scripts\python.exe, and write each \ as \\ inside JSON strings. Pointing at the venv's Python matters: a bare "python" may resolve to a system interpreter that does not have mcp installed.

Alternatives in the generated README

README 里的其他写法

The README in every generated ZIP uses the absolute-path configs above (no cwd, which some Claude Desktop builds ignore) and adds one alternative per language:

TypeScript, compiled (after npm run build)

{
  "mcpServers": {
    "weather-helper": {
      "command": "node",
      "args": ["/Users/you/mcp/weather-helper/dist/index.js"]
    }
  }
}

Python with uv (no manual venv; uv installs mcp from pyproject.toml on first run)

{
  "mcpServers": {
    "weather-helper": {
      "command": "uv",
      "args": ["run", "--directory", "/Users/you/mcp/weather-helper", "server.py"]
    }
  }
}

If the host can't find node or uv, replace them with absolute paths from which node / which uv.

Claude Desktop specifics

Claude Desktop 要点

  • File: macOS ~/Library/Application Support/Claude/claude_desktop_config.json, Windows %APPDATA%\Claude\claude_desktop_config.json. Settings → Developer → Edit Config opens it.
  • Restart: quit the app completely (not just the window) so it re-reads the file.
  • Logs: macOS ~/Library/Logs/Claude/mcp*.log, Windows %APPDATA%\Claude\logs. A server's stderr ends up here, including the generator's “running on stdio” line.

Cursor specifics

Cursor 要点

  • Global: ~/.cursor/mcp.json makes the server available in every project.
  • Per project: .cursor/mcp.json in the repo root; commit it only if the paths make sense for teammates.
  • Status: the MCP section of Cursor Settings lists each server, whether it started, and its tools. Toggle it off and on after editing the file.

Troubleshooting

常见问题排查

SymptomLikely cause and fix
No servers load at allInvalid JSON. One trailing comma disables the whole file; run it through a JSON validator.
spawn npx ENOENT / command not foundThe app does not see your shell PATH. Use the absolute path to tsx, node or the venv Python (which node).
Server starts, then disconnectsSomething printed to stdout. Log with console.error or print(..., file=sys.stderr).
ModuleNotFoundError: mcpcommand points at a Python without the package. Use .venv/bin/python.
Tools listed but never usedVague descriptions. Say what the tool does and when to use it; mention it by name in your prompt to test.

Need a server to connect?

还没有 server?先生成一个

Generate a TypeScript or Python MCP server from a form; the README includes the mcpServers entry.

FAQ

常见问题

Where is claude_desktop_config.json?

On macOS it is ~/Library/Application Support/Claude/claude_desktop_config.json and on Windows %APPDATA%\Claude\claude_desktop_config.json. In Claude Desktop, Settings > Developer > Edit Config opens it.

中文: macOS:~/Library/Application Support/Claude/claude_desktop_config.json;Windows:%APPDATA%\Claude\claude_desktop_config.json。可在 Settings > Developer > Edit Config 打开。

Where does Cursor read MCP servers from?

From ~/.cursor/mcp.json for servers available in every project, or .cursor/mcp.json inside a project for that project only. Both use the same mcpServers format as Claude Desktop.

中文: 全局:~/.cursor/mcp.json;单项目:项目内 .cursor/mcp.json。格式与 Claude Desktop 相同。

Why use absolute paths instead of cwd?

Desktop apps start servers from their own working directory and do not load your shell PATH, and some Claude Desktop builds ignore the cwd field. Absolute paths to the interpreter and the entry file work either way.

中文: 桌面应用从自己的工作目录启动,不加载 shell 的 PATH,部分 Claude Desktop 版本会忽略 cwd;用解释器和入口文件的绝对路径最稳妥。

My server does not appear. What should I check first?

Validate the JSON (a trailing comma breaks the whole file), confirm the command path exists, fully restart the host, then read the host's MCP log. On macOS Claude Desktop writes ~/Library/Logs/Claude/mcp*.log.

中文: 先检查 JSON(多余逗号会让整个文件失效)、命令路径是否存在、是否完全重启主机,再看 MCP 日志(macOS:~/Library/Logs/Claude/mcp*.log)。

Can I use the same server in both Claude Desktop and Cursor?

Yes. Paste the same mcpServers entry into both config files; each host launches its own copy of the process over stdio.

中文: 可以。把同一段 mcpServers 配置粘到两个配置文件里,各自通过 stdio 启动一个进程。