modelcontextprotocol / modelcontextprotocol/csharp-sdk

SseClientTransportOptions.Endpoint needs a way for a consumer to control if the corresponding Resource ends with a trailing slash or not

Open
#757 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement needs confirmation
Dominant language
C#
Stars
4.5k
Forks
814
Avg merge
9d 19h
Merged PRs (30d)
4

Description

Is your feature request related to a problem? Please describe.
When creating an MCP client that connects to an OAuth-secured MCP server, the "Endpoint" may have different conventions regarding whether or not it ends with a trailing slash. SseClientTransportOptions.Endpoint being a URI makes this increasingly problematic, as the default behavior appends a trailing slash, even if the input string doesn't contain it:

var urlRawString = "https://example.com";
var uri = new Uri(urlRawString);
		
Console.WriteLine(urlRawString); // https://example.com
Console.WriteLine(uri.ToString()); // https://example.com/

Per spec, this is even in violation of their recommendation of whether or not to include the trailing slash:

Note: While both https://mcp.example.com/ (with trailing slash) and https://mcp.example.com (without trailing slash) are technically valid absolute URIs according to RFC 3986, implementations SHOULD consistently use the form without the trailing slash for better interoperability unless the trailing slash is semantically significant for the specific resource.

Describe the solution you'd like
I'd like for SseClientTransportOptions.Endpoint to be a string, and the internals can validate that it is a URI

Describe alternatives you've considered
If SseClientTransportOptions.Endpoint being Uri is strictly necessary, than a callback to format the resource prior to constructing the authorization url may be helpful. Or some option to eab This is probably more problematic, though, as it would allow implementers to violate the spec more easily.

Additional context
To work around the issue, I have had to do the following when writing an MCP client:

  1. Set ClientOAuthOptions.AuthorizationRedirectDelegate
  2. Override the resource query parameter of the authorization url with the trailing slash removed

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 by locating SseClientTransportOptions.Endpoint and the authorization URL construction described in the issue. Inspect existing tests around SSE transport and OAuth resource parameters. Done means consumers can control the endpoint's trailing-slash form and the generated authorization resource matches it consistently.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp
Domain
authentication
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.