TellWorldAI World Archive
Ask中文

Home›Practice›Practice

Practice

Configuring MCP servers in Claude Desktop, VS Code and Cursor

Configure MCP servers in Claude Desktop, VS Code and Cursor: find each client's config file, add a server entry, restart, confirm the connection and fix common failures.

Who this is for and what you will be able to do

If you already have a working MCP server and want Claude Desktop, VS Code or Cursor to call it, this guide is for you. By the end you will know where each client keeps its configuration, how to write a server entry, how to confirm the server is connected after a restart, and where to look first when something fails.[1]

What an MCP host is

An MCP host is an AI application that can connect to MCP servers to extend its capabilities. The user works with the host, while the servers behind it provide the tools and data. Claude Desktop, VS Code and Cursor can all act as hosts.[1]

You need three things: a working MCP server, the host application installed, and comfort with JSON configuration files. Most configuration errors are JSON syntax errors, so validate the file with a JSON validator before you blame anything else.[1]

Claude Desktop

Claude Desktop is Anthropic's official desktop application, and it supports MCP natively. It defines servers in a JSON configuration file, located at:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

[1]

The example below defines three servers:[1]

{
  "mcpServers": {
    "calculator": {
      "command": "python",
      "args": ["-m", "mcp_calculator_server"],
      "env": {
        "PYTHONPATH": "/path/to/your/server"
      }
    },
    "weather": {
      "command": "node",
      "args": ["/path/to/weather-server/build/index.js"]
    },
    "database": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-postgres"],
      "env": {
        "DATABASE_URL": "postgresql://user:pass@localhost/mydb"
      }
    }
  }
}

In the mcpServers object, each key names one server. Each entry takes command (the program to run), args (command-line arguments) and, optionally, env (environment variables). The calculator entry runs python -m mcp_calculator_server and sets PYTHONPATH to the server's directory. The weather entry runs a compiled Node.js entry file with node. The database entry starts @modelcontextprotocol/server-postgres with npx -y and passes its connection string in DATABASE_URL.[1]

The connection string and paths in the example are placeholders; replace them with your own. Do not write real passwords into the configuration file. Put sensitive values in environment variables or a secrets manager.[1]

After you finish the configuration, test in this order:

  1. Save the configuration file.
  2. Quit Claude Desktop completely and reopen it.
  3. Start a new conversation.
  4. Look for the 🔌 icon, which indicates connected servers.
  5. Ask Claude to use one of your tools and check that it returns a result.[1]

If a server does not appear, validate the configuration file's syntax, confirm that the command path is correct, and open the Claude Desktop logs from the Help menu (Help → Show Logs). If a server crashes on startup, run it manually in a terminal first, confirm that its environment variables are set and its dependencies are installed, and then test it in the client again.[1]

VS Code

VS Code supports MCP through GitHub Copilot Chat extensions. You need VS Code 1.99 or later, the GitHub Copilot extension and the GitHub Copilot Chat extension.[1]

Workspace configuration lives in .vscode/mcp.json. It uses a servers object, and each entry has a type field:[1]

{
  "servers": {
    "my-calculator": {
      "type": "stdio",
      "command": "python",
      "args": ["-m", "mcp_calculator_server"]
    },
    "my-database": {
      "type": "sse",
      "url": "http://localhost:8080/sse"
    }
  }
}

In this example, my-calculator starts a Python module over stdio, while my-database uses the sse type and points to http://localhost:8080/sse. The /sse form is the legacy HTTP+SSE approach for MCP 2025-11-25. For MCP 2026-07-28, select Streamable HTTP in hosts that support it, and use the endpoint the server configures.[1]

To use the server, open the Copilot Chat panel with Ctrl+Shift+I (Cmd+Shift+I on Mac), type @ to see the available MCP tools, and call them in natural language, for example "Calculate 25 * 48 using the calculator."[1]

If something goes wrong, check the MCP channel in the Output panel for errors, then run Developer: Reload Window. If that does not help, confirm that the server runs on its own outside VS Code.[1]

Cursor

Cursor is an AI-first code editor with built-in MCP support. Its configuration file is ~/.cursor/mcp.json on macOS and Linux, and %USERPROFILE%\.cursor\mcp.json on Windows. The format is similar to Claude Desktop's and also uses an mcpServers object:[1]

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/allowed/directory"]
    },
    "github": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-github"],
      "env": {
        "GITHUB_TOKEN": "ghp_your_token_here"
      }
    }
  }
}

This example configures two servers. The filesystem server starts with npx -y @modelcontextprotocol/server-filesystem, and its last argument is the directory it may access, so keep that directory as narrow as possible. The GitHub server receives its token through GITHUB_TOKEN in the env field. The token shown is a placeholder, and in real use it should come from environment variables or a secrets manager.[1]

Open the AI chat with Ctrl+L (Cmd+L on Mac). MCP tools appear automatically in suggestions, and you can ask the AI to complete tasks with the connected servers.[1]

Common problems

The server will not start

Run the server by hand in a terminal first. A Python server runs with python -m your_server_module, and a Node.js server with node /path/to/server/index.js:[1]

# For Python
python -m your_server_module

# For Node.js
node /path/to/server/index.js

Next, check the command path. Use absolute paths when you can, and make sure the executable is on your PATH. Then verify the dependencies: for Python, pip list | grep mcp, and for Node.js, npm list @modelcontextprotocol/sdk:[1]

# Python
pip list | grep mcp

# Node.js
npm list @modelcontextprotocol/sdk

The server connects but its tools do not work

Check the server logs first; most hosts offer a logging option. Then use MCP Inspector to confirm that the tools are registered, and check that they have the file or network permissions they need.[1]

Environment variables do not reach the server

Some hosts sanitize environment variables. Pass them explicitly with the env field, and keep sensitive data out of configuration files.[1]

Security basics

These rules apply to every host:[1]

  • Never commit API keys to configuration files.
  • Use environment variables for sensitive data.
  • Limit each server to the permissions it needs.
  • Review server code before you grant it access to your system.
  • Use allowlists to limit file system and network access.

Transports and next steps

Hosts differ in which transports they support. The newer specification recommends selecting Streamable HTTP in hosts that support it. The transports section of the specification is published at modelcontextprotocol.io.[2]

When a configuration fails, test the server's tools with MCP Inspector first. Once you know the server works, go back and check the host side.[1]

Adapted from lesson 3 of Microsoft's open-source course *MCP for Beginners*[1], released under the MIT License.

Sources

  1. 1
    Setting Up Popular MCP Host ClientsMicrosoft mcp-for-beginners (MIT)
  2. 2
    MCP Specification - TransportsModel Context Protocol

Cite this page: Configuring MCP servers in Claude Desktop, VS Code and Cursor. TellWorld, https://www.tellworld.net/practice/practice-mcp-hosts. Updated 2026-11-14

Related news

View all