Skip to main content

build_mcp_config_from_refs

Function build_mcp_config_from_refs 

Source
pub fn build_mcp_config_from_refs(
    servers: &[McpServer],
    user_mcp_blob: Option<&str>,
    agent_slug: &str,
    agent_bus_id: &str,
) -> Option<String>
Expand description

Build .mcp.json from standalone McpServer ref rows (v1 composable model).

Layering (later wins on key collision, except the reserved agentmux key):

  1. synthetic agentmux entry (always injected)
  2. user_mcp_blob’s mcpServers — the legacy per-agent blob, merged when the caller passes it (used so a global-only ref set never wipes a legacy agent’s user servers)
  3. servers ref rows (the agent’s own bound servers + globals) For each ref row the config field is a JSON object used as the server value directly. Falls back to build_mcp_config when there are no ref rows and no blob.