Class RequestContext<TParams>
- Namespace
- ModelContextProtocol.Server
- Assembly
- ModelContextProtocol.Core.dll
Provides a context container that provides access to the client request parameters and resources for the request.
public sealed class RequestContext<TParams>
Type Parameters
TParams
Type of the request parameters specific to each MCP operation.
- Inheritance
-
RequestContext<TParams>
- Inherited Members
Remarks
The RequestContext<TParams> encapsulates all contextual information for handling an MCP request. This type is typically received as a parameter in handler delegates registered with IMcpServerBuilder, and may be injected as parameters into McpServerTools.
Constructors
RequestContext(IMcpServer)
Initializes a new instance of the RequestContext<TParams> class with the specified server.
public RequestContext(IMcpServer server)
Parameters
server
IMcpServerThe server with which this instance is associated.
Properties
Params
Gets or sets the parameters associated with this request.
public TParams? Params { get; set; }
Property Value
- TParams
Server
Gets or sets the server with which this instance is associated.
public IMcpServer Server { get; set; }
Property Value
Services
Gets or sets the services associated with this request.
public IServiceProvider? Services { get; set; }
Property Value
Remarks
This may not be the same instance stored in Services if ScopeRequests was true, in which case this might be a scoped IServiceProvider derived from the server's Services.