modelcontextprotocol / modelcontextprotocol/csharp-sdk

When Absolute Uri passed as McpAuthenticationOptions.ResourceMetadataUri, /.well-known/oauth-protected-resource endpoint returns 404

Open
#654 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area-auth bug help wanted needs confirmation P3
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

  1. Provide an absolute Uri as as McpAuthenticationOptions.ResourceMetadataUri when configuring AddMcp
  2. Start the server
  3. 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

Image

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.