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::Mutexwhen shared across threads. - Tool discovery via
tools/list, tool invocation viatools/call. agnt_core::Toolbridge viaMcpTool, so discovered MCP tools slot directly into anagnt_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::Toolimplementation that routes calls to a specific tool on a sharedMcpClient. - McpTool
Info - Metadata for a tool exposed by an MCP server.
Enums§
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
initializehandshake. - REQUEST_
TIMEOUT - Per-request timeout. Hard-coded for v0.3.