Skip to main content

Crate agnt_mcp

Crate agnt_mcp 

Source
Expand description

§agnt-mcp

Minimal Model Context Protocol client for agnt.

v0.3 scope:

  • stdio transport only — spawns an MCP server as a child process and speaks line-delimited JSON-RPC 2.0 over its stdin/stdout.
  • Synchronous, one-shot request/response — a single in-flight request at a time, serialized through a std::sync::Mutex when shared across threads.
  • Tool discovery via tools/list, tool invocation via tools/call.
  • agnt_core::Tool bridge via McpTool, so discovered MCP tools slot directly into an agnt_core::Registry.

Protocol version targeted: 2024-11-05.

§Example

use agnt_mcp::{McpClient, McpTool};
use std::sync::{Arc, Mutex};

let mut client = McpClient::start("my-mcp-server", &["--flag"]).unwrap();
let infos = client.list_tools().unwrap();
let shared = Arc::new(Mutex::new(client));
let tools: Vec<McpTool> = infos
    .into_iter()
    .map(|info| McpTool::new(Arc::clone(&shared), info))
    .collect();

Structs§

McpClient
Synchronous MCP stdio client.
McpTool
An agnt_core::Tool implementation that routes calls to a specific tool on a shared McpClient.
McpToolInfo
Metadata for a tool exposed by an MCP server.

Enums§

McpError
Errors surfaced by McpClient operations.

Constants§

MAX_LINE_BYTES
Maximum bytes accepted on a single JSON-RPC line from an MCP server.
PROTOCOL_VERSION
Protocol version this client advertises in its initialize handshake.
REQUEST_TIMEOUT
Per-request timeout. Hard-coded for v0.3.