modelcontextprotocol / modelcontextprotocol/example-remote-server
Confusion with `WWW-Authenticate` and EXTERNAL server mode
还没有人认领这个 Issue。
- 主要语言
- TypeScript
- 星标
- 80
- 派生
- 39
- 平均合并
- 43 分钟
- 30 天内合并 PR
- 1
描述
Describe the bug
It seems there is some confusion in this example project regarding the EXTERNAL mode.
In this mode, there should be two distinct servers:
- one for authentication (OAuth2),
- one for the MCP server.
However, even in EXTERNAL mode, the example project still exposes the resource /.well-known/oauth-authorization-server on the MCP server.
This should not be the case. This resource is exposed by the OAuth2 authorization server, not by the MCP server, no ?
According to the MCP specification, the MCP server should instead expose: /.well-known/oauth-protected-resource
(see: https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization#protected-resource-metadata-discovery-requirements)
This resource is discovered by the client via the WWW-Authenticate header, which contains the URL of the MCP protected-resource metadata.
The JSON returned by this /.well-known/oauth-protected-resource endpoint must provide the base URL of the external authorization server.
Example response:
{
"resource": "http://localhost:3232/mcp",
"resource_name": "MCP Server",
"authorization_servers": [
"http://localhost:3001"
]
}
The client then uses this information to discover the authorization server metadata, as described in the spec:
https://modelcontextprotocol.io/specification/2025-11-25/basic/authorization#authorization-server-metadata-discovery
The spec allows several discovery patterns, such as:
-
OAuth 2.0 Authorization Server Metadata with path insertion:
https://auth.example.com/.well-known/oauth-authorization-server/tenant1 -
OpenID Connect Discovery 1.0 with path insertion:
https://auth.example.com/.well-known/openid-configuration/tenant1 -
OpenID Connect Discovery 1.0 with path appending:
https://auth.example.com/tenant1/.well-known/openid-configuration
This seems to be related to this topic on the inspector. Which seems to ignore the WWW-Authenticate header and make calls directly to the MCP server, expecting to deal with the authentication server.
To Reproduce
This issue can be observed by testing MCP clients + server that rely on this discovery mechanism.
For these clients, the current implementation does not work as expected.
Expected behavior
Add the /.well-known/oauth-protected-resource endpoint to the MCP server.
Remove the .well-known/oauth-authorization-server on the Mcp Server.Because it already displays this one by default.
Logs
If applicable, add logs to help explain your problem.
Additional context
Add any other context about the problem here.
贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
调研方向
从 MCP server 的 well-known 路由配置入手,检查 EXTERNAL 模式如何公开 /.well-known/oauth-authorization-server。将其行为与链接的 MCP authorization specification 进行比较,并验证 WWW-Authenticate 流程。完成的标准是 MCP server 公开 /.well-known/oauth-protected-resource,其中包含外部 authorization server 的 URL,并且不再公开 authorization server 元数据端点。
由索引模型根据 Issue 内容生成。
评估
- 技术栈
- typescript
- 领域
- api, authentication
- Issue 类型
- 缺陷
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 活跃度
- 停滞
- 描述清晰度
- 描述清楚
- 新手友好度
- 38/100