How to Add an MCP Server to Claude Code (Desktop, CLI, More)
Learn how to add an MCP server to Claude Code, Claude Desktop, Cursor, and VS Code. Install, configure keys, troubleshoot, and build custom extensions.

Understanding MCP servers and how they help Claude
MCP stands for Model Context Protocol. It is a standard way for an LLM app to connect to outside tools and data.
With MCP, your model does not rely on one-off integrations. Instead, it discovers tool “capabilities” from an MCP server and calls them when needed.
This reduces prompt bloat and improves tool reliability. It also makes swaps easier when you change tools or backends.
- MCP server: runs the tools, data access, or actions
- MCP client: lets an app list tools and call them
- Transport: how the client reaches the server

Install an MCP server on Claude Desktop
Start with an MCP server you can run locally or in your network. Some servers ship as prebuilt packages. Others require you to clone a repo, install deps, then start a process.
Before touching Claude, run the server manually. Confirm it listens on the host and port you expect. Also check that it can reach its own data sources.
Next, open Claude Desktop and find the place for extensions or tools. The menu name can change by version. Common paths are Settings → Extensions or Tools → MCP servers → Add.
- Install or clone the MCP server package
- Start the server and verify it is reachable
- Open Claude Desktop settings
- Go to Extensions or Tools
- Add the MCP server connection details
After you add it, you should see the server in your extension list. Keep it enabled if you plan to use it right now. Disable it when you do not need tool access.

Configure the MCP server for Claude Code (and Claude via tools)
Once the server is reachable, you need to wire it into Claude code integration. This is the core answer to how to add mcp server to claude code in a practical way.
The workflow is usually the same across clients. First add connection info. Then add required secrets and permissions. Finally, test that the client can list tools.
If the MCP server uses third-party APIs, it will often require an API key. For safe setups, store keys in environment variables. Or use a server config file that your server reads at startup.
Avoid pasting secrets into prompts or UI fields that get logged. Instead, keep keys outside the chat flow. Then point Claude at the server, not at the key value.
Recommended setup checklist
- Host and port match what the server prints on startup
- Transport mode matches the server type you run
- API keys are available where the server process runs
- Permissions allow the server to read the needed files
- Tool listing works before you rely on tool calls
When tool listing works, simple prompts should succeed. For example, ask for an available tools list. Or ask for a basic “health check” if the server provides one.
If you are looking for how to add mcp server to claude in general, treat Claude Desktop and Claude code as the host. The MCP server stays the same. You only change the host-side config.

Troubleshoot MCP server connection issues with Claude
Use a two-step debug loop for troubleshoot mcp server issues. First confirm Claude can reach the server. Then confirm the server can handle the request.
Common connection failures include the wrong host or port. Another issue is the server not running. Mismatched transport also causes tool discovery to fail.
If the server starts but rejects calls, check configuration files. A bad config can prevent proper tool registration. It can also break access to files or remote APIs.
Fast diagnosis flow
- Verify the server process is running
- Test the host and port from the same machine
- Confirm keys exist in the server runtime environment
- Re-check permissions for any local file access
- Retry tool listing from Claude code
If Claude shows no tools, start by checking tool registration on the server side. Many servers log when they register capabilities. Then compare that to what Claude is able to list.
Also watch for CLI launch differences. If you run the server via a different shell, your environment variables may differ. That leads to “works manually, fails in Claude” behavior.

Configure MCP in other clients: Cursor, VS Code, ChatGPT, Codex, and CLI tools
MCP integration depends on the host app. Some apps offer a direct “MCP server” setting. Others use an MCP-capable extension. Either way, the MCP server installation stays the same.
Below are common patterns you can adapt. This helps with how to add mcp server to cursor, how to add mcp server in vscode, and how to add mcp server to vscode.
What to look for in each host
| Host app | Where MCP settings usually live | What you must provide |
|---|---|---|
| Cursor | Settings or an MCP-capable extension | Server host, port, and transport details |
| VS Code | Extensions panel for MCP tooling | Connection info and any API keys |
| ChatGPT | Custom tool or connector area (varies) | Connector config and secrets |
| Codex | Tool connectors or CLI config (varies) | Connection config and permissions |
If you need how to add mcp server to claude code cli, focus on the CLI host’s config. The idea stays the same. Point the CLI at your running MCP server. Then ensure the CLI runtime provides the keys the server needs.
The same principle applies to how to add mcp server to codex and how to add mcp server to codex cli. You configure the host to connect to your MCP server. The server handles the tools.
For how to add mcp server to chatgpt and how to add mcp server to cursor, expect different UI names. Still, you will always set connection details and keep secrets out of prompts.
For claude desktop how to add mcp server, use the Claude Desktop extensions flow. For how to add mcp server in cursor and how to add mcp server in vscode, follow the host’s extension or settings for MCP servers.
Also note: some tools mention “local servers.” That simply means host and port on your machine. Setup is still the same for how to add local mcp server to claude desktop.
Build custom MCP extensions and keep them maintainable
Once your base server works, you may want a custom MCP extension. That is the fastest path to tailored workflows. It also helps when you want tool behavior specific to your team.
For a custom workflow, build the server to expose narrow capabilities. For example, expose one capability for fetching repo context. Expose another for running a controlled action. Keep the tool schema tight and testable.
When you publish or deploy, treat updates as schema changes. A small change to tool names can break client tool discovery. You should version your server and test upgrades with your main host first.
Extension build checklist
- Define tool capabilities with clear inputs and outputs
- Validate inputs before calling external services
- Log tool calls and errors in a safe way
- Document required env vars for API keys
- Provide a “health check” capability for troubleshooting
If you are asking how to add custom mcp server to claude desktop, the “custom” part is server work. The “add” part uses the same Claude Desktop extensions flow you used earlier.
For how to add authentication to mcp server, apply auth on the server side. Require a token or API key for tool calls you want protected. Then ensure only your intended hosts can reach the server.
Finally, follow best practice for LLM tool use. Keep tools least-privilege. Also limit what the server can do with local files.
This helps you scale from one integration to many. It keeps updates boring and failures easy to debug.

Best practices for MCP integration across Claude and editors
Good MCP setup is mostly hygiene. That means stable server configs and predictable tool schemas. It also means keeping secrets in the right place.
Use consistent environment variable names across environments. For example, keep key names the same in your local shell and in your server config. This avoids “works in one app, fails in another” surprises.
Pin versions when a server or client changes behavior. Update one piece at a time. Then run a tool listing test after each update.
- Prefer local server for development and testing
- Use environment variables for API keys
- Test tool listing before tool calling
- Version your custom MCP server when you change schemas
- Log errors safely and add a health check tool
If you are still stuck, check whether the client expects an absolute URL or a local transport. Also confirm that the client can reach the server from its runtime context.
These steps cover the common cases for how to add mcp server claude code, how to add mcp server to claude code, how to add mcp server to claude desktop, and how to add mcp server to vscode.
They also help you adapt to other hosts and editors as they add MCP support. The core idea remains the same. Run the server. Then configure the host to connect.
FAQ
- How do I add an MCP server to Claude Code?
- Add the MCP server connection in Claude code settings, then supply any needed secrets for the server runtime. Finally, test tool listing with a simple prompt.
- How do I install an MCP server on Claude Desktop?
- Run the MCP server locally first. Then open Claude Desktop settings, find extensions or tools, and add the server connection details.
- Why does Claude show no tools after I add my MCP server?
- Most often the host cannot reach the server, or the server failed to register tools. Verify host, port, transport, and server logs, then retry tool listing.
- How do I add an MCP server to Cursor or VS Code?
- Look for MCP server settings or an MCP-capable extension in each editor. Configure host connection info and make sure the server has its required API keys.
- How do I add authentication to an MCP server?
- Implement auth on the MCP server side. Require a token for protected tool calls, and restrict who can reach the server host and port.
- How do I add a custom MCP server to Claude Desktop?
- Build or install your custom MCP server first. Then add it using the same Claude Desktop extensions or tools flow for MCP servers.


