Skip to main content

agent_client_protocol/mcp_server/
context.rs

1use crate::{ConnectionTo, role::Role};
2
3/// Context about the ACP and MCP connection available to an MCP server.
4#[derive(Clone, Debug)]
5pub struct McpConnectionTo<Counterpart: Role> {
6    pub(super) acp_id: String,
7    pub(super) connection: ConnectionTo<Counterpart>,
8}
9
10impl<Counterpart: Role> McpConnectionTo<Counterpart> {
11    /// The ACP identifier for this MCP server (e.g., `"acp:UUID"`).
12    pub fn acp_id(&self) -> String {
13        self.acp_id.clone()
14    }
15
16    /// The `acp:UUID` that was given.
17    #[deprecated(since = "0.12.0", note = "renamed to `acp_id()`")]
18    pub fn acp_url(&self) -> String {
19        self.acp_id()
20    }
21
22    /// The host connection context.
23    ///
24    /// If this MCP server is hosted inside of an ACP context, this will be the ACP connection context.
25    pub fn connection_to(&self) -> ConnectionTo<Counterpart> {
26        self.connection.clone()
27    }
28}