Skip to content

MCP: fix show_conversation TypeError after account_id became keyword-only - #131

Merged
Ooscaar merged 2 commits into
developfrom
t3/mcp-correlate-errors-fix-root-cause
Nov 24, 2026
Merged

Ooscaar merged 2 commits into
developfrom
t3/mcp-correlate-errors-fix-root-cause

Conversation

@Ooscaar

@Ooscaar Ooscaar commented Nov 24, 2026 •

Copy link
Copy Markdown
Member

Problem

The hosted MCP tool show_conversation fails on every call:

MessagesResource.get_inbox_conversation_messages() takes 2 positional arguments but 3 positional arguments (and 2 keyword-only arguments) were given

The error is raised inside the MCP process before any request goes out, which is why no API logs show it. messages_get_inbox_conversation_messages and show_inbox still work with the same ids.

Root cause

  • feat(mcp): Zernio MCP App, interactive views in Claude and ChatGPT (behind ZERNIO_MCP_APPS) #113 (2026-11-18) added show_conversation, which calls client.messages.get_inbox_conversation_messages(conversation_id, account_id, ...) with account_id passed positionally.
  • The spec regen in 7e04675 (2026-11-20) made accountId optional on GET /v1/inbox/conversations/{id}/messages. The generator puts optional params after *, so account_id became keyword-only and the hand-written call broke. The generated tool (generated_tools.py) already passed it by keyword and kept working.

Why nothing caught it

  • mypy runs in CI, but late.mcp.* is in ignore_errors, and the app tools get their client through _server() -> Any. mypy saw nothing.
  • The regen workflow (generate.yml) does run pytest before it commits, but nothing exercised show_conversation, which only registers when ZERNIO_MCP_APPS is set.

Fix

  • show_conversation passes account_id=account_id.
  • Every other SDK call in the app tools passes everything except URL path parameters by keyword. That includes show_post_preview's validate_post(platforms=...), which had the same latent bug: platforms is a body field and was passed by position. Keyword arguments still work when the spec makes a param optional.

Audit of other call sites

  • generated_tools.py: all 1,390 SDK calls already pass every non-path argument by keyword. None are at risk.
  • server.py: calls the hand-written resources in late/resources/*.py, which regen doesn't touch. Not at risk.
  • apps/tools.py: show_conversation (broken) and validate_post (latent). Both fixed here.

Tests (tests/test_mcp_sdk_call_sites.py)

  1. Every hand-written <x>.<resource>.<method>(...) call under late/mcp must bind to the current SDK signature.
  2. For generated resources, only URL path parameters may be passed positionally. This catches the risky pattern before a regen turns it into a crash.
  3. End-to-end show_conversation call (respx) checks that accountId is sent.

The regen workflow runs pytest before it commits, so a regen that would break a call site now stops there instead of shipping.

Verification

  • With the fix set aside, the tests fail with the exact production error. The keyword rule also flags the old validate_post call.
  • Full suite: 3545 passed.
  • Live check against production with a read-only API key: on develop, show_conversation returns the TypeError; on this branch it returns the conversation.

🤖 Generated with Claude Code

Ooscaar and others added 2 commits November 24, 2026 21:55
…only

The 2026-11-20 spec regen made accountId optional on
GET /v1/inbox/conversations/{id}/messages, so the generator moved
account_id behind `*` in get_inbox_conversation_messages. show_conversation
still passed it positionally and raised TypeError on every call, before
any request went out.

Pass account_id (and every other non-path argument in the app tools) by
keyword, so a required-to-optional flip in the spec cannot break these
call sites again. Add a test that binds every hand-written client.<res>.<method>
call in late/mcp against the current SDK signatures, so a regen that breaks
one fails CI, plus an end-to-end show_conversation test.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… tests

show_post_preview passed the platforms body field positionally, the same
pattern that broke show_conversation: if the spec ever makes it optional,
the regen moves it behind `*` and the tool raises TypeError.

The call-site test now finds SDK calls on any receiver and, for generated
resources, fails when anything other than a URL path parameter is passed
positionally, so the risk is caught before a regen turns it into a crash.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Ooscaar
Ooscaar merged commit 1621eb9 into develop Nov 24, 2026
4 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.

1 participant