MCP surfaces use API keys for authentication. Secure your MCP connections by properly managing keys and understanding authentication Flows.
How MCP authentication works
MCP Surfaces support two authentication modes:
- OAuth — The AI IDE connects to your MCP server URL directly. On first connection, the user authorizes via a browser-based OAuth flow. This is the recommended mode for Claude Desktop and Cursor.
- API Key — The IDE passes an API key (with the
mcp_ prefix) as a Bearer token in each request. Use this for clients that do not support OAuth.
Authentication flow with API keys:
- IDE connects to the MCP server URL with the API key
- Runtype validates the key on each request
- AI assistant discovers available tools
- When invoking a tool, the IDE includes the API key in the request
- Runtype validates the key and executes the Capability
Creating MCP-specific keys
Create dedicated API keys for MCP to isolate access:
- Go to your MCP Surface
- Open the Keys tab
- Click Generate API Key
- Name it descriptively, such as “MCP - Claude Desktop”
- Click Generate
- Copy the key immediately. Production keys cannot be recovered after creation.
MCP Surface keys use the mcp_ prefix. Use separate keys for each IDE or team member so you can revoke access without disrupting other users.
Key security
When using API key authentication, keys are stored in plain text in IDE configuration files. Protect them:
- Don’t commit to version control — Add IDE config files to
.gitignore
- Use environment-specific keys — Development keys for local IDEs, production keys only when necessary
- Rotate regularly — Generate new keys periodically
Revoking MCP access
If a key is compromised or no longer needed:
- Go to your MCP Surface
- Open the Keys tab
- Find the key to revoke
- Click Revoke
- Confirm
The key stops working immediately. Update IDE configurations with a new key if continued access is needed.
Authentication errors
Common MCP authentication issues:
Invalid API key:
- Key was revoked or deleted
- Typo in configuration
- Using development key with production surface
Permission denied:
- Key is scoped to different capabilities
- Surface status is Inactive
Check the IDE’s output panel for detailed error messages from the MCP server.
Next steps