Skip to content

Fix MCP tool call payload handling#888

Open
mariano wants to merge 1 commit intomypyfrom
fix-tool_call_event_item-payload-handling
Open

Fix MCP tool call payload handling#888
mariano wants to merge 1 commit intomypyfrom
fix-tool_call_event_item-payload-handling

Conversation

@mariano
Copy link
Collaborator

@mariano mariano commented Jan 10, 2026

Summary

  • Update _tool_call_event_item in src/avalan/server/routers/mcp.py to handle EventType.TOOL_PROCESS payloads that provide calls as a list by extracting the first call so MCP tool-call notifications are emitted for streaming tool calls.
  • Add test coverage in tests/server/mcp_router_test.py for the payload={'calls': [call]} variant to ensure the new code path is exercised.

Testing

  • Ran make lint, which reformatted files but mypy failed due to a missing plugin error: pyproject.toml:1:1: error: Error importing plugin "pydantic.mypy": No module named 'pydantic'.
  • Ran poetry run pytest --verbose -s and the test suite passed: 1566 passed, 11 skipped, 5 warnings.

Codex Task

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0400144be4

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +1058 to +1061
calls = event.payload.get("calls")
if isinstance(calls, list) and calls:
call = calls[0]
else:

Choose a reason for hiding this comment

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

P2 Badge Emit all tool call notifications for multi-call events

When a TOOL_PROCESS payload includes multiple calls (the tool parser can emit payload={"calls": [call1, call2, ...]} when a response contains several tool calls at once), this code only selects calls[0], so _tool_event_notifications emits a notification for the first call and silently drops the rest. That means MCP clients won’t receive tool-call notifications for subsequent calls in the same event, breaking multi-tool responses; this scenario is triggered whenever the model outputs multiple tool calls in a single chunk.

Useful? React with 👍 / 👎.

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.

1 participant