Skip to content

fix: validate MCP allowed tool names at runtime - #206

Open
mohammedmessaoudene-cmd wants to merge 1 commit into
xai-org:mainfrom
mohammedmessaoudene-cmd:codex/fix-mcp-allowed-tool-names-validation
Open

fix: validate MCP allowed tool names at runtime#206
mohammedmessaoudene-cmd wants to merge 1 commit into
xai-org:mainfrom
mohammedmessaoudene-cmd:codex/fix-mcp-allowed-tool-names-validation

Conversation

@mohammedmessaoudene-cmd

Copy link
Copy Markdown

Summary

  • validate allowed_tool_names before constructing the MCP protobuf
  • reject a plain string instead of silently treating each character as a tool name
  • reject non-list containers and non-string list members with stable TypeError messages
  • preserve valid lists and the documented empty-list behavior

Problem

The helper is annotated as accepting list[str] | None, but protobuf construction accepts any iterable. Passing allowed_tool_names="safe" therefore succeeds and serializes four entries: s, a, f, and e, instead of rejecting the invalid Python input.

Validation

  • targeted runtime-validation tests: 8 passed
  • full SDK test suite: 839 passed
  • Ruff format/check: passed
  • Pyright: 0 errors

Scope

This patch changes only Python-side input validation. It does not change the protobuf schema or the documented behavior that an omitted or empty allowlist permits all tools.

@mohammedmessaoudene-cmd
mohammedmessaoudene-cmd requested a review from a team as a code owner September 3, 2026 03:10
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.

1 participant