Class DelegatingMcpServerTool
- Namespace
- ModelContextProtocol.Server
- Assembly
- ModelContextProtocol.dll
Provides an McpServerTool that delegates all operations to an inner McpServerTool.
public abstract class DelegatingMcpServerTool : McpServerTool, IMcpServerPrimitive
- Inheritance
-
DelegatingMcpServerTool
- Implements
- Inherited Members
Remarks
This is recommended as a base type when building tools that can be chained around an underlying McpServerTool. The default implementation simply passes each call to the inner tool instance.
Constructors
DelegatingMcpServerTool(McpServerTool)
Initializes a new instance of the DelegatingMcpServerTool class around the specified innerTool
.
protected DelegatingMcpServerTool(McpServerTool innerTool)
Parameters
innerTool
McpServerToolThe inner tool wrapped by this delegating tool.
Properties
ProtocolTool
Gets the protocol Tool type for this instance.
public override Tool ProtocolTool { get; }
Property Value
Methods
InvokeAsync(RequestContext<CallToolRequestParams>, CancellationToken)
Invokes the McpServerTool.
public override ValueTask<CallToolResponse> InvokeAsync(RequestContext<CallToolRequestParams> request, CancellationToken cancellationToken = default)
Parameters
request
RequestContext<CallToolRequestParams>The request information resulting in the invocation of this tool.
cancellationToken
CancellationTokenThe CancellationToken to monitor for cancellation requests. The default is None.
Returns
- ValueTask<CallToolResponse>
The call response from invoking the tool.
Exceptions
- ArgumentNullException
request
is null.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.