Expand description
§graphrt-mcp
Exposes the tools of Model Context Protocol
servers to graphrt’s tool and agent nodes.
use graphrt_mcp::{McpServers, connect_all};
let servers: McpServers = serde_json::from_str(r#"{
"mcpServers": {
"fs": { "command": "npx", "args": ["-y", "@modelcontextprotocol/server-filesystem", "/data"] },
"remote": { "url": "https://mcp.example.com/mcp", "bearer_token": "..." }
}
}"#).unwrap_or_default();
let tools = connect_all(&servers.into_configs()).await?;
let services = graphrt_core::Services::new().with(tools);Each server is registered in the ToolRegistry under both <name> and
mcp:<name>, so a tool node can use provider_id: mcp:fs.
Security defaults: stdio servers start with an empty environment except for
a few launcher essentials (config::DEFAULT_PASS_ENV) plus explicitly
listed variables; every request has a timeout; allowed_tools restricts
which tools are exposed.
Re-exports§
pub use config::HttpConfig;pub use config::McpServerConfig;pub use config::McpServers;pub use config::McpTransport;pub use config::StdioConfig;pub use runtime::McpError;pub use runtime::McpToolRuntime;
Modules§
- config
- MCP server configuration.
- content
- Mapping between MCP wire types and graphrt tool types.
- runtime
McpToolRuntime: aToolRuntimebacked by one MCP server connection.
Constants§
- PROVIDER_
PREFIX - Prefix of the alias provider name for MCP servers.
Functions§
- connect_
all - Connect to every server concurrently and build a
ToolRegistry. Names are validated first; fails on the first server that cannot be connected. - register
- Register a connected server under
<name>andmcp:<name>, replacing any provider already registered under those names. Prefertry_register, which refuses to shadow an existing provider. - try_
register - Register a connected server under
<name>andmcp:<name>. Fails if either name is already taken, so a server can never silently replace another provider (for example one namedbuiltin). - validate_
configs - Check server names before connecting: non-empty, no
/(tools are referenced asprovider/tool), and unique.