Class ToolsCapability
- Namespace
- ModelContextProtocol.Protocol
- Assembly
- ModelContextProtocol.Core.dll
Represents the tools capability configuration. See the schema for details.
public class ToolsCapability
- Inheritance
-
ToolsCapability
- Inherited Members
Properties
CallToolHandler
Gets or sets the handler for ToolsCall requests.
[JsonIgnore]
public Func<RequestContext<CallToolRequestParams>, CancellationToken, ValueTask<CallToolResponse>>? CallToolHandler { get; set; }
Property Value
Remarks
This handler is invoked when a client makes a call to a tool that isn't found in the ToolCollection. The handler should implement logic to execute the requested tool and return appropriate results. It receives a RequestContext<TParams> containing information about the tool being called and its arguments, and should return a CallToolResponse with the execution results.
ListChanged
Gets or sets whether this server supports notifications for changes to the tool list.
[JsonPropertyName("listChanged")]
public bool? ListChanged { get; set; }
Property Value
- bool?
Remarks
When set to true, the server will send notifications using ToolListChangedNotification when tools are added, removed, or modified. Clients can register handlers for these notifications to refresh their tool cache. This capability enables clients to stay synchronized with server-side changes to available tools.
ListToolsHandler
Gets or sets the handler for ToolsList requests.
[JsonIgnore]
public Func<RequestContext<ListToolsRequestParams>, CancellationToken, ValueTask<ListToolsResult>>? ListToolsHandler { get; set; }
Property Value
Remarks
The handler should return a list of available tools when requested by a client. It supports pagination through the cursor mechanism, where the client can make repeated calls with the cursor returned by the previous call to retrieve more tools. When used in conjunction with ToolCollection, both the tools from this handler and the tools from the collection will be combined to form the complete list of available tools.
ToolCollection
Gets or sets a collection of tools served by the server.
[JsonIgnore]
public McpServerPrimitiveCollection<McpServerTool>? ToolCollection { get; set; }
Property Value
Remarks
Tools will specified via ToolCollection augment the ListToolsHandler and CallToolHandler, if provided. ListTools requests will output information about every tool in ToolCollection and then also any tools output by ListToolsHandler, if it's non-null. CallTool requests will first check ToolCollection for the tool being requested, and if the tool is not found in the ToolCollection, any specified CallToolHandler will be invoked as a fallback.