modelcontextprotocol / modelcontextprotocol/csharp-sdk
`SseClientTransport.Endpoint` should be nullable when `HttpClient` is provided
Nobody has claimed this yet.
- 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.
I'm looking at how to integrate with .NET Aspire, where I have an MCP server on HTTP and then I want to consume that from an application using McpClient.
Aspire allows me to pass through the endpoint using service discovery on the HttpClient, so I can have an endpoint like https+http://mcp, but this endpoint can't be set to SseClientTransport.Endpoint due to this validation on the setter: https://github.com/modelcontextprotocol/csharp-sdk/blob/1e8fb040377b9ac9ac94c97e4b1f1438170bc0ea/src/ModelContextProtocol.Core/Client/SseClientTransportOptions.cs#L24-L27
Describe the solution you'd like
I want to be able to provide a HttpClient instance to the SseClientTransport without also having to provide the endpoint, since the HttpClient has the endpoint known (and it's resolved via service discovery).
Describe alternatives you've considered
My only solution is that I have to manually configure the endpoint, which defeats some of the value of using .NET Aspire here.
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 in src/ModelContextProtocol.Core/Client/SseClientTransportOptions.cs, especially the setter linked in the issue, and trace how SseClientTransport uses HttpClient and Endpoint. Done means an HttpClient can provide the service-discovered endpoint without requiring a separate Endpoint value, while existing validation still behaves correctly; check the related tests if present.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- api
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 68/100