Skip to content

Conversation

@rakdutta
Copy link
Collaborator

@rakdutta rakdutta commented Nov 10, 2025

closing issue #1406
This pull request introduces improvements to the handling and processing of tool responses, particularly for structured content, and enhances logging for debugging and traceability. The changes ensure that both unstructured and structured outputs from tools are correctly normalized and returned, and that the code is robust against different field naming conventions and model types.
Tool response handling and normalization:

  • Updated call_tool in streamablehttp_transport.py to return both unstructured and structured content when available, supporting both snake_case and camelCase field names for structured content. This allows downstream validation against output schemas.
  • In tool_service.py, enhanced extraction of structured content from tool responses by accepting both structuredContent and structured_content fields, improving compatibility with different model serialization formats.

Unit test robustness:

  • Updated unit tests in test_streamablehttp_transport.py to explicitly unset structured_content and override model_dump on mocks, preventing accidental attribute leakage and ensuring test accuracy.

@rakdutta rakdutta marked this pull request as ready for review November 10, 2025 15:49
Signed-off-by: rakdutta <[email protected]>
Signed-off-by: rakdutta <[email protected]>
Signed-off-by: rakdutta <[email protected]>
Signed-off-by: rakdutta <[email protected]>
Signed-off-by: rakdutta <[email protected]>
Signed-off-by: rakdutta <[email protected]>
Signed-off-by: rakdutta <[email protected]>
Signed-off-by: rakdutta <[email protected]>
Signed-off-by: rakdutta <[email protected]>
Signed-off-by: rakdutta <[email protected]>
Signed-off-by: rakdutta <[email protected]>
Copy link
Member

@kevalmahajan kevalmahajan left a comment

Choose a reason for hiding this comment

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

Structured Content is properly generated now with both /mcp as well as /sse and is being validated with the defined OutputSchema for the tool on the mcp client side.

- Change verbose info logging to debug level for tool responses
  to reduce production log noise while maintaining debug capability
- Remove redundant isinstance check in plugin response handling
- Add comprehensive docstring explaining structured content return
  types and MCP SDK behavior in call_tool function
- Add test case for structured content validation with tuple returns
- Improve code maintainability and documentation clarity

These changes enhance code quality without altering functionality,
improving pylint score from 9.64 to 9.77.

Signed-off-by: Mihai Criveti <[email protected]>
@crivetimihai crivetimihai force-pushed the outpout_schema_steamablehttp branch from d8c0937 to e6deb8e Compare November 12, 2025 08:40
@crivetimihai crivetimihai merged commit 491c8ba into main Nov 12, 2025
45 checks passed
@crivetimihai crivetimihai deleted the outpout_schema_steamablehttp branch November 12, 2025 09:34
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.

4 participants