Skip to content

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

Merged
chiragjn merged 2 commits into
truefoundry:mainfrom
MTEnt:fix/code-mode-destructive-gate
Aug 26, 2026
Merged

chiragjn merged 2 commits into
truefoundry:mainfrom
MTEnt:fix/code-mode-destructive-gate

Conversation

@MTEnt

@MTEnt MTEnt commented Aug 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Addresses the MCP Python SDK 2.0 compatibility portion of #318.

MCP Python SDK 1.29 exposes tool annotation attributes in camelCase, while SDK 2.0 exposes them in snake_case. This change prefers the SDK 2.0 snake_case fields and falls back to the older camelCase fields. Existing destructive-tool behavior, including the handling of unannotated tools, is unchanged.

Changes

  • Prefer destructive_hint and read_only_hint in the core sandbox client, with camelCase fallback.
  • Prefer snake_case annotation keys in the local sandbox client, with camelCase fallback.
  • Add patch changesets for @truefoundry/trueforge-core and @truefoundry/trueforge.

How was this tested?

  • Direct compatibility checks against real mcp==1.29.0 and mcp==2.0.0 model objects through both _is_destructive implementations, covering unannotated, read-only, destructive, and non-read-only non-destructive tools.
  • pnpm typecheck using Git Bash as the package script shell on Windows.
  • pnpm format:check.
  • pnpm lint:ci was run but reports 23 errors in unchanged frontend files on this Windows checkout; the full local-check item below is therefore left unchecked.

Checklist

  • pnpm build, pnpm test, pnpm typecheck, pnpm lint:ci, and pnpm format:check pass locally
  • Tests added/updated where it makes sense - the added policy tests were removed per review; compatibility was checked directly against both SDK versions
  • No hand-edits to generated code (packages/trueforge-sdk, .github/fern/openapi/openapi.json, docs/openapi.json) - fork PRs omit SDK regen; maintainers regenerate after merge
  • Docs / .env.example updated if configuration or behavior changed - not applicable

Note

Low Risk
Narrow compatibility change in annotation field lookup only; destructive-tool gating logic and approval behavior are explicitly preserved.

Overview
Updates Code Mode MCP client destructive-tool checks to work with MCP Python SDK 2.0, which exposes tool annotation fields as destructive_hint and read_only_hint instead of the SDK 1.29 camelCase names.

In mcp_client.py, _is_destructive now reads those hints via getattr, preferring snake_case and falling back to destructiveHint / readOnlyHint. The local UDS client mcp_client_local.py applies the same preference on annotation dict keys. When a tool is blocked in Code Mode is unchanged (including unannotated tools and the read-only / destructive rules).

Patch changesets were added for @truefoundry/trueforge-core and @truefoundry/trueforge.

Reviewed by Cursor Bugbot for commit 32f9c86. Bugbot is set up for automated code reviews on this repo. Configure here.

@MTEnt MTEnt changed the title fix: fail closed for unannotated MCP tools fix(code-mode): fail closed for unannotated MCP tools Aug 20, 2026
@MTEnt
MTEnt marked this pull request as ready for review August 20, 2026 08:00
@chiragjn chiragjn changed the title fix(code-mode): fail closed for unannotated MCP tools fix(code-mode): prefer snake case mcp tool annotations fields over camel case ones Aug 26, 2026

@chiragjn chiragjn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is forward compatibility PR to support mcp 2.0 sdk. Please do not change any behavior around detecting destructive tools in this PR

@changeset-bot

changeset-bot Bot commented Aug 26, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 32f9c86

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 2 packages
Name Type
@truefoundry/trueforge-core Patch
@truefoundry/trueforge Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@chiragjn
chiragjn force-pushed the fix/code-mode-destructive-gate branch from 04154d1 to 32f9c86 Compare August 26, 2026 12:36
@chiragjn
chiragjn enabled auto-merge (squash) August 26, 2026 12:36
@chiragjn
chiragjn merged commit 940c4e5 into truefoundry:main Aug 26, 2026
8 checks passed
@MTEnt
MTEnt deleted the fix/code-mode-destructive-gate branch August 26, 2026 12:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants