Remove McpServerConfig and have McpClientFactory accept IClientTransport instances directly. (#230)
* Remove McpServerConfig and have McpClientFactory accept IClientTransport instances directly. * Address feedback and use lists when representing stdio arguments. * Use "Name" for transport descriptors and "EndpointName" for MCP clients and servers. * Update code samples. * Fix source file naming
This commit is contained in:
parent
8bd9ee81c0
commit
3e21f3594a
1 changed files with 315 additions and 527 deletions
|
|
@ -18,13 +18,10 @@ public class SseServerIntegrationTestFixture : IAsyncDisposable
|
|||
// multiple tests, so this dispatches the output to the current test.
|
||||
private readonly DelegatingTestOutputHelper _delegatingTestOutputHelper = new();
|
||||
|
||||
private McpServerConfig DefaultServerConfig { get; } = new McpServerConfig
|
||||
private SseClientTransportOptions DefaultTransportOptions { get; } = new()
|
||||
{
|
||||
Id = "test_server",
|
||||
Endpoint = new Uri("http://localhost/sse"),
|
||||
Name = "TestServer",
|
||||
TransportType = TransportTypes.Sse,
|
||||
TransportOptions = [],
|
||||
Location = $"http://localhost/sse"
|
||||
};
|
||||
|
||||
public SseServerIntegrationTestFixture()
|
||||
|
|
@ -40,7 +37,7 @@ public class SseServerIntegrationTestFixture : IAsyncDisposable
|
|||
|
||||
HttpClient = new HttpClient(socketsHttpHandler)
|
||||
{
|
||||
BaseAddress = new Uri(DefaultServerConfig.Location),
|
||||
BaseAddress = DefaultTransportOptions.Endpoint,
|
||||
};
|
||||
_serverTask = Program.MainAsync([], new XunitLoggerProvider(_delegatingTestOutputHelper), _inMemoryTransport, _stopCts.Token);
|
||||
}
|
||||
|
|
@ -50,9 +47,8 @@ public class SseServerIntegrationTestFixture : IAsyncDisposable
|
|||
public Task<IMcpClient> ConnectMcpClientAsync(McpClientOptions? options, ILoggerFactory loggerFactory)
|
||||
{
|
||||
return McpClientFactory.CreateAsync(
|
||||
DefaultServerConfig,
|
||||
new SseClientTransport(DefaultTransportOptions, HttpClient, loggerFactory),
|
||||
options,
|
||||
(_, _) => new SseClientTransport(new(), DefaultServerConfig, HttpClient, loggerFactory),
|
||||
loggerFactory,
|
||||
TestContext.Current.CancellationToken);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue