Manage MCP Servers
Full reference for configuring, scoping, authenticating, and managing MCP servers in Command Code.
All MCP management is done through cmd mcp <subcommand>.
Add a Server
| Command | Description | Example |
|---|---|---|
cmd mcp add | Add server with CLI options | cmd mcp add --transport http notion https://mcp.notion.com/mcp |
cmd mcp add-json | Add server from JSON config | cmd mcp add-json github '{"type":"http","url":"https://..."}' |
Manage Servers
| Command | Description | Example |
|---|---|---|
cmd mcp list | List all configured servers | cmd mcp list |
cmd mcp get | Show detailed config for a server | cmd mcp get notion |
cmd mcp remove | Remove a server from configuration | cmd mcp remove notion |
Authentication
| Command | Description | Example |
|---|---|---|
cmd mcp auth <server> | Authenticate with OAuth (opens browser) | cmd mcp auth notion |
cmd mcp auth --status | Check authentication status | cmd mcp auth --status notion |
cmd mcp auth --list | List all servers with stored tokens | cmd mcp auth --list |
cmd mcp auth --clear | Clear stored tokens | cmd mcp auth --clear notion |
MCP servers can be stored in three scopes with different visibility:
| Scope | File Location | Purpose |
|---|---|---|
local | ~/.commandcode/projects/<slug>/mcp.json | Private, per-project (default) |
project | .mcp.json in project root | Shared, version controlled |
user | ~/.commandcode/mcp.json | Private, available across all projects |
Precedence: When the same server name exists in multiple scopes, local overrides project, which overrides user.
Scope Examples
cmd mcp add --transport http notion https://mcp.notion.com/mcp
Config Schema
The configuration files follow this schema:
Config Schema
{
"mcpServers": {
"my-server": {
"transport": "http",
"enabled": true,
"url": "https://api.example.com/mcp",
"headers": { "Authorization": "Bearer token" },
"env": { "API_KEY": "value" }
}
}
}
Every MCP server is configured at a specific scope that controls visibility and sharing.
Local scope (default)
Stored in ~/.commandcode/. Only available to you for the current project.
cmd mcp add --transport http stripe https://mcp.stripe.com
# Explicit:
cmd mcp add --transport http stripe --scope local https://mcp.stripe.com
Project scope
Stored in .mcp.json at your project root. Checked into version control — shared with your team.
cmd mcp add --transport http stripe --scope project https://mcp.stripe.com
This creates or updates .mcp.json:
{
"mcpServers": {
"stripe": {
"transport": "http",
"url": "https://mcp.stripe.com"
}
}
}
User scope
Stored in ~/.commandcode/mcp.json. Available to you across all projects.
cmd mcp add --transport http stripe --scope user https://mcp.stripe.com
OAuth Flow
Command Code supports OAuth 2.0 Authorization Code with PKCE for HTTP servers.
Add a server that requires OAuth
Add OAuth Server
cmd mcp add --transport http my-server https://api.example.com/mcp
If the server requires authentication, Command Code detects this automatically and starts the OAuth flow.
Authenticate via browser
A browser window opens for you to authorize. After you grant access, tokens are stored securely in ~/.commandcode/mcp-tokens.json.
You can also authenticate later:
Authenticate
cmd mcp auth my-server
Or use the /mcp menu inside a session to authenticate interactively.
Tokens refresh automatically
Tokens are refreshed automatically when they expire. If refresh fails, re-authenticate with cmd mcp auth <server>.
Token Commands
cmd mcp auth --status my-server
OAuth Flow (remote servers)
Many remote MCP servers support OAuth 2.0. Use /mcp inside Command Code to authenticate:
/mcp
Select the server and follow the browser login flow. Tokens are stored securely and refreshed automatically.
Tips:
- Use "Clear authentication" in
/mcpto revoke access - If your browser doesn't open automatically, copy the provided URL
- OAuth works with HTTP and SSE transport servers
OAuth with JSON
cmd mcp add-json my-server \
'{"type":"http","url":"https://mcp.example.com/mcp","oauth":{"clientId":"your-client-id","callbackPort":8080}}' \
--client-secret
API key auth
For servers that use API keys, pass them as environment variables or headers:
# Via env
cmd mcp add --transport stdio --env API_KEY=your-key my-server \
-- npx -y my-mcp-server
# Via header
cmd mcp add --transport http my-server https://api.example.com/mcp \
--header "Authorization: Bearer your-token"
- Check out our MCP Quickstart to add your first MCP server
- Join our Discord community for support