Class DelegatingMcpServerTool
- Namespace
- ModelContextProtocol.Server
- Assembly
- ModelContextProtocol.Core.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
innerToolMcpServerToolThe 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<CallToolResult> InvokeAsync(RequestContext<CallToolRequestParams> request, CancellationToken cancellationToken = default)
Parameters
requestRequestContext<CallToolRequestParams>The request information resulting in the invocation of this tool.
cancellationTokenCancellationTokenThe CancellationToken to monitor for cancellation requests. The default is None.
Returns
- ValueTask<CallToolResult>
The call response from invoking the tool.
Exceptions
- ArgumentNullException
requestis null.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.