Skip to content

feat: allowed_tools and require_approval for MCP servers (lands #328) - #476

Merged
TonsOfFun merged 5 commits into
mainfrom
claude/mcp-allowed-tools-328
Sep 24, 2026
Merged

TonsOfFun merged 5 commits into
mainfrom
claude/mcp-allowed-tools-328

Conversation

@TonsOfFun

Copy link
Copy Markdown
Contributor

Lands #328 by @dark-panda, whose commit is kept as authored, plus the two follow-ups it needed to go green.

  • f1fb203 — the original change: MCP servers accept allowed_tools and require_approval in the common format. OpenAI Responses passes them through; Anthropic turns allowed_tools into an mcp_toolset entry (default_config: {enabled: false}, one configs entry per allowed tool).
  • 414821c — the fix diagnosed on feat: Add allowed_tools and require_approval to option transforms #328 in July: Anthropic::Request defaults mcp_servers: [] on every request, so the new branch ran unconditionally and serialized "tools": null, failing 50 WebMock body expectations. :tools is now set only when a toolset was extracted. Also accepts allowed_tools entries as strings/symbols, and fixes the rubocop offenses.
  • aee2f01 — new: with function tools already on the request, the transform previously kept them and dropped the server's allowed_tools, silently losing the restriction exactly when a request used both. The toolset is now appended beside the existing tools; the test that pinned the old behaviour is updated.

Testing

Closes #328

🤖 Generated with Claude Code

https://claude.ai/code/session_01KfFzc97pARf86bj8LNR59B


Generated by Claude Code

dark-panda and others added 5 commits July 29, 2026 01:18
…CP tools

The allowed_tools extraction in PR #328 broke 50 integration tests because
Request#apply_defaults sets mcp_servers: [] on every request, and an empty
array is truthy — so the MCP branch in normalize_params ran unconditionally
and assigned params[:tools] = nil (via .presence), which the Anthropic gem
then serialized as "tools": null on every request body.

- Only assign params[:tools] when toolsets were actually extracted
- Support allowed_tools as tool-name strings/symbols as well as
  {name: ...} hashes, ignoring entries in any other format
- Make normalize_mcp_tools consistently return nil when nothing is
  extracted, and align test names with that behavior
- Fix Layout/SpaceInsideArrayLiteralBrackets rubocop offenses

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BgneVvQLw5Uc9jQxRHz6Zj
With function tools already declared, the Anthropic transform dropped a
server's allowed_tools rather than send them, so the restriction was
silently lost exactly when a request used both. The mcp_toolset entry is
now appended to the request's tools.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KfFzc97pARf86bj8LNR59B
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KfFzc97pARf86bj8LNR59B

# Conflicts:
#	CHANGELOG.md
@TonsOfFun
TonsOfFun merged commit cfa0061 into main Sep 24, 2026
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants