/mcp command inside a session or through CLI subcommands outside one. This page covers the full management lifecycle.
Interactive server management
Inside any Claude Code session, run/mcp to open the MCP settings panel. This panel shows all configured servers, their connection status, and lets you enable or disable servers for the current session.
You can also use /mcp with arguments directly:
MCPToggle component in commands/mcp/mcp.tsx:12. The enable/disable state persists within the session but does not modify your config files.
CLI subcommands
Outside of a session, use theclaude mcp subcommands to manage server configurations.
List all servers
Get details for a specific server
Remove a server
local scope by default. Use -s to target a specific scope:
removeMcpConfig in services/mcp/config.ts:769. The function throws an error if the server is not found in the specified scope, so you will get a clear message if you target the wrong scope.
You can only remove servers from
local, user, and project scopes. Servers in enterprise or dynamic scopes are managed externally and cannot be removed via the CLI.Connection states
Each server connection is typed asMCPServerConnection in services/mcp/types.ts:221, which is a union of five states:
connected
connected
The server is reachable and its tools are available to Claude. The
ConnectedMCPServer object includes the server’s reported capabilities, version information, and any instructions the server provides.pending
pending
Claude Code is actively attempting to connect or is waiting to retry after a failure. The
PendingMCPServer type includes reconnectAttempt and maxReconnectAttempts fields that track retry progress.needs-auth
needs-auth
The server requires OAuth authentication before it can be used. Claude Code will prompt you to complete the OAuth flow. See Authentication below.
failed
failed
The connection could not be established. The
FailedMCPServer type includes an error string with the failure reason. Run /mcp reconnect <name> to retry, or check the troubleshooting section below.disabled
disabled
The server is configured but has been manually disabled for the current session via
/mcp disable. Use /mcp enable <name> to re-enable it.Authentication
Remote MCP servers (HTTP and SSE transport) can require OAuth authentication. When Claude Code connects to such a server for the first time, it transitions toneeds-auth state and prompts you to complete the flow.
OAuth client secrets
Client secrets are stored in the system keychain rather than in config files. If you added a server with--client-secret, the secret was saved at add time. You can update it by removing and re-adding the server.
OAuth callback port
Some servers require a pre-registered redirect URI. Use--callback-port when adding the server to fix the local callback port:
callbackPort: 8085 in the oauth block of the server config (see McpOAuthConfigSchema in services/mcp/types.ts:43).
Project-scoped servers and .mcp.json
When you add a server with --scope project, it is written to .mcp.json in your current working directory. This file is designed to be committed to version control so every team member gets the same servers automatically.
The file format is:
.mcp.json files. Files closer to the current working directory take precedence over those in parent directories (getMcpConfigsByScope in services/mcp/config.ts:888).
Duplicate server deduplication
If two configurations point to the same underlying server (same command array for stdio, or same URL for remote), Claude Code deduplicates them:- A manually configured server always wins over a plugin-provided or claude.ai connector server with the same signature.
- Among plugin-provided servers, the first-loaded one wins.
- Suppressed duplicates are logged at debug level.
dedupPluginMcpServers and dedupClaudeAiMcpServers in services/mcp/config.ts:223.
Troubleshooting
Server shows as failed at startup
Server shows as failed at startup
Check that the command or URL is correct. For stdio servers, verify the executable is on your For remote servers, confirm the endpoint is reachable:Use
PATH:/mcp reconnect <name> inside a session to retry without restarting Claude Code.Environment variables not expanding
Environment variables not expanding
Variables in your config must be set in the environment where you launch
claude. Add them to your shell profile or .env file and restart the terminal.If a variable is missing at startup, Claude Code logs a warning listing the unresolved variable names. Check your debug logs for lines referencing missingVars.Tools from a server are not appearing
Tools from a server are not appearing
Confirm the server is in
connected state via /mcp. If it is connected but tools are missing, the server may not have advertised any tools (it may only provide resources or prompts). Check the server’s own documentation.Also check that the server is not disabled — run /mcp enable <name> to re-enable it.'Server already exists' error when adding
'Server already exists' error when adding
Each server name must be unique within a scope. If you get this error, either pick a different name or remove the existing entry first:
'Enterprise MCP configuration is active' error
'Enterprise MCP configuration is active' error
When an enterprise-managed MCP config exists, it takes exclusive control and you cannot add or remove servers via the CLI. Contact your administrator to adjust the managed configuration.
Server blocked by enterprise policy
Server blocked by enterprise policy
Your organization’s policy may restrict which servers can run. The error message will indicate whether the server is on a denylist or not on an allowlist. Contact your administrator to request an exception.