How to connect MCP servers to your AI tools

Register local and remote MCP servers with Claude Desktop, Claude Code, Cursor, and VS Code — config shapes, authentication, and troubleshooting.

, updated

Every major AI host ships with a built-in MCP client. “Connecting a server” just means telling the host how to reach it — either a local server the host launches as a subprocess (command + args), or a remote server it reaches over Streamable HTTP (a URL). Where that entry lives differs per host:

Host Where to configure
Claude Desktop claude_desktop_config.json — macOS: ~/Library/Application Support/Claude/claude_desktop_config.json; Windows: %APPDATA%\Claude
Claude Code claude mcp add CLI, or .mcp.json in the project root (checked in, shared with your team)
Cursor ~/.cursor/mcp.json (global) or .mcp.json in the project
VS Code .vscode/mcp.json in the workspace

Config formats are mostly JSON with an mcpServers key; VS Code uses a top-level servers object in mcp.json. Shapes below are the common case — check your host’s docs if a field name differs.

Connect a local stdio server

Local servers are launched by the host and spoken to over stdin/stdout. If you built the server yourself with the official SDKs, this is a one-liner with the Python CLI:

mcp install server.py --name "Demo Tools" -v DEBUG=1

Other servers — published packages, CLI tools — are one config entry. For example, to add the reference filesystem server to Claude Desktop:

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": ["-y", "@modelcontextprotocol/server-filesystem", "/Users/you/demo"]
    },
    "my-server": {
      "command": "python",
      "args": ["/absolute/path/to/server.py"],
      "env": { "API_KEY": "..." }
    }
  }
}

Details that trip people up:

  • command runs in a bare environment. Prefer absolute paths. If the command isn’t on the host’s PATH (GUI apps like Claude Desktop don’t source your shell rc), use the absolute path to node, python, or a wrapper like /bin/zsh -lc "...".
  • env is opt-in. Nothing from your shell is passed through unless you list it.
  • Restart the host after editing the config — servers are launched at startup.

For Claude Code, the CLI equivalent (project scope writes .mcp.json so teammates get it too):

claude mcp add demo-tools -- python /absolute/path/to/server.py
claude mcp add filesystem -- npx -y @modelcontextprotocol/server-filesystem /Users/you/demo

Connect a remote Streamable HTTP server

Remote servers are just a URL — the standard endpoint is /mcp (Streamable HTTP). For Claude Code:

claude mcp add --transport http linear-mcp https://mcp.linear.app/mcp

Or in a JSON config:

{
  "mcpServers": {
    "linear-mcp": {
      "type": "http",
      "url": "https://mcp.example.com/mcp",
      "headers": { "Authorization": "Bearer <token>" }
    }
  }
}

Hosts vary in how they spell a remote entry (type/url here; Cursor uses a url field with no command). The server itself decides how it authenticates you:

  • OAuth 2.1 (the spec’s authorization flow, 2025-06-18+): on first connect, the host opens a browser to the server’s authorization server, you consent, and the token is stored and refreshed automatically. This is how most commercial MCP providers (GitHub, Linear, Notion…) work.
  • Static credentials: pre-configure a token in the headers/env block for APIs that use API keys.
  • Nothing: fine for internal servers behind a proxy or on localhost.

Verify it works

  1. Restart the host (or reload the window in VS Code / Cursor).
  2. Look for the server’s tools in the model’s tool list, or check the host’s MCP panel (Cursor), the MCP: List Servers command in VS Code, or /mcp in Claude Code.
  3. No server showing up? Check the host’s logs:
Host Where logs live
Claude Desktop (macOS) ~/Library/Logs/Claude/mcp*.log
Claude Code claude --debug, or /mcp for connection status
Cursor Logs link in the MCP panel
VS Code Output panel → MCP Log channel

Troubleshooting

Symptom Likely cause Fix
Server never appears JSON syntax error, wrong path, or command not found Validate the JSON; run command args… yourself in a bare shell; use absolute paths
Server listed, tools missing Launch succeeded but the process crashed at startup Check the logs above; run the command manually and inspect stderr
Tool calls always fail Bad arguments — schema mismatch Test the same call in the MCP Inspector first
Server worked solo, broken under host Your code printed to stdout Stdout is the JSON-RPC wire on stdio — log to stderr instead
Timeouts on big responses Tool doing too much in one call Return progress notifications, or paginate results
Remote server 401s Expired/stale token or mis-pointed auth Reconnect to replay the OAuth flow; check WWW-Authenticate / audience setup server-side

Keep the security rules in mind

The model can call every tool you register — treat them like shell scripts in your PATH:

  • Review before you add. Prefer well-known, published servers; read the source of small unknown ones.
  • Scope what a local server can touch — the filesystem server above only sees the directory you pass it; bind servers to specific scopes, not ~.
  • Leave approvals on. Hosts ask before running risky tools by default; don’t blanket-approve tools that mutate data.
  • Remote servers are third parties. OAuth scopes and your API tokens should be as narrow as the tools require.
  • How to build an MCP server — expose your own tools, resources, and prompts with the Python or TypeScript SDK.
  • MCP Flow Architecture — what the client actually does for you: transports, lifecycle handshake, and tool-call flows, with diagrams.