Skip to main content

Module mcp

Module mcp 

Source
Expand description

The MCP servers this run is configured with, loaded and live (#5428).

Why: before this, tcode could reach exactly one MCP server — the hard-coded search_code tool. Every other connector in the file trusty-agents already reads (~/.trusty-tools/mcp/servers.toml) was invisible here. What: McpToolSet::load resolves the global and project tiers, gates the untrusted project tier by content, spawns each enabled stdio server in isolation, and exposes each advertised tool as mcp__<server>__<tool>; register_configured_tools puts them in a ToolRegistry. Test: mcp::tests, crates/trusty-code/tests/mcp_loader_e2e.rs. Loading and running the MCP servers a tcode task run is configured with (#5428, slice 1).

Why: tcode could reach exactly one MCP server before this — search_code, which hard-codes trusty-search (crate::tools::trusty_search). Every other connector the operator configures in the file trusty-agents already reads (~/.trusty-tools/mcp/servers.toml, ADR-0060 decision 2) was invisible here. This module is the loader that closes that gap: shared config in, registered tools out.

What: McpToolSet::load is the whole lifecycle and runs ONCE per task run, before the agent loop — resolve the two tiers (config), gate the untrusted project tier (trust), spawn each enabled stdio server in isolation (spawn), and wrap each advertised tool as a ToolExecutor (tool). register_configured_tools is the cheap per-registry half, and is what the two registry-building sites call. The set is shared across every registry a run builds, so the servers are spawned once and the client handles stay alive exactly as long as a tool that can call them.

Every link above is spelled crate::mcp::… rather than module-relative: pub mod mcp; in lib.rs carries its own /// block, and rustdoc merges that with this //! one and resolves the whole thing in the CRATE ROOT’s scope, where a bare config or trust names nothing (#5428).

What this slice does NOT do: no catalog over the API or CLI (slice 2), and no remote transports — an http or sse entry is recognised and reported as not usable, never silently dropped.

Test: tests — the unit modules, which are #[cfg(test)] and so cannot be a link target in rustdoc’s public pass; crates/trusty-code/tests/mcp_loader_e2e.rs — spawn, register and dispatch against a real stdio MCP server.

Re-exports§

pub use config::McpIssue;
pub use config::McpTier;
pub use config::ProjectOverrides;
pub use config::ResolvedMcp;
pub use config::ServerStatus;
pub use tool::McpBridgeTool;
pub use tool::composed_name;

Modules§

config
The two configuration tiers a tcode run reads MCP servers from (#5428).
spawn
Spawning one configured MCP server, in isolation (#5428).
tool
One configured MCP server’s tool, as a ToolExecutor (#5428).
trust
The trust gate over the project tier (#5428).

Structs§

McpDiagnostics
What a run should say about its MCP configuration.
McpToolSet
Every MCP tool a task run can dispatch, plus why any server is missing.

Constants§

REMOTE_UNSUPPORTED
Why a recognised but unimplemented transport is not connected.

Functions§

register_configured_tools
Register every loaded MCP tool into registry.