github / github/copilot-cli

HTTP MCP server with Bearer token fails OAuth discovery instead of falling back to headers auth

未关闭
#3,100 0 条评论 9 个 reaction 已指派 0 人 在 GitHub 查看
area:authentication area:mcp
主要语言
Shell
星标
11.2k
派生
1.9k
平均合并
14 小时 16 分钟
30 天内合并 PR
6

描述

### Describe the bug

When an HTTP MCP server is configured in .mcp.json with "type": "http" and "headers": { "Authorization": "Bearer " }, the CLI attempts OAuth discovery
(/.well-known/oauth-authorization-server
) and fails with:

MCPOAuthError: Failed to discover authorization server metadata

The CLI does not fall back to using the provided Bearer token from headers, causing a hard auth failure even though valid credentials are present in the config.

### Affected version

_No response_

### Steps to reproduce the behavior

1. Configure the mcp config for server which using custom token authorization
2. Run /mcp
3. Select the configured server
4. Pay attention to the error

Actual behavior: Hard fail on OAuth discovery, server stays disabled.

Image

### Expected behavior

Expected behavior: If OAuth discovery fails and headers contains Authorization: Bearer, the CLI should skip OAuth and proceed to MCP initialize using the provided token.

### Additional context

Workaround: Manually enabling the server via /mcp enable bypasses OAuth discovery and connects successfully using the Bearer token.

MCP spec reference: OAuth is optional — clients should fall back to configured credentials when authorization server metadata is not found.

贡献指南

打开贡献指南

调研方向

Start by reproducing the failure with an HTTP server configured in .mcp.json and the /mcp command. Trace the OAuth discovery path at /.well-known/oauth-authorization-server alongside the configured Authorization header handling. Done means discovery failure no longer disables the server when a Bearer token is configured, and MCP initialization succeeds using that token.

由索引模型根据 Issue 内容生成。

评估

技术栈
shell
领域
api, authentication, cli
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
冷清
描述清晰度
基本清楚
新手友好度
52/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。