Skip to content

Conversation

@ElliottJW
Copy link

@ElliottJW ElliottJW commented Dec 15, 2025

Description

This PR adds support for the meta field in MCPToolResult, allowing MCP tools to return metadata alongside their content. The implementation follows the same pattern as structuredContent, only including the field when it's not None.

Changes:

  • Added meta field to MCPToolResult with documentation
  • Updated _handle_tool_result in mcp_client to conditionally include meta when present
  • Modified echo_server to add test tools that return CallToolResult with meta field
  • Added unit tests covering meta field scenarios
  • Added integration tests validating end-to-end meta field handling

Related Issues

Closes #881

Documentation PR

No documentation changes needed - the meta field is already part of the MCP specification.

Type of Change

New feature

Testing

All tests pass:

  • Additional unit tests in test_mcp_client.py

  • New integration tests in test_mcp_client_meta_with_hooks.py

  • I ran hatch run prepare (equivalently ran ruff, mypy, and all tests)

Checklist

  • I have read the CONTRIBUTING document
  • I have added any necessary tests that prove my fix is effective or my feature works
  • I have updated the documentation accordingly (added inline documentation for the meta field)
  • I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • My changes generate no new warnings
  • Any dependent changes have been merged and published

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@ElliottJW ElliottJW changed the title Issue 881: Support 'meta' field in MCPToolResult. Feature: Issue 881 - Support 'meta' field in MCPToolResult. Dec 15, 2025
@ElliottJW
Copy link
Author

@dbschmigelski - I looked at the comments you left here before opening this PR. We're very interested in leveraging this field in our services via hooks, so we'll be responsive to any feedback you have.

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.

[FEATURE] MCP ToolResult meta field is missing

2 participants