Skip to content

Conversation

@vamgan
Copy link
Contributor

@vamgan vamgan commented Sep 8, 2025

This PR adds support for MCP output schema tool specifications as defined in the MCP specification (https://modelcontextprotocol.io/specification/2025-06-18/server/tools#data-types). This allows tools to define their expected output structure through outputSchema, which is particularly valuable for LLM agents to better understand tool capabilities and responses.

Note, the LLM is not automatically shown the outputSchema. In the future certain models may accept but. But for now, it is a device that users can leverage internally. For example if someone wanted to create their own dynamic tool loader they could use the outputSchema as a message.

As part of this we needed to make sure the BedrockModel explicitly manages its supported fields (including handling outputSchema appropriately), while other providers naturally drop fields they don't recognize. This maintains backward compatibility while keeping the code cleaner and more maintainable.

Closes #787

Type of Change

New feature

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

  • I ran hatch run prepare

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
  • 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.

@dbschmigelski dbschmigelski self-assigned this Sep 8, 2025
@dbschmigelski
Copy link
Member

Thanks for the work here!

@vamgan vamgan force-pushed the feat/add-output-schema-support branch from c020b6b to b31dc7d Compare September 8, 2025 21:00
@vamgan vamgan force-pushed the feat/add-output-schema-support branch from b31dc7d to 5470b11 Compare September 8, 2025 21:02
@vamgan vamgan requested a review from dbschmigelski September 8, 2025 21:37
Copy link

@mxie-extreme mxie-extreme left a comment

Choose a reason for hiding this comment

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

vamgan pushed a commit to vamgan/sdk-python that referenced this pull request Sep 8, 2025
- Add outputSchema as optional field in ToolSpec using NotRequired
- Filter outputSchema unconditionally in streaming.py before passing to models
- Add outputSchema support to MCP agent tool adapter
- Add tests for outputSchema functionality
- Addresses PR strands-agents#818 review comments
@vamgan vamgan force-pushed the feat/add-output-schema-support branch from 5470b11 to 49c0897 Compare September 8, 2025 23:52
@vamgan
Copy link
Contributor Author

vamgan commented Sep 8, 2025

Should we add outputSchema here too: https://github.com/strands-agents/sdk-python/blob/main/src/strands/tools/mcp/mcp_agent_tool.py#L63

yes, thanks for pointing it out.

@vamgan vamgan requested a review from mxie-extreme September 10, 2025 19:44
@dbschmigelski
Copy link
Member

Hi, I want to apologize for the delay in reviewing this. I will take a look tomorrow morning with the aim of getting the PR merged next week.

@vamgan
Copy link
Contributor Author

vamgan commented Sep 11, 2025

Hi, I want to apologize for the delay in reviewing this. I will take a look tomorrow morning with the aim of getting the PR merged next week.

Thanks!

@dbschmigelski dbschmigelski force-pushed the feat/add-output-schema-support branch from 49c0897 to 169fca4 Compare September 15, 2025 22:36
dbschmigelski pushed a commit to vamgan/sdk-python that referenced this pull request Sep 15, 2025
- Add outputSchema as optional field in ToolSpec using NotRequired
- Filter outputSchema unconditionally in streaming.py before passing to models
- Add outputSchema support to MCP agent tool adapter
- Add tests for outputSchema functionality
- Addresses PR strands-agents#818 review comments
dbschmigelski
dbschmigelski previously approved these changes Sep 15, 2025
dbschmigelski pushed a commit to vamgan/sdk-python that referenced this pull request Sep 16, 2025
- Add outputSchema as optional field in ToolSpec using NotRequired
- Filter outputSchema unconditionally in streaming.py before passing to models
- Add outputSchema support to MCP agent tool adapter
- Add tests for outputSchema functionality
- Addresses PR strands-agents#818 review comments
@dbschmigelski dbschmigelski force-pushed the feat/add-output-schema-support branch from f6fcbd3 to c0a6d5e Compare September 16, 2025 21:18
@vamgan
Copy link
Contributor Author

vamgan commented Sep 18, 2025

@dbschmigelski Hi,any issues for this merge?

dbschmigelski pushed a commit to vamgan/sdk-python that referenced this pull request Sep 19, 2025
- Add outputSchema as optional field in ToolSpec using NotRequired
- Filter outputSchema unconditionally in streaming.py before passing to models
- Add outputSchema support to MCP agent tool adapter
- Add tests for outputSchema functionality
- Addresses PR strands-agents#818 review comments
@dbschmigelski dbschmigelski force-pushed the feat/add-output-schema-support branch from c0a6d5e to 5eef756 Compare September 19, 2025 16:09
@dbschmigelski
Copy link
Member

dbschmigelski commented Sep 19, 2025

Hi, turns out #836 was not as relevant. Or rather it did not go far enough. We still were coupled to the ToolSpec definition. This PR removes that by doing the destructuring in BedrockModel. Meaning we do not need the global filter in the event loop.

All other providers drop the additional field.

@dbschmigelski dbschmigelski enabled auto-merge (squash) September 19, 2025 19:48
Vamil Gandhi and others added 9 commits September 19, 2025 15:49
- Add outputSchema as optional field in ToolSpec using NotRequired
- Filter outputSchema unconditionally in streaming.py before passing to models
- Add outputSchema support to MCP agent tool adapter
- Add tests for outputSchema functionality
- Addresses PR strands-agents#818 review comments
@dbschmigelski dbschmigelski force-pushed the feat/add-output-schema-support branch from 03bbe72 to afeeaf5 Compare September 19, 2025 19:50
@dbschmigelski dbschmigelski merged commit 6ea8f72 into strands-agents:main Sep 19, 2025
12 checks passed
@vamgan vamgan deleted the feat/add-output-schema-support branch September 19, 2025 20:57
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.

[FEATURE] Strands MCP client should support retrieving Output Schema & other Data Types

4 participants