Repository navigation
Accept names under localhost for the URLs Protected Resource Metadata publishes - #683
Open
koic wants to merge 1 commit into
Conversation
…ta publishes ## Motivation and Context `ProtectedResourceMetadata` refused a plain-http `resource` or `authorization_servers` entry unless its host was `localhost` or a loopback address, so a server that gives each tenant a subdomain could not be run in development as `http://acme.localhost:3000/mcp`: neither the metadata document nor the `401` challenge could be built. Every name under `localhost` is reserved for loopback and cannot be registered (RFC 6761 Section 6.3). These two members are values the server publishes and compares with a token's audience and issuer; it never connects to them. They now accept plain `http` on such a name, through a predicate of their own in `ProtectedResourceMetadata`. `Discovery.secure_url?` is unchanged, and with it every URL that is connected to: `jwks_uri:` and `introspection_endpoint:` on the server, and everything in the client. A resolver is not bound to answer a name under `localhost` with the loopback address, so plain `http` to one stays refused there. A server reached under such a name lists it in the `allowed_hosts:` of the transport, and `MCP::Client::HTTP` with `oauth:` does not connect to it over plain `http`. Resolves modelcontextprotocol#677. ## How Has This Been Tested? `test/mcp/server/oauth/protected_resource_metadata_test.rb`, `jwt_verifier_test.rb` and `introspection_verifier_test.rb`; the test that builds the metadata for `http://acme.localhost:3000/mcp` fails on the previous library. ## Breaking Changes None.
atesgoral
approved these changes
Nov 13, 2026
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation and Context
ProtectedResourceMetadatarefused a plain-httpresourceorauthorization_serversentry unless its host waslocalhostor a loopback address, so a server that gives each tenant a subdomain could not be run in development ashttp://acme.localhost:3000/mcp: neither the metadata document nor the401challenge could be built.Every name under
localhostis reserved for loopback and cannot be registered (RFC 6761 Section 6.3). These two members are values the server publishes and compares with a token's audience and issuer; it never connects to them. They now accept plainhttpon such a name, through a predicate of their own inProtectedResourceMetadata.Discovery.secure_url?is unchanged, and with it every URL that is connected to:jwks_uri:andintrospection_endpoint:on the server, and everything in the client. A resolver is not bound to answer a name underlocalhostwith the loopback address, so plainhttpto one stays refused there. A server reached under such a name lists it in theallowed_hosts:of the transport, andMCP::Client::HTTPwithoauth:does not connect to it over plainhttp.Resolves #677.
How Has This Been Tested?
test/mcp/server/oauth/protected_resource_metadata_test.rb,jwt_verifier_test.rbandintrospection_verifier_test.rb; the test that builds the metadata forhttp://acme.localhost:3000/mcpfails on the previous library.Breaking Changes
None.
Types of changes
Checklist