Expand description
MCP (Model Context Protocol) integration. MCP (Model Context Protocol) integration.
Provides a built-in mcp tool that acts as a gateway to MCP servers,
plus a per-tool direct-registration path (Phase 3) and a disk-backed
metadata cache (Phase 1) that lets search / list / describe
work without a live connection.
§Architecture
McpTool (AgentTool) ──┐
McpDirectTool (x N) ─┴─→ McpManager ─→ McpClient (per server, Transport-based)
│ ├── JSON-RPC over transport (stdio / http_sse)
│ ├── Metadata cache (disk-backed)
│ ├── Consent manager (disk-backed)
│ └── Lifecycle task (mpsc, owns idle/health timers)§Concurrency
McpManager is internally Arc<McpManager> after spawn(). The
lifecycle timer task receives a Weak<McpManager> so it never
participates in a reference cycle. The inner state is guarded by
tokio::sync::Mutex for write paths and parking_lot::RwLock for
cheap read paths (cache, consent).
§Config format
{
"mcpServers": {
"my-server": {
"command": "npx",
"args": ["-y", "@my-org/mcp-server"],
"lifecycle": "lazy",
"idleTimeout": 10,
"directTools": true
}
},
"settings": {
"toolPrefix": "server"
}
}Re-exports§
pub use auth::Credential;pub use auth::McpCredentialProvider;pub use auth::NoopCredentialProvider;pub use cache::MetadataCache;pub use client::McpClient;pub use client::McpLogLevel;pub use client::McpPrompt;pub use client::McpPromptArgument;pub use client::McpSamplingRequest;pub use consent::ConsentManager;pub use direct_tool::McpDirectTool;pub use error::McpError;pub use spawn::NoopSpawnValidator;pub use spawn::SpawnValidator;pub use tool::McpTool;pub use transport::McpTransport;pub use transport::http::StreamableHttpTransport;pub use transport::stdio::StdioTransport;pub use types::ConsentState;pub use types::DirectToolDef;pub use types::DirectToolsConfig;pub use types::LifecycleMode;pub use types::McpCallResult;pub use types::McpConfig;pub use types::McpConnectionStatus;pub use types::McpContent;pub use types::McpDashboardData;pub use types::McpServerInfo;pub use types::McpSettings;pub use types::McpSettingsView;pub use types::McpToolDef;pub use types::McpToolInfo;pub use types::ServerEntry;pub use types::ServerInfo;pub use types::ServerStatus;pub use types::ToolMetadata;pub use types::ToolPrefix;pub use types::effective_prefix_mode;pub use types::format_schema;pub use types::format_tool_name;pub use types::get_server_prefix;
Modules§
- auth
- MCP credential provider (v2.1).
- cache
- MCP tool metadata disk cache.
- client
- MCP JSON-RPC client.
- config
- MCP configuration loading.
- consent
- MCP consent management — two policies over one store.
- content
- MCP content transformation.
- direct_
tool - Direct MCP tool →
AgentToolbridge (Phase 3). - error
- Typed errors for MCP operations.
- lifecycle
- Channel-based MCP server lifecycle management.
- spawn
- MCP server spawn validation policy hook.
- tool
- MCP proxy tool.
- transport
- MCP transport layer abstraction.
- types
- Config format …
Structs§
- McpManager
- Central manager for all MCP server connections.
- McpManager
Inner - Inner mutable state for
McpManager.
Constants§
- DEFAULT_
FAILURE_ BACKOFF_ SECS - Default back-off period after a server connection failure (seconds).
- DEFAULT_
IDLE_ TIMEOUT_ MINS - Default global idle timeout (minutes).