Skip to content

AuthSettings.issuer_url is required in resource-server-only mode but never used #3702

Open

Description

@AkshayShah03

Release line: 2.x (main @ 754254c)

Following up on #3283, where it was noted that token_verifier= shouldn't make you invent an authorization server. I didn't find an issue tracking that, so here's one.

What happens

For a server that only verifies bearer tokens (token_verifier=, no auth_server_provider, resource_server_url=None):

  • AuthSettings(resource_server_url=None) fails validation: issuer_url field required.
  • MCPServer(token_verifier=...) without auth= raises "Cannot specify auth_server_provider or token_verifier without auth settings".
  • With a placeholder such as issuer_url="https://placeholder.invalid", everything works: only /mcp is mounted, a missing token gets 401 and a valid one gets 200. The value is never read. It's only used when auth_server_provider is set (server.py:1218) or when the PRM document is served (server.py:1277).

Minor related point: resource_server_url is typed AnyHttpUrl | None but declared with Field(...), so None has to be passed explicitly.

What I expected

To configure a resource-server-only setup without a made-up URL.

Possible shape

  • issuer_url: AnyHttpUrl | None = None and resource_server_url: AnyHttpUrl | None = None.
  • Validate that issuer_url is set when resource_server_url is set, since the PRM authorization_servers needs an entry, and when auth_server_provider is used.
  • Existing configs behave the same. The only change is that the placeholder is no longer needed.

The alternative would be to allow token_verifier= without auth= at all, but that's a bigger change. Does the first shape fit, or would you prefer something different? I'm happy to implement whichever you prefer.

Repro script: https://gist.github.com/AkshayShah03/92d4d4eb6dcbbfa15c7f374e30e506a5

Investigation and repro done with AI assistance; I ran it and checked the output.

Activity

  1. added
    enhancementRequest for a new feature that's not currently supported
    on Oct 13, 2026
  2. lzif commented on Oct 14, 2026

    @lzif

    Verified on current main (754254c0, 2026-10-13):

    • AuthSettings(resource_server_url=None) raises ValidationError: 1 validation error for AuthSettings / issuer_url / Field required — reproduces exactly as described.
    • Audited all issuer_url read sites: src/mcp/server/lowlevel/server.py:803 (inside if auth_server_provider:), :839 (inside if auth and auth.resource_server_url:), src/mcp/server/mcpserver/server.py:1218 (inside if self._auth_server_provider:), :1277 (inside the resource_server_url branch). In resource-server-only mode (token_verifier set, no auth server provider, no resource_server_url) none of them execute — so the mandatory field is never read.

    The incremental fix shape from the issue (optional issuer_url/resource_server_url plus a validator requiring issuer_url only when resource_server_url is set or an auth server provider is used) matches this audit.

    Note: open PR #3292 takes the alternative, bigger approach (token verifier without AuthSettings at all) — flagging in case maintainers prefer it.

    Disclosure: this verification was AI-assisted (per this repo's CONTRIBUTING).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementRequest for a new feature that's not currently supported

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions