sdk-python icon indicating copy to clipboard operation
sdk-python copied to clipboard

feat(mcp): Add a new field _meta to MCPToolResult

Open Mashiro2000 opened this issue 2 months ago • 2 comments

Description

#881

# file:src/strands/tools/mcp/mcp_types.py
# because it is a TypedDict, we use `_meta` instead of `meta`.
class MCPToolResult(ToolResult):
    _meta: NotRequired[Dict[str, Any]]  # add logic,
    structuredContent: NotRequired[Dict[str, Any]]

# file:src/strands/tools/mcp/mcp_client.py
# method:_handle_tool_result
result = MCPToolResult(
    status=status,
    toolUseId=tool_use_id,
    content=mapped_contents,
    _meta=call_tool_result.meta,  # add logic
)

Related Issues

Issues #881

Documentation PR

Type of Change

Bug fix

Bug fix New feature Breaking change Documentation update Other (please describe):

Testing

How have you tested the change? Verify that the changes do not break functionality or introduce warnings in consuming repositories: agents-docs, agents-tools, agents-cli

  • [x] I ran hatch run prepare

Checklist

  • [x] I have read the CONTRIBUTING document
  • [x] I have added any necessary tests that prove my fix is effective or my feature works
  • [x] I have updated the documentation accordingly
  • [x] I have added an appropriate example to the documentation to outline the feature, or no new docs are needed
  • [x] My changes generate no new warnings
  • [x] 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.

Mashiro2000 avatar Sep 28 '25 09:09 Mashiro2000