X Tutup
Skip to content

fix: include "none" in token_endpoint_auth_methods_supported metadata#2261

Open
namabile wants to merge 1 commit intomodelcontextprotocol:v1.xfrom
namabile:fix/token-endpoint-auth-methods-none
Open

fix: include "none" in token_endpoint_auth_methods_supported metadata#2261
namabile wants to merge 1 commit intomodelcontextprotocol:v1.xfrom
namabile:fix/token-endpoint-auth-methods-none

Conversation

@namabile
Copy link

@namabile namabile commented Mar 9, 2026

Summary

build_metadata() in mcp/server/auth/routes.py hardcodes token_endpoint_auth_methods_supported to ["client_secret_post", "client_secret_basic"], omitting "none". This breaks public client OAuth flows used by MCP clients like Claude Code and Cursor.

Spec References

  • MCP Authorization Spec (2025-06-18): "Authorization servers MUST implement OAuth 2.1 with appropriate security measures for both confidential and public clients." Best practices: "We strongly recommend that local clients implement OAuth 2.1 as a public client."
  • RFC 7591 Section 2: token_endpoint_auth_method: "none" — "The client is a public client as defined in OAuth 2.0, Section 2.1, and does not have a client secret."
  • RFC 8414 Section 2: token_endpoint_auth_methods_supported uses values from RFC 7591, which includes "none".
  • Official MCP example server: Uses token_endpoint_auth_methods_supported: ['none'] — the Python SDK is the outlier.

The Problem

The registration handler (register.py:54-60) already supports public clients — it skips client_secret generation when token_endpoint_auth_method: "none". But the metadata doesn't advertise this capability, so clients assume a secret is always required and fail during token exchange.

Changes:

  • Add "none" to token_endpoint_auth_methods_supported in build_metadata()
  • Add "none" to revocation_endpoint_auth_methods_supported for consistency
  • Update test assertions

Fixes #2260

Test plan

  • uv run pytest tests/client/test_auth.py::test_build_metadata — 2 passed, 1 xfailed
  • uv run pytest tests/server/fastmcp/auth/test_auth_integration.py — 40 passed
  • uv run ruff check — all checks passed
  • uv run ruff format --check — already formatted
  • Manual verification: MCP server metadata now advertises "none", allowing Claude Code to complete public client OAuth flow

The `build_metadata()` function hardcoded `token_endpoint_auth_methods_supported`
to `["client_secret_post", "client_secret_basic"]`, but the registration handler
already supports `token_endpoint_auth_method: "none"` for public clients.

MCP clients like Claude Code follow the metadata to determine supported auth
methods. Without "none" advertised, public client flows break: the client
registers successfully (no client_secret), but then cannot complete the token
exchange because the metadata implies a secret is required.

Also includes "none" in `revocation_endpoint_auth_methods_supported` for
consistency.

Fixes modelcontextprotocol#2260
@namabile namabile force-pushed the fix/token-endpoint-auth-methods-none branch from a78316c to 6839133 Compare March 9, 2026 20:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

X Tutup