The MCP integration sits on the visitor-facing hot path and reaches third-party servers. The security model below is the defence-in-depth applied at every layer.

SSRF protection

Credential isolation

Prompt-injection defence

Every tool result is wrapped in <tool-result trusted="false"> tags. The system prompt explicitly tells the LLM that anything inside such tags is data, not instructions, and not to follow links or commands found inside. Same pattern as the existing <source> RAG wrapping.

Output budget enforcement

Tool outputs are truncated to a per-tool token budget (default 1200) before being fed back to the LLM. A misbehaving server returning multi-megabyte responses is capped at 1MB by the transport layer; the token truncator caps oversized but legitimate responses.

Rate limit + circuit breaker

Tenancy

Servers, tools, grants, and call logs are scoped by workspace_id via the BelongsToWorkspace trait. The widget hot path resolves the agent from the signed JWT, then queries through the registry which never reads CurrentWorkspace directly. Cross-tenant attempts return 404 on admin routes (existence-leak-safe).