Class DelegatingMcpServerPrompt
- Namespace
- ModelContextProtocol.Server
- Assembly
- ModelContextProtocol.dll
Provides an McpServerPrompt that delegates all operations to an inner McpServerPrompt.
public abstract class DelegatingMcpServerPrompt : McpServerPrompt, IMcpServerPrimitive
- Inheritance
-
DelegatingMcpServerPrompt
- Implements
- Inherited Members
Remarks
This is recommended as a base type when building prompts that can be chained around an underlying McpServerPrompt. The default implementation simply passes each call to the inner prompt instance.
Constructors
DelegatingMcpServerPrompt(McpServerPrompt)
Initializes a new instance of the DelegatingMcpServerPrompt class around the specified innerPrompt
.
protected DelegatingMcpServerPrompt(McpServerPrompt innerPrompt)
Parameters
innerPrompt
McpServerPromptThe inner prompt wrapped by this delegating prompt.
Properties
ProtocolPrompt
Gets the protocol Prompt type for this instance.
public override Prompt ProtocolPrompt { get; }
Property Value
Remarks
The ProtocolPrompt property represents the underlying prompt definition as defined in the Model Context Protocol specification. It contains metadata like the prompt's name, description, and acceptable arguments.
Methods
GetAsync(RequestContext<GetPromptRequestParams>, CancellationToken)
Gets the prompt, rendering it with the provided request parameters and returning the prompt result.
public override ValueTask<GetPromptResult> GetAsync(RequestContext<GetPromptRequestParams> request, CancellationToken cancellationToken = default)
Parameters
request
RequestContext<GetPromptRequestParams>The request context containing information about the prompt invocation, including any arguments passed to the prompt. This object provides access to both the request parameters and the server context.
cancellationToken
CancellationTokenThe CancellationToken to monitor for cancellation requests. The default is None.
Returns
- ValueTask<GetPromptResult>
A Task representing the asynchronous operation, containing a GetPromptResult with the prompt content and messages.
Exceptions
- ArgumentNullException
request
is null.- InvalidOperationException
The prompt implementation returns null or an unsupported result type.
ToString()
Returns a string that represents the current object.
public override string ToString()
Returns
- string
A string that represents the current object.