pub struct McpServerHandle {
pub server: String,
/* private fields */
}Expand description
P5-2: one connected server, wrapping the Arc<Mutex<McpClient>> every
derived Tool/prompt-source shares — the single point that produces
tools (McpTool), resource tools, prompt names, and the server’s
folded-in instructions, so a caller (crates/cli’s attach_mcp) only
has to connect once and ask this handle for everything else.
Fields§
§server: StringThis server’s name (the mcp__<server>__… namespace prefix).
Implementations§
Source§impl McpServerHandle
impl McpServerHandle
Sourcepub fn new(server: impl Into<String>, client: McpClient) -> Self
pub fn new(server: impl Into<String>, client: McpClient) -> Self
Wrap an already-connected client under server’s name.
Sourcepub async fn instructions(&self) -> Option<String>
pub async fn instructions(&self) -> Option<String>
The server’s initialize-time instructions, if any.
Sourcepub async fn tools(&self) -> Result<Vec<McpTool>>
pub async fn tools(&self) -> Result<Vec<McpTool>>
This server’s tools, namespaced mcp__<server>__<tool>.
Sourcepub fn resource_tools(&self) -> Vec<Box<dyn Tool>>
pub fn resource_tools(&self) -> Vec<Box<dyn Tool>>
This server’s resource-access tools (resources_list/_read/
_subscribe), always offered regardless of whether the server
actually advertised a resources capability — a server that
doesn’t support resources simply errors clearly on the underlying
resources/list call (the same “let the remote error surface”
posture McpTool::execute already has for tools/call), rather
than this client trying to pre-negotiate capabilities perfectly.
Sourcepub async fn prompts(&self) -> Result<Vec<(String, McpPromptSource)>>
pub async fn prompts(&self) -> Result<Vec<(String, McpPromptSource)>>
This server’s prompts, namespaced mcp__<server>__<prompt> — see
McpPromptSource’s doc comment for why namespacing (not a bare
name) is the mechanism that keeps an untrusted/remote server from
ever being able to collide with a trusted command name.
Trait Implementations§
Source§impl Clone for McpServerHandle
impl Clone for McpServerHandle
Source§fn clone(&self) -> McpServerHandle
fn clone(&self) -> McpServerHandle
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more