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

Aperta
#757 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

enhancement needs confirmation
Lingua principale
C#
Stelle
4.5k
Fork
814
Merge medio
9g 19h
PR unite (30g)
4

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Direzione di ricerca

Inizia individuando SseClientTransportOptions.Endpoint e la costruzione dell’URL di autorizzazione descritta nell’issue. Esamina i test esistenti sul trasporto SSE e sui parametri della risorsa OAuth. Il lavoro è completato quando i consumer possono controllare la forma della barra finale dell’endpoint e la risorsa di autorizzazione generata corrisponde ad essa in modo coerente.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
csharp
Ambito
authentication
Tipo di issue
Funzionalità
Difficoltà
3/5
Tempo stimato
1-2 giorni
Stato di attività
Ferma
Chiarezza
Abbastanza chiara
Idoneità per principianti
35/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.