mcp-server: protected-resource metadata `resource` should be the /mcp URL

Đang mở
#5,309 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 2 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
56/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
api, authentication

Hướng nghiên cứu

Start with the protected resource metadata route in packages/mcp-server/src/server.ts, then read src/oauth/metadata.ts and src/oauth/challenge.ts to trace the metadata URL and 401 pointer. Update the metadata and challenge behavior, then run the metadata, handler, and MCP end to end tests listed in the issue. Done means both metadata paths return the /mcp resource, the challenge points to the path-suffixed URL, docs are resolved, and a patch changeset is added; deployed client sign-in also needs verification.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug

Problem

The MCP server's protected-resource metadata (RFC 9728) names the bare origin as the resource, while clients connect to the /mcp endpoint:

$ curl https://mcp.accounter.tax/.well-known/oauth-protected-resource
{"resource":"https://mcp.accounter.tax","authorization_servers":["https://dev-cnaunfqjwhwwd8ld.us.auth0.com/"],"bearer_methods_supported":["header"]}

The connector URL users enter is https://mcp.accounter.tax/mcp. Claude's connector docs require the metadata resource to match the connector URL, path included, and RFC 9728 §3.3 has clients reject a metadata document whose resource doesn't match the resource they requested. Claude Desktop currently tolerates the mismatch, but that's not something to rely on, especially once the connector moves to CIMD (#4616) and a directory listing.

Where

  • packages/mcp-server/src/server.ts: the PROTECTED_RESOURCE_METADATA_PATH route passes env.server.publicBaseUrl as resource.
  • packages/mcp-server/src/config/env.ts: publicBaseUrl is MCP_PUBLIC_BASE_URL with the trailing slash stripped (an origin, by convention).
  • packages/mcp-server/src/oauth/metadata.ts: buildProtectedResourceMetadata, protectedResourceMetadataUrl.
  • The 401 challenge's resource_metadata pointer (src/oauth/challenge.ts) points at /.well-known/oauth-protected-resource.

What to decide while fixing it

  • Resource value: build resource as ${publicBaseUrl}${MCP_ROUTE_PATH}, keeping MCP_PUBLIC_BASE_URL an origin (no env change in deploys).
  • Metadata location: RFC 9728 puts the metadata for a resource with a path at /.well-known/oauth-protected-resource/mcp (that returns 404 today). Serve it there and point the WWW-Authenticate resource_metadata at it. Keep the root path serving the same document for clients that probe the origin.
  • Audience: token verification is unaffected. Auth0 tokens carry aud: https://api.accounter.com, not the resource URL. Gap 3 in docs/connector-gaps-and-decisions.md covers audience binding separately.

Done when

  • GET /.well-known/oauth-protected-resource/mcp returns resource: <base>/mcp; the root well-known path returns the same document.
  • The 401 challenge's resource_metadata points at the path-suffixed URL.
  • Unit tests (src/oauth/__tests__/metadata.test.ts, src/mcp/__tests__/handler.test.ts) and src/__tests__/mcp-e2e.test.ts updated.
  • After deploy, Claude Desktop (custom connector, own OAuth client) and Cursor still connect and complete sign-in.
  • The PRM note under B1 in packages/mcp-server/docs/todo.md and the gap 3 update in connector-gaps-and-decisions.md are marked resolved.
  • Changeset for @accounter/mcp-server (patch).

Related: #4616.

🤖 Generated with Claude Code

Ngôn ngữ chính
TypeScript
Star
30
Fork
10
Merge trung bình
2 ngày 12 giờ
Pull request đã merge (30 ngày)
276

Chuẩn bị môi trường

Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của Urigo/accounter-fullstack

Tất cả issue của Urigo/accounter-fullstack

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.