You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Code Mode destructive-tool gate fails open on unannotated tools (and errors on annotated ones with mcp >=2.0) #318
_is_destructive() in packages/trueforge-core/src/core/sandbox/scripts/mcp_client.py decides whether a tool is blocked from running in Code Mode (destructive tools are supposed to be pushed to the direct-call approval flow). It has two problems.
def_is_destructive(tool: Tool) ->bool:
annotations=tool.annotationsifannotationsisNone:
returnFalsereturnbool(annotations.destructiveHint) or (notannotations.readOnlyHintandannotations.readOnlyHintisnotNone)
1. Fails open on tools without annotations. Most MCP servers ship tools with no annotations at all. For those, this returns False, so a genuinely destructive tool runs in Code Mode without ever hitting the approval flow. The MCP spec defaults destructiveHint to true (destructive unless the server says otherwise), so absence of annotations should be treated as destructive, not safe. The function's second clause already tries to treat a non-read-only tool as destructive, but the annotations is None guard and the readOnlyHint is not None check short-circuit that for the unannotated case.
Repro:
frommcp.typesimportToolt=Tool(name="delete_file", inputSchema={"type": "object"}) # no annotationsassert_is_destructive(t) isFalse# runs in Code Mode with no approval
2. Raises AttributeError on annotated tools with mcp >=2.0. The code reads annotations.destructiveHint / annotations.readOnlyHint, but the mcp Python SDK renamed these fields to destructive_hint / read_only_hint in 2.0. Attribute access on the camelCase names raises, so any tool that declares annotations breaks the gate:
t=Tool.model_validate({"name": "delete_file", "inputSchema": {"type": "object"},
"annotations": {"destructiveHint": True, "readOnlyHint": False}})
_is_destructive(t) # AttributeError: 'ToolAnnotations' object has no attribute 'destructiveHint'
Expected: unannotated or unset-hint tools are treated as destructive (fail safe), and annotated tools are read via the SDK's actual field names.
Actual: unannotated destructive tools bypass the Code Mode approval gate; annotated tools raise AttributeError on mcp >=2.0.
Environment: reproduced against mcp==2.0.0, tool annotation defaults per the MCP spec.
Happy to open a PR: read the hints via the SDK field names (handling both casings for compatibility) and default to destructive when destructiveHint is unset and the tool is not explicitly read-only.
For 1. we will think of introducing a feature flag like TREAT_UNANNOTATED_TOOLS_AS_DESTRUCTIVE with default false. We will get back after an internal discussion
For now, we have decided to not change the behavior for unnotated tools
Most MCP Servers out in the wild do not have proper tool annotations - in which case the harness would have to trigger approval on every single tool regardless it is destructive or not. We explicitly call out our policy to not gate unannotated tools by default in our docs.
Activity
chiragjn commentedon Aug 26, 2026
We will only address 2. in #373
For 1. we will think of introducing a feature flag like
TREAT_UNANNOTATED_TOOLS_AS_DESTRUCTIVEwith defaultfalse. We will get back after an internal discussionchiragjn commentedon Sep 25, 2026
For now, we have decided to not change the behavior for unnotated tools
Most MCP Servers out in the wild do not have proper tool annotations - in which case the harness would have to trigger approval on every single tool regardless it is destructive or not. We explicitly call out our policy to not gate unannotated tools by default in our docs.
require_approval_for_toolsat https://trueforge.dev/create-agent/overview#mcp_servers