* Add initial support for Resource Templates * Make ListResourceTemplatesHandler not required The server was throwing if this handler wasn't specified, and it should probably be optional anyway. * Remove extra line Co-authored-by: Stephen Toub <stoub@microsoft.com> * Fix spaces Co-authored-by: Stephen Toub <stoub@microsoft.com> * Fix spaces Co-authored-by: Stephen Toub <stoub@microsoft.com> * Add and use a default ListResourceTemplatesHandler If no ListResourceTemplatesHandler is specified, use a default one that returns an empty result. * Fix spaces * Spaces * Add Client extensions for ListResourceTemplates * Integration Test for Client ListResourceTemplates * Fix comment Co-authored-by: Stephen Toub <stoub@microsoft.com> * Make Defaults internal Co-authored-by: Stephen Toub <stoub@microsoft.com> * Simplify test call Co-authored-by: Stephen Toub <stoub@microsoft.com> * Make delegate static Co-authored-by: Stephen Toub <stoub@microsoft.com> * Fix test comment * Spaces * Fix xml doc Co-authored-by: Stephen Toub <stoub@microsoft.com> * Make default handler inline * Spaces Co-authored-by: Stephen Halter <halter73@gmail.com> --------- Co-authored-by: Stephen Toub <stoub@microsoft.com> Co-authored-by: Stephen Halter <halter73@gmail.com>
46 lines
2.2 KiB
C#
46 lines
2.2 KiB
C#
using ModelContextProtocol.Protocol.Types;
|
|
using ModelContextProtocol.Server;
|
|
|
|
namespace ModelContextProtocol.Tests.Server;
|
|
|
|
public class McpServerHandlerTests
|
|
{
|
|
[Fact]
|
|
public void AllPropertiesAreSettable()
|
|
{
|
|
var handlers = new McpServerHandlers();
|
|
|
|
Assert.Null(handlers.ListToolsHandler);
|
|
Assert.Null(handlers.CallToolHandler);
|
|
Assert.Null(handlers.ListPromptsHandler);
|
|
Assert.Null(handlers.GetPromptHandler);
|
|
Assert.Null(handlers.ListResourceTemplatesHandler);
|
|
Assert.Null(handlers.ListResourcesHandler);
|
|
Assert.Null(handlers.ReadResourceHandler);
|
|
Assert.Null(handlers.GetCompletionHandler);
|
|
Assert.Null(handlers.SubscribeToResourcesHandler);
|
|
Assert.Null(handlers.UnsubscribeFromResourcesHandler);
|
|
|
|
handlers.ListToolsHandler = (p, c) => Task.FromResult(new ListToolsResult());
|
|
handlers.CallToolHandler = (p, c) => Task.FromResult(new CallToolResponse());
|
|
handlers.ListPromptsHandler = (p, c) => Task.FromResult(new ListPromptsResult());
|
|
handlers.GetPromptHandler = (p, c) => Task.FromResult(new GetPromptResult());
|
|
handlers.ListResourceTemplatesHandler = (p, c) => Task.FromResult(new ListResourceTemplatesResult());
|
|
handlers.ListResourcesHandler = (p, c) => Task.FromResult(new ListResourcesResult());
|
|
handlers.ReadResourceHandler = (p, c) => Task.FromResult(new ReadResourceResult());
|
|
handlers.GetCompletionHandler = (p, c) => Task.FromResult(new CompleteResult());
|
|
handlers.SubscribeToResourcesHandler = (s, c) => Task.FromResult(new EmptyResult());
|
|
handlers.UnsubscribeFromResourcesHandler = (s, c) => Task.FromResult(new EmptyResult());
|
|
|
|
Assert.NotNull(handlers.ListToolsHandler);
|
|
Assert.NotNull(handlers.CallToolHandler);
|
|
Assert.NotNull(handlers.ListPromptsHandler);
|
|
Assert.NotNull(handlers.GetPromptHandler);
|
|
Assert.NotNull(handlers.ListResourceTemplatesHandler);
|
|
Assert.NotNull(handlers.ListResourcesHandler);
|
|
Assert.NotNull(handlers.ReadResourceHandler);
|
|
Assert.NotNull(handlers.GetCompletionHandler);
|
|
Assert.NotNull(handlers.SubscribeToResourcesHandler);
|
|
Assert.NotNull(handlers.UnsubscribeFromResourcesHandler);
|
|
}
|
|
}
|