Skip to content

The open-source agent harness - the runtime layer that turns an LLM into a working agent.

fix(code-mode): prefer snake case mcp tool annotations fields over camel case ones (#373)

MTEnt940c4e5e6383
diff --git a/.changeset/code-mode-destructive-defaults.md b/.changeset/code-mode-destructive-defaults.md
new file mode 100644
index 000000000..5046e8a88
--- /dev/null
+++ b/.changeset/code-mode-destructive-defaults.md
@@ -0,0 +1,6 @@
+---
+'@truefoundry/trueforge-core': patch
+'@truefoundry/trueforge': patch
+---
+
+Prefer MCP Python SDK 2.0 snake_case tool annotation fields, with camelCase fallback for older SDKs, without changing destructive-tool detection behavior.
diff --git a/packages/trueforge-core/src/core/sandbox/scripts/mcp_client.py b/packages/trueforge-core/src/core/sandbox/scripts/mcp_client.py
index b942acde5..35dc8edf8 100644
--- a/packages/trueforge-core/src/core/sandbox/scripts/mcp_client.py
+++ b/packages/trueforge-core/src/core/sandbox/scripts/mcp_client.py
@@ -225,7 +225,14 @@ def _is_destructive(tool: Tool) -> bool:
annotations = tool.annotations
if annotations is None:
return False
- return bool(annotations.destructiveHint) or (not annotations.readOnlyHint and annotations.readOnlyHint is not None)
+
+ destructive = getattr(
+ annotations, "destructive_hint", getattr(annotations, "destructiveHint", None)
+ )
+ read_only = getattr(
+ annotations, "read_only_hint", getattr(annotations, "readOnlyHint", None)
+ )
+ return bool(destructive) or (not read_only and read_only is not None)
async def _ensure_non_destructive(server: str, tool_name: str) -> None:
tool = await _get_tool(server, tool_name)
diff --git a/packages/trueforge/src/sandbox/local/scripts/mcp_client_local.py b/packages/trueforge/src/sandbox/local/scripts/mcp_client_local.py
index 0a1eb1af4..9de816a54 100644
--- a/packages/trueforge/src/sandbox/local/scripts/mcp_client_local.py
+++ b/packages/trueforge/src/sandbox/local/scripts/mcp_client_local.py
@@ -181,8 +181,9 @@ def _is_destructive(tool: dict[str, Any]) -> bool:
return False
if not isinstance(annotations, dict):
return False
- destructive = annotations.get("destructiveHint")
- read_only = annotations.get("readOnlyHint")
+
+ read_only = annotations.get("read_only_hint", annotations.get("readOnlyHint"))
+ destructive = annotations.get("destructive_hint", annotations.get("destructiveHint"))
return bool(destructive) or (not read_only and read_only is not None)