Fix: McpIntegration.list_tools() always returns empty inputSchema (#1073) #1757
kaluli123123
started this conversation in
Bug reports
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Summary
McpIntegration.list_tools()(prime-agent-runtime/src/rlm/mcp_base.py) always returns"inputSchema": {}for every tool of every MCP server, even though the server sends a full JSON Schema. This was already reported and diagnosed in #1073, which is one of the "related reports" under the still-open tracker #1383 (Harden MCP OAuth discovery and Codex transports — "preserve MCP tool schemas ..."). The merged stack PR #1164 for that tracker didn't touch this file, so the bug is still present onmain(verified on06860844e).Root cause
mcp.types.Toolis a pydantic model whose schema field is the snake_caseinput_schema, with a camelCase aliasinputSchema:Aliases are honored on validation and on
model_dump(by_alias=True), never as a plain attribute. So the existing codealways misses and silently substitutes
{}. The same value feeds the per-tool docstring in__getattr__, so the documented discovery path ("callhelp(<tool>)for the argument schema") returns nothing for every MCP integration, and callers have to reverse-engineer arguments from the server's validation errors one field at a time — this is exactly what the original report describes with Context7.The existing regression test in
test_mcp_base.pydidn't catch this because its fake session built tools from a bare duck-typed stub that set the camelCase attribute directly (t.inputSchema = schema), which happens to satisfy the buggygetattrand therefore encodes the bug rather than catching it.Fix
Read the schema via
model_dump(by_alias=True)first (falls back to plaingetattrfor non-pydantic stand-ins used in tests):Also rebuilt the test double to construct a real
mcp.types.Toolinstead of the duck-typed stub, and added a regression test asserting the schema round-trips throughlist_tools()and the bound-tool docstring. Confirmed the new test fails against the pre-fix code and passes after the fix.Validation
Also ran the full
npm run checkat the repo root (biome,tsgo --noEmit, installer render check, browser smoke check) — all green; this change doesn't touchpackages/*, so no.changes/fragment is required by the changelog-fragment CI check.Patch
Branch pushed here, diff is two files / ~55 lines: https://github.com/kaluli123123/prime-agent/tree/fix/mcp-tool-input-schema-alias
Diff: main...kaluli123123:prime-agent:fix/mcp-tool-input-schema-alias
Happy to open a PR from this branch if a maintainer wants to invite implementation, per CONTRIBUTING.md.
All reactions