* 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>
58 lines
1.8 KiB
C#
58 lines
1.8 KiB
C#
using Microsoft.Extensions.DependencyInjection;
|
|
using ModelContextProtocol.Protocol;
|
|
using ModelContextProtocol.Server;
|
|
using System.Runtime.InteropServices;
|
|
|
|
namespace ModelContextProtocol.Tests.Server;
|
|
|
|
public class McpServerLoggingLevelTests
|
|
{
|
|
public McpServerLoggingLevelTests()
|
|
{
|
|
#if !NET
|
|
Assert.SkipWhen(RuntimeInformation.IsOSPlatform(OSPlatform.Windows), "https://github.com/modelcontextprotocol/csharp-sdk/issues/587");
|
|
#endif
|
|
}
|
|
|
|
[Fact]
|
|
public void CanCreateServerWithLoggingLevelHandler()
|
|
{
|
|
var services = new ServiceCollection();
|
|
|
|
services.AddMcpServer()
|
|
.WithStdioServerTransport()
|
|
.WithSetLoggingLevelHandler(async (ctx, ct) => new EmptyResult());
|
|
|
|
var provider = services.BuildServiceProvider();
|
|
|
|
provider.GetRequiredService<McpServer>();
|
|
}
|
|
|
|
[Fact]
|
|
public void AddingLoggingLevelHandlerSetsLoggingCapability()
|
|
{
|
|
var services = new ServiceCollection();
|
|
|
|
services.AddMcpServer()
|
|
.WithStdioServerTransport()
|
|
.WithSetLoggingLevelHandler(async (ctx, ct) => new EmptyResult());
|
|
|
|
var provider = services.BuildServiceProvider();
|
|
|
|
var server = provider.GetRequiredService<McpServer>();
|
|
|
|
Assert.NotNull(server.ServerOptions.Capabilities?.Logging);
|
|
Assert.NotNull(server.ServerOptions.Capabilities.Logging.SetLoggingLevelHandler);
|
|
}
|
|
|
|
[Fact]
|
|
public void ServerWithoutCallingLoggingLevelHandlerDoesNotSetLoggingCapability()
|
|
{
|
|
var services = new ServiceCollection();
|
|
services.AddMcpServer()
|
|
.WithStdioServerTransport();
|
|
var provider = services.BuildServiceProvider();
|
|
var server = provider.GetRequiredService<McpServer>();
|
|
Assert.Null(server.ServerOptions.Capabilities?.Logging);
|
|
}
|
|
}
|