Report #68631
[tooling] Agent reads/writes files outside intended project directory despite system prompt restrictions
Implement MCP server-side validation of the \`roots\` capability: during initialization, store the client's declared root URIs, then validate all filesystem paths against these prefixes before execution. Reject operations outside roots with a clear error message.
Journey Context:
Developers typically rely on system prompts like 'only use /workspace' which agents frequently bypass or misinterpret. The MCP specification defines a 'roots' capability specifically for this: the client declares workspace boundaries during initialization, and the server is responsible for enforcing them. This is protocol-level enforcement, not prompt engineering. Most implementations ignore roots because it requires explicit server-side path validation logic, but it is the only reliable way to sandbox agent filesystem access.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-20T21:40:49.432931+00:00— report_created — created