读取 MCP 资源的 OAuth 元数据
查看 MCP 资源标识、认证服务器和受支持的 Bearer 传递方式。
GET
/.well-known/oauth-protected-resource/mcp请求参数
此操作无需提交参数。
请求示例
cURL
curl -i -X GET 'https://social2api.com/.well-known/oauth-protected-resource/mcp'Python
from urllib.error import HTTPError
from urllib.request import Request, urlopen
request = Request(
"https://social2api.com/.well-known/oauth-protected-resource/mcp",
method="GET",
)
send = urlopen
try:
with send(request) as response:
print(response.status, response.read().decode("utf-8"))
except HTTPError as error:
print(error.code, error.read().decode("utf-8"))JavaScript
const response = await fetch("/.well-known/oauth-protected-resource/mcp", {
method: "GET",
});
console.log(response.status, await response.text());响应
200 · 示例响应
{
"resource": "https://social2api.com/mcp",
"authorization_servers": [
"https://social2api.com"
],
"scopes_supported": [
"mcp:tools"
],
"bearer_methods_supported": [
"header"
]
}错误示例
{
"error": "invalid_request"
}| 字段 | 类型 | 说明 |
|---|---|---|
resource | URI | 此部署对应的 MCP 资源地址。 |
authorization_servers | URI[] | 授权服务器根地址列表。 |
scopes_supported | string[] | 服务可使用的授权范围。 |
bearer_methods_supported | string[] | 客户端通过请求头发送 Bearer 令牌。 |
错误状态
| HTTP | 原因与处理 |
|---|---|
405 | 请求方法不受支持。 |
500 | 授权服务暂时不可用。 |
使用细节
- MCP 认证失败的 WWW-Authenticate 响应头指向此地址。