modelcontextprotocol / modelcontextprotocol/csharp-sdk
When Absolute Uri passed as McpAuthenticationOptions.ResourceMetadataUri, /.well-known/oauth-protected-resource endpoint returns 404
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 4.5k
- Forks
- 814
- Avg merge
- 9d 19h
- Merged PRs (30d)
- 4
Description
Describe the bug
When Absolute Uri passed as McpAuthenticationOptions.ResourceMetadataUri, /.well-known/oauth-protected-resource endpoint returns 404.
The logic for matching resource metadata endpoint is only limited to relative path, when an absolute path is passed in, the match fails and allows the resource metadata request to fall through the pipeline.
To Reproduce
- Provide an absolute Uri as as
McpAuthenticationOptions.ResourceMetadataUriwhen configuringAddMcp - Start the server
- Hit the resource metadata endpoint
Reproduced in sample server, added
AddMcp(options =>
{
// ... resource metadata object
options.ResourceMetadataUri = new Uri($"{serverUrl}.well-known/oauth-protected-resource", UriKind.Absolute);
}
in samples\ProtectedMCPServer\Program.cs
Expected behavior
Resource metadata request should be handled when provided a valid ResourceMetadataUri
Unit tests failure when configure the absolute uri
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with samples\ProtectedMCPServer\Program.cs and reproduce the request using an absolute ResourceMetadataUri configured through AddMcp. Then locate the resource metadata endpoint matching logic and the unit tests referenced by the issue. Done means a valid absolute URI is handled by the /.well-known/oauth-protected-resource endpoint instead of returning 404, with the relevant tests passing.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api, authentication
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 55/100