using Microsoft.Extensions.DependencyInjection; using ModelContextProtocol.Utils; namespace ModelContextProtocol.Server; /// /// Provides a context container that provides access to the client request parameters and resources for the request. /// /// Type of the request parameters specific to each MCP operation. /// /// The encapsulates all contextual information for handling an MCP request. /// This type is typically received as a parameter in handler delegates registered with , /// and may be injected as parameters into s. /// public sealed class RequestContext { /// The server with which this instance is associated. private IMcpServer _server; /// /// Initializes a new instance of the class with the specified server. /// /// The server with which this instance is associated. public RequestContext(IMcpServer server) { Throw.IfNull(server); _server = server; Services = server.Services; } /// Gets or sets the server with which this instance is associated. public IMcpServer Server { get => _server; set { Throw.IfNull(value); _server = value; } } /// Gets or sets the services associated with this request. /// /// This may not be the same instance stored in /// if was true, in which case this /// might be a scoped derived from the server's /// . /// public IServiceProvider? Services { get; set; } /// Gets or sets the parameters associated with this request. public TParams? Params { get; set; } }