-
Notifications
You must be signed in to change notification settings - Fork 14.8k
The mcp auth and mcp debug don't send configured headers during OAuth flow #20286
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)Anything pertaining to core functionality of the application (opencode server stuff)
Description
Description
When a remote MCP server requires custom headers on every request (e.g. for routing/realm selection), the opencode mcp auth and opencode mcp debug commands fail because the headers configured under mcp..headers are not forwarded during the OAuth flow.
The headers are correctly sent for normal MCP connections (connectRemote), but three code paths ignore them:
- startAuth in src/mcp/index.ts — creates StreamableHTTPClientTransport without requestInit
- The fetch probe in src/cli/cmd/mcp.ts (McpDebugCommand) — raw fetch() call omits the headers
- The OAuth transport in src/cli/cmd/mcp.ts (McpDebugCommand) — creates StreamableHTTPClientTransport without requestInit
The result: mcp auth gets a 404 instead of 401 from the server and reports "Authentication failed". mcp debug similarly probes without the headers and reports wrong status.
Plugins
No response
OpenCode version
1.3.10
Steps to reproduce
- Configure a remote MCP server that requires a custom header on all requests:
mcp: {
my-server: {
type: remote,
url: https://example.com/mcp,
headers: { X-Custom-Header: value },
oauth: {}
}
}
- Run opencode mcp auth my-server
- Authentication fails with a 404 error
Screenshot and/or share link
No response
Operating System
Linux (Fedora 43)
Terminal
Ghostty
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workingcoreAnything pertaining to core functionality of the application (opencode server stuff)Anything pertaining to core functionality of the application (opencode server stuff)