-
Notifications
You must be signed in to change notification settings - Fork 485
Open
Description
Describe the bug
When defining a custom tools .WithListToolsHandler(SOME_FUNCTION), it doesn't fully override the tool handler
To Reproduce
builder.Services
.AddMcpServer()
.WithListToolsHandler((context, cancellationToken) =>
{
var result = new ListToolsResult();
return ValueTask.FromResult(result);
})
.WithStdioServerTransport()
.WithTools<MyTool>()
When calling the tools/list method MyTool will still be listed
Expected behavior
Just the result from the WithListToolsHandler (empty list) should be returned
Additional context
From McpServer.cs
var originalListToolsHandler = listToolsHandler;
listToolsHandler = async (request, cancellationToken) =>
{
ListToolsResult result = originalListToolsHandler is not null ?
await originalListToolsHandler(request, cancellationToken).ConfigureAwait(false) :
new();
if (request.Params?.Cursor is null)
{
foreach (var t in tools)
{
result.Tools.Add(t.ProtocolTool);
}
}
return result;
};
It feels like there should be a default list tool handler that just returns the list of tools, and it gets replaced by the listToolsHandler specified in options if it is not null. Let me know if I'm not understanding how it is supposed to be working.
Metadata
Metadata
Assignees
Labels
No labels