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
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:
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
Screenshot and/or share link
No response
Operating System
Linux (Fedora 43)
Terminal
Ghostty