Remote servers & OAuth¶
Streamable HTTP and SSE¶
{
"mcpServers": {
"docs": {"url": "https://example.com/mcp"},
"keyed": {"url": "https://api.example.com/mcp", "headers": {"Authorization": "Bearer ${API_KEY}"}},
"legacy": {"type": "sse", "url": "https://example.com/sse"}
}
}
An entry with a url and no type uses Streamable HTTP.
OAuth 2.1¶
Many hosted MCP servers (Linear, Atlassian, Notion, …) require users to sign in. Turn on OAuth for the server:
On first use, codemode-mcp:
- discovers the authorization server from the MCP server's metadata (RFC 9728 / RFC 8414);
- registers itself with dynamic client registration if the server supports it;
- opens your browser at the sign-in page, and prints the URL to stderr in case it can't;
- receives the authorization code on
http://localhost:33418/callback(PKCE, S256); - stores the tokens in
~/.codemode-mcp/oauth/<server>-<hash>.json, with permissions0600where the OS supports them.
Later runs reuse the stored tokens and refresh them automatically, so the browser only opens again if access is revoked.
Sign in ahead of time¶
When codemode-mcp is started by a desktop client, it's convenient to sign in once from a terminal first:
codemode-mcp login linear -c mcp.json
codemode-mcp login linear -c mcp.json --logout # forget the stored credentials
Pre-registered clients¶
If the provider gave you client credentials:
{
"mcpServers": {
"corp": {
"url": "https://mcp.corp.example/mcp",
"oauth": {
"client_id": "abc123",
"client_secret": "${CORP_CLIENT_SECRET}",
"scopes": ["read", "write"],
"redirect_port": 33418
}
}
}
}
Register http://localhost:<redirect_port>/callback as the redirect URI with the provider.
| OAuth option | Default | Description |
|---|---|---|
client_id |
dynamic registration | Pre-registered client ID |
client_secret |
none (public client) | Confidential-client secret (client_secret_post) |
scopes |
server default | List or space-separated string |
redirect_port |
33418 |
Port for the local callback server |
client_name |
codemode-mcp |
Name shown on the consent screen (dynamic registration) |
Headless machines¶
The callback needs a browser that can reach localhost on the machine running
codemode-mcp. On a remote server, either:
- run
codemode-mcp loginon your workstation and copy~/.codemode-mcp/oauth/across, or - forward the port with
ssh -L 33418:localhost:33418 server, runloginon the server, and open the printed URL locally.
Try it locally¶
The repository includes an OAuth-protected demo server with an auto-approving authorization server: