pub struct McpRequestContext<Counterpart: Role> { /* private fields */ }unstable_mcp_over_acp only.Expand description
Authority for a single operation, not for the lifetime of its service.
Implementations§
Source§impl<Counterpart: Role> McpRequestContext<Counterpart>
impl<Counterpart: Role> McpRequestContext<Counterpart>
Sourcepub fn server_id(&self) -> &McpServerAcpId
pub fn server_id(&self) -> &McpServerAcpId
Server identifier bound to this invocation.
Sourcepub fn request_id(&self) -> &McpRequestId
pub fn request_id(&self) -> &McpRequestId
Logical request identifier, held until cleanup and terminal output finish.
Sourcepub fn session_id(&self) -> Option<&SessionId>
pub fn session_id(&self) -> Option<&SessionId>
The session the Agent says this request was sent for.
Returns None for a standalone MCP connection, and when the Agent
supplied no session. For a child session’s work this is the child’s ID.
The SDK does not check the value. Before you use it to choose what a request acts on, check that the session is active on the connection, or is a child that the Agent announced for an active session, and that this server was declared to it or to one of its ancestors.
Sourcepub fn tool_call_id(&self) -> Option<&ToolCallId>
pub fn tool_call_id(&self) -> Option<&ToolCallId>
The tool call, in the session returned by session_id, that the Agent
says this request is part of.
Returns None for a standalone MCP connection, and when the Agent
supplied no tool call. The Agent can report the tool call after it
sends the request, so the ID might not be known yet.
Sourcepub fn connection(&self) -> &McpConnectionTo<Counterpart>
pub fn connection(&self) -> &McpConnectionTo<Counterpart>
Host connection for application tools.
Sourcepub fn metadata(&self) -> &Map<String, Value>
pub fn metadata(&self) -> &Map<String, Value>
Validated protocol version and client capability metadata.
Sourcepub fn cancellation(&self) -> &RequestCancellation
pub fn cancellation(&self) -> &RequestCancellation
Cancellation of the outer ACP request.
Sourcepub fn operation_cancellation(&self) -> &McpOperationCancellation
pub fn operation_cancellation(&self) -> &McpOperationCancellation
Cancellation including provider removal and transport EOF.
Sourcepub async fn send_notification(
&self,
method: impl Into<String>,
params: Option<Map<String, Value>>,
) -> Result<(), Error>
pub async fn send_notification( &self, method: impl Into<String>, params: Option<Map<String, Value>>, ) -> Result<(), Error>
Send an operation-scoped notification while this invocation is live.
§Errors
Returns Request cancelled (-32800) if the operation has finished
or was cancelled. Otherwise propagates any failure to send the notification.