To add an MCP server to Claude Code, run claude mcp add in your terminal with the server’s transport and endpoint or launch command. Then check claude mcp list, open /mcp inside Claude Code, and test one of the server’s tools. A saved configuration is only the first checkpoint; a successful tool call proves the connection works.
Start with the official documentation server below: it needs no provider account or token. Once it works, use the transport and authentication instructions for the service you want to connect. The scope table shows where the entry will live and whether it follows you into other projects.
Add your first MCP server to Claude Code
Start with Claude Code installed and authenticated, and open a terminal in the project where you want the server available. The default scope is tied to this project. If you later open a different directory and cannot see the server, that may be expected scope behavior rather than a failed installation.
claude --versionclaude mcp add --transport http claude-code-docs https://code.claude.com/docs/mcpclaude mcp listThe first line records the version you are using. The second registers the documentation server. The third checks configured servers and their connection status. The name claude-code-docs is a label you choose; use it consistently when inspecting or removing this entry. The URL is the server endpoint, not the documentation homepage.
This example comes from the official MCP quickstart. The documentation endpoint does not require server authentication. Other endpoints may require a browser sign-in or a provider-issued token, even when Claude Code itself is already signed in.
claude/mcpSelect the new server and inspect its available tools. Then ask a narrow question that explicitly uses it, such as: “Use claude-code-docs to find the documentation for MCP_TIMEOUT and explain what it controls.” Check the tool call shown in the conversation. An answer without a call to that server could have come from another source.
- Step 1RegisterThe configuration entry is saved.
- Step 2ConnectThe endpoint or local process responds.
- Step 3VerifyA named tool returns the expected result.
Keep the first task small and read-only. For a documentation service, retrieving one relevant page is enough. For a work system, choose a known record you are permitted to view. Confirm the record identifier and returned content before asking the assistant to create, edit or delete anything.
Choose HTTP or stdio from the server’s instructions
MCP describes how a client and server communicate. It does not mean every server installs as an npm package. Your provider should supply either a remote endpoint or a command that launches a local process. Match that shape before changing credentials or timeouts.
| What you have | Connection type | What Claude Code needs |
|---|---|---|
| An HTTPS MCP endpoint | HTTP | The exact endpoint and any required authentication |
| A command that starts a program | stdio | The executable, arguments and required environment |
| An older SSE-only endpoint | SSE compatibility | The provider’s instructions and a compatible client version |
| A WebSocket endpoint | WebSocket JSON configuration | An explicit ws entry; the add transport flag does not accept ws |
The MCP reference recommends HTTP for remote connections and marks SSE transport as deprecated. Current releases can fall back from HTTP to SSE; that behavior requires version 2.1.265 or later. Follow your server’s documented endpoint rather than changing /sse to /mcp by guesswork.
For a local server, give Claude Code the command it should start. The following is a template for a Node-based server you have already installed and reviewed. Replace the absolute path with the real entry point; it is not a package to download.
claude mcp add --transport stdio --scope local local-docs -- node /absolute/path/to/server.jsEverything after -- belongs to the server command. This separator prevents a server flag from being interpreted as a Claude Code flag. Quote a path containing spaces, and check that the required runtime is installed in the same environment where Claude Code runs. Node is relevant to this example; a Python or native server has different prerequisites.
A stdio server normally starts when the client connects. You do not need to run a second copy in another terminal unless its own instructions require that. If you do run its command to diagnose startup, do so only after reviewing what that program does. Waiting silently for protocol input can be normal; a missing executable or immediate crash is not.
Pick local, project or user scope deliberately
Scope answers who receives the configuration and where it loads. It does not determine whether the server runs locally. A remote HTTP server can have local scope; a local stdio process can have user scope. Separating those two meanings prevents a common setup mistake.
| Scope | Where it loads | Where it is stored |
|---|---|---|
| local, the default | Only you, in the current project | Project-specific entry in ~/.claude.json |
| project | This project; shareable with teammates | .mcp.json at the project root |
| user | Your projects on this machine | Top-level server entry in ~/.claude.json |
For a personal experiment, the default is usually enough. Choose project scope when the team needs a shared definition that can be reviewed in version control. Choose user scope when you intentionally want the same server available across your projects. “User” is the flag to look for when searching for a global Claude Code MCP configuration.
claude mcp get claude-code-docsclaude mcp remove claude-code-docs --scope localclaude mcp add --scope user --transport http claude-code-docs https://code.claude.com/docs/mcpThese lines move the earlier example from local to user scope. Inspect first, remove the specific old entry, then add the replacement. If you already removed the test server, skip the removal. To share it through the repository instead, use --scope project on the add command.
Among these three scopes, local takes precedence over project, which takes precedence over user when names match. The selected entry replaces the whole definition; fields do not merge. Organization-managed configuration can take precedence over personal settings. A surprising endpoint may therefore be a duplicate-name problem, not an ignored edit. See installation scopes.
- Your home directory/Personal settings
- .claude.jsonLocal and user MCP entries
- Your project/Shared configuration
- .mcp.jsonProject MCP server definitions
Use .mcp.json for a shared project configuration
If you prefer a reviewed file, place this JSON at the project root. It defines the same documentation endpoint at project scope. Merge the entry into an existing mcpServers object rather than overwriting other servers. Do not keep another same-name local entry unless you deliberately want it to override this file.
{ "mcpServers": { "claude-code-docs": { "type": "http", "url": "https://code.claude.com/docs/mcp" } }}Start a new Claude Code session in that project after saving. In an ordinary interactive session, review the project-server approval prompt. If you previously rejected it and want to reconsider, claude mcp reset-project-choices resets those choices; restart and review the prompt again. Managed restrictions still apply.
Use valid JSON: double-quoted keys and strings, no comments, and no trailing commas. A remote entry needs its transport type. A URL without type can be read as an invalid stdio definition. For a local entry, use command and an args array, keeping each argument separate rather than placing an entire shell command in one field.
Sharing a file shares its configuration, not a universal login. Each teammate may need their own provider account, access rights and environment variables. Review the diff before committing it, especially URLs, headers and environment fields. A private repository is still the wrong place for a reusable secret.
Authenticate, then test the permissions you actually need
For an OAuth-enabled remote server, add its documented endpoint, start Claude Code and open /mcp. Select the server and choose Authenticate. Complete the provider’s browser flow, checking the account and requested permissions. Return to Claude Code and verify the server’s status before testing a tool.
For a token-based service, follow the provider’s header format. If sharing configuration, use an environment-variable reference so each person supplies their own secret outside the file. This illustrative entry uses a placeholder domain and a dedicated token name; replace the endpoint and set the variable before launching Claude Code.
{ "mcpServers": { "team-docs": { "type": "http", "url": "https://mcp.example.com/mcp", "headers": { "Authorization": "Bearer ${TEAM_DOCS_MCP_TOKEN}" } } }}An environment reference is not an encryption mechanism. The running process must receive the value, and the provider receives the authentication header. Do not place the literal token in a copied command, screenshot or committed file. Avoid reusing Claude Code’s own credentials for an unrelated MCP service. The environment expansion reference explains unset values and protected credential names.
Successful authentication also does not establish authorization for every record or action. Test an expected read, inspect the returned result, and distinguish a missing record from a permission denial. If a server offers write tools, review their scope separately. The MCP safety guide explains why retrieved content and tool permissions need separate attention.
Troubleshoot the first failing checkpoint
Run claude mcp get with the server’s name to inspect details, and use /mcp for session status, authentication and reconnect options. Keep the exact message and your Claude Code version when reporting a problem. Redact secrets before sharing configuration or logs.
| Symptom | Check next | Useful correction |
|---|---|---|
| No server appears | Working directory and scope | Start in the project where it was added, or choose user scope intentionally |
| Server already exists | Same name in the selected scope | Inspect and remove the intended entry before re-adding |
| Pending approval | Interactive project approval | Start claude in the project and review the server |
| Needs authentication or HTTP 401 | Provider sign-in and token | Authenticate or correct the dedicated credential |
| Local process fails immediately | Executable, path, arguments, runtime | Correct the launch command before increasing timeouts |
| Connected, but tools fetch failed | Discovery error detail | Inspect get output and the provider’s server health |
| Connected, but expected tool absent | Tool list and access policy | Check what this account and server expose |
| Edited JSON seems ignored | Session startup and duplicate scopes | Start a new session and inspect higher-priority entries |
An HTTP endpoint may not display a normal web page in a browser. A browser GET response alone does not prove an MCP handshake succeeded or failed. Use the client’s connection check. Similarly, a server may expose resources or prompts without the particular tool you expected; check its documented capabilities before treating that as a transport problem.
For a timeout, first rule out a wrong endpoint, unavailable runtime, package download or blocked network path. Raising a timeout cannot repair a bad command. If an organization policy blocks the server, resolve the policy with the administrator instead of trying another name to evade it. For broader client differences, see the cross-client MCP installation guide.
Verify completion and remove an experiment cleanly
- The intended definition loads in the intended project.
- The connection and authentication are healthy.
- The required tool is visible and permitted.
- One small tool call returns a result you can verify.
- The file contains no literal secrets.
- Paths and prerequisites are documented for teammates.
- A fresh session loads the configuration.
- The owner and intended permissions are clear.
If the documentation server was only a test, remove the scope you actually used. The command below removes the user-scoped entry created earlier. A project-scoped entry requires --scope project; the original default entry requires --scope local.
claude mcp remove claude-code-docs --scope userFor a remote service with OAuth, removing its configuration is not the same as revoking access at the provider. The current CLI supports claude mcp logout <name> before removal, with revocation where the authorization server supports it. Check the provider’s connected-app settings when ending access. The authentication reference covers the distinction.
Questions people ask
Can I add an MCP server globally in Claude Code?
Use --scope user when adding it. The configuration is available across your projects on this machine. Remove a same-name local entry if you do not want it to override the user definition.
Where is the Claude Code MCP configuration file?
Local and user definitions are stored in ~/.claude.json by default. Project definitions are in .mcp.json at the project root. A configured CLAUDE_CONFIG_DIR changes the personal configuration location.
Do I type /mcp in the terminal?
Type /mcp inside an interactive Claude Code session. Use claude mcp add, list, get and remove in your operating-system terminal.
Is Claude Desktop configuration the same as Claude Code configuration?
The chat app’s claude_desktop_config.json is a separate configuration. The CLI offers claude mcp add-from-claude-desktop on macOS or WSL to import entries. The Claude Code desktop app also has its own Connectors interface. Follow the instructions for the surface you use.
Do I need to restart Claude Code after editing .mcp.json?
Start a new session after editing the project file so it is read at startup. For a server already loaded in the session, /mcp also provides reconnect and authentication controls.



