Skip to main content

Module mcp_tool_loop

Module mcp_tool_loop 

Source
Expand description

Principal-gated MCP tool loop (U3-A / U3-B).

Talk and agent UIs never invoke local MCP tools without an explicit principal Permit. Deny never reaches the MCP surface.

Flow: propose → Permit / Deny → execute (if Permit + allowlist) → result.

Allowlist source of truth: crate::agent_registry::AgentDefinition::allowed_mcp_tools.

  • Empty list → deny-all for tools
  • "*" → all tools (use sparingly; prefer explicit names)
  • otherwise exact tool name match via AgentDefinition::has_tool

In-process dispatch uses qualia_core_db::mcp::mcp_server::handle_jsonrpc_message — no second LLM HTTP API, no external agent SDK.

Structs§

McpToolInfo
One entry from the local MCP tools/list surface.

Enums§

GateDecision
Outcome of the principal + allowlist gate (no MCP call).

Constants§

SAFE_SEED_TOOLS
Safe golden tools for dogfood (empty args or {"op":"list"}).

Functions§

agent_set_allowed_mcp_tools
Set allowed_mcp_tools on an existing roster agent and persist.
dispatch_mcp_tool_call
Dispatch one MCP tools/call in-process. Caller must already have passed the principal + allowlist gate. Prefer mcp_call_tool_gated_for_agent.
ensure_safe_tool_allowlist
If the agent’s allowlist is empty, seed the safe golden tools and persist. Returns the (possibly updated) allowlist. Does not auto-Permit any call.
evaluate_tool_gate
Pure gate: principal flag + allowlist membership. Unit-testable without APP_STATE or MCP.
mcp_call_tool_gated
Load agent from roster, gate, then dispatch. Empty slug resolves to "local".
mcp_call_tool_gated_for_agent
Gate + optional dispatch for a concrete AgentDefinition (testable without storage).
mcp_list_local_tools
List local in-process MCP tools via JSON-RPC tools/list.