Connect clients
Connect a generated MCP server to Claude Code, Cursor, VS Code and Claude.ai, over stdio locally or Streamable HTTP remotely.
By Harsha VardhanUpdated
There are two ways to connect:
- Local (stdio): the client launches your server as a process.
- Remote (HTTP): the client connects to a URL, such as a Cloudflare Worker's
/mcpendpoint.
In the examples, replace /absolute/path/to/my-mcp with your project folder and https://my-mcp.example.workers.dev/mcp with your endpoint. The built entry file is build/index.js (the generated package.json sets "main" to it, and npm start runs node build/index.js).
Claude Code#
# Local stdio server, passing a credential
claude mcp add --env API_KEY_MYSCHEME=your-key --transport stdio my-api -- node /absolute/path/to/my-mcp/build/index.js
# Remote Streamable HTTP server
claude mcp add --transport http my-api https://my-mcp.example.workers.dev/mcp
# Remote server generated with --inbound-auth bearer
claude mcp add --transport http my-api https://my-mcp.example.workers.dev/mcp \
--header "Authorization: Bearer $MCP_AUTH_TOKEN"Put Claude Code's options before the server name and the launch command after --. Keep another option such as --transport stdio between --env and the name, or the CLI reads the name as another KEY=value pair. Source: Claude Code MCP docs.
Cursor#
Add the server to .cursor/mcp.json in your project, or to your global Cursor MCP settings:
{
"mcpServers": {
"my-api": {
"command": "node",
"args": ["/absolute/path/to/my-mcp/build/index.js"],
"env": { "API_KEY_MYSCHEME": "your-key" }
},
"my-api-remote": {
"url": "https://my-mcp.example.workers.dev/mcp"
}
}
}VS Code#
The quickest way is the MCP: Add Server command: choose Command (stdio) for a local server or HTTP for a remote one, then choose where to save it. VS Code reads two file formats.
Portable format (recommended)#
Put servers under mcpServers in .mcp.json at the root of your workspace to share them with the project, or in ~/.copilot/mcp-config.json to use them in every workspace ($COPILOT_HOME/mcp-config.json when COPILOT_HOME is set). Copilot agent sessions read this format directly.
{
"mcpServers": {
"my-api": {
"command": "node",
"args": ["/absolute/path/to/my-mcp/build/index.js"],
"env": { "API_KEY_MYSCHEME": "${API_KEY_MYSCHEME}" }
},
"my-api-remote": {
"type": "http",
"url": "https://my-mcp.example.workers.dev/mcp",
"headers": { "Authorization": "Bearer ${MCP_AUTH_TOKEN}" }
}
}
}${NAME}is read from the environment VS Code runs in, so credentials stay out of the file. Use the braced form (a bare$NAMEis treated as literal text), and restart VS Code after changing the variables.- Include
headersonly for servers generated with--inbound-auth bearer. - The portable format has no input prompts or env files. Workspace-root
.mcp.jsonsupports stdio and HTTP servers; for an SSE server (--transport=web), use~/.copilot/mcp-config.jsonor the VS Code format below. - MCP: Add Server offers the workspace-root
.mcp.jsondestination only when the experimentalchat.mcp.workspaceRootConfig.enabledsetting is on. A.mcp.jsonfile you create yourself is used either way.
VS Code format (still supported)#
Servers under servers in .vscode/mcp.json in your workspace, or in mcp.json in your user profile. VS Code keeps these locations for compatibility and labels them deprecated in the Add Server flow. Use them when you need input prompts (${input:...}), an env file or per-server sandboxing.
{
"servers": {
"my-api": {
"type": "stdio",
"command": "node",
"args": ["/absolute/path/to/my-mcp/build/index.js"]
},
"my-api-remote": {
"type": "http",
"url": "https://my-mcp.example.workers.dev/mcp"
}
}
}Sources: Add MCP servers and MCP configuration reference, checked 24 October 2026.
Claude.ai#
Claude.ai connects to remote MCP servers as custom connectors. Claude connects from Anthropic's cloud, so your server must be reachable from the public internet over HTTPS, for example a deployed Cloudflare Worker.
- Deploy the server and note the
/mcpURL. - Add a custom connector and paste the URL:
- Free (one connector), Pro and Max: Customize > Connectors > Add custom connector.
- Team and Enterprise: an Owner adds it under Organization settings > Connectors > Add > Custom.
Supported authentication: OAuth 2.0 (dynamic client registration or a client ID metadata document), a static API key or bearer header entered by an organization Owner (beta), or none. See Anthropic's guide to remote MCP custom connectors.
Claude Desktop and other stdio-only clients#
Use the stdio build directly, or reach a remote server through mcp-remote.
Test in the browser#
Generated web, streamable-http and Worker servers also serve the playground at their own root URL, for example http://localhost:3000/ (or http://localhost:8787/ for npm run dev on a Worker). Use that for local servers: it is served from the server's own origin, so it needs no CORS or MCP_ALLOWED_ORIGINS changes. It lists the tools, builds a form for each one, runs it and shows every JSON-RPC message, with copy-as-curl and client configs.
For deployed servers, use the hosted playground and enter your /mcp URL. If the server uses --inbound-auth bearer, paste the token into the page; it stays in your browser tab and is only sent to your server.
- The hosted page can reach local servers only in Chrome (after its local-network permission prompt) and Firefox. Safari blocks it.
- Node servers must list
https://mcp.pidata.techinMCP_ALLOWED_ORIGINSto accept the hosted page. Workers answer CORS already. - stdio servers have no HTTP endpoint; test them with the MCP Inspector.