pub struct McpClient { /* private fields */ }Expand description
A client connection to a single MCP server.
Implementations§
Source§impl McpClient
impl McpClient
Sourcepub async fn spawn(
server_name: String,
command: &str,
args: &[String],
env: &HashMap<String, String>,
) -> PunchResult<Self>
pub async fn spawn( server_name: String, command: &str, args: &[String], env: &HashMap<String, String>, ) -> PunchResult<Self>
Spawn an MCP server subprocess and prepare the client.
Does NOT send the initialize request yet – call [initialize] after.
Sourcepub async fn initialize(&self) -> PunchResult<()>
pub async fn initialize(&self) -> PunchResult<()>
Send the JSON-RPC initialize handshake to the MCP server.
Sourcepub async fn list_tools(&self) -> PunchResult<Vec<ToolDefinition>>
pub async fn list_tools(&self) -> PunchResult<Vec<ToolDefinition>>
Discover tools exposed by this MCP server.
Tool names are namespaced as mcp_{server_name}_{tool_name}.
Sourcepub async fn call_tool(&self, name: &str, input: Value) -> PunchResult<Value>
pub async fn call_tool(&self, name: &str, input: Value) -> PunchResult<Value>
Call a tool on the MCP server.
The name should be the raw tool name (without the mcp_ prefix).
Sourcepub async fn shutdown(&self) -> PunchResult<()>
pub async fn shutdown(&self) -> PunchResult<()>
Shut down the MCP server process gracefully.
Sourcepub fn strip_namespace<'a>(&self, namespaced_name: &'a str) -> Option<&'a str>
pub fn strip_namespace<'a>(&self, namespaced_name: &'a str) -> Option<&'a str>
Extract the raw tool name from a namespaced MCP tool name.
E.g., mcp_github_create_issue with server_name github returns create_issue.
Sourcepub fn server_name(&self) -> &str
pub fn server_name(&self) -> &str
The server name used for namespacing.
Auto Trait Implementations§
impl !Freeze for McpClient
impl !RefUnwindSafe for McpClient
impl Send for McpClient
impl Sync for McpClient
impl Unpin for McpClient
impl UnsafeUnpin for McpClient
impl !UnwindSafe for McpClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more