Restructure IMcpEndpoint, IMcpClient, and IMcpServer (#723)
* Remove `McpEndpoint` & `IMcpClient` * Revise naming, add abstract classes * Fix missing renames * Move extension methods to instance methods * Add back old API, but obsoleted * Add back obsoleted factory classes * Move deprecation attributes * `SseClientTransport` -> `HttpClientTransport` * Update src/ModelContextProtocol.Core/Server/AugmentedServiceProvider.cs Co-authored-by: Stephen Halter <halter73@gmail.com> * PR feedback * PR feedback * Add back dispose lock * Fix docs projects * PR feedback * Undo `docs/*.md` changes --------- Co-authored-by: Stephen Halter <halter73@gmail.com>
This commit is contained in:
parent
fe2ce2bc60
commit
38b4a26998
1 changed files with 5169 additions and 3786 deletions
|
|
@ -23,21 +23,21 @@ public abstract class MapMcpTests(ITestOutputHelper testOutputHelper) : KestrelI
|
|||
options.Stateless = Stateless;
|
||||
}
|
||||
|
||||
protected async Task<IMcpClient> ConnectAsync(
|
||||
protected async Task<McpClient> ConnectAsync(
|
||||
string? path = null,
|
||||
SseClientTransportOptions? transportOptions = null,
|
||||
HttpClientTransportOptions? transportOptions = null,
|
||||
McpClientOptions? clientOptions = null)
|
||||
{
|
||||
// Default behavior when no options are provided
|
||||
path ??= UseStreamableHttp ? "/" : "/sse";
|
||||
|
||||
await using var transport = new SseClientTransport(transportOptions ?? new SseClientTransportOptions
|
||||
await using var transport = new HttpClientTransport(transportOptions ?? new HttpClientTransportOptions
|
||||
{
|
||||
Endpoint = new Uri($"http://localhost:5000{path}"),
|
||||
TransportMode = UseStreamableHttp ? HttpTransportMode.StreamableHttp : HttpTransportMode.Sse,
|
||||
}, HttpClient, LoggerFactory);
|
||||
|
||||
return await McpClientFactory.CreateAsync(transport, clientOptions, LoggerFactory, TestContext.Current.CancellationToken);
|
||||
return await McpClient.CreateAsync(transport, clientOptions, LoggerFactory, TestContext.Current.CancellationToken);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -244,7 +244,7 @@ public abstract class MapMcpTests(ITestOutputHelper testOutputHelper) : KestrelI
|
|||
private class SamplingRegressionTools
|
||||
{
|
||||
[McpServerTool(Name = "sampling-tool")]
|
||||
public static async Task<string> SamplingToolAsync(IMcpServer server, string prompt, CancellationToken cancellationToken)
|
||||
public static async Task<string> SamplingToolAsync(McpServer server, string prompt, CancellationToken cancellationToken)
|
||||
{
|
||||
// This tool reproduces the scenario described in https://github.com/modelcontextprotocol/csharp-sdk/issues/464
|
||||
// 1. The client calls tool with request ID 2, because it's the first request after the initialize request.
|
||||
|
|
|
|||
Loading…
Reference in a new issue