Skip to content

WIP: add tool outputSchema and DataContent type to support structured content #685

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 10 commits into
base: main
Choose a base branch
from

Conversation

davemssavage
Copy link

@davemssavage davemssavage commented May 11, 2025

Enable tool to return data content and schema.

Motivation and Context

As per discussion in modelcontextprotocol/modelcontextprotocol#356 there are use cases where being able to know the schema of a tool is useful prior to calling it. This patch is an experiment to enable me to test this behaviour, it is far from finished and depends on the above RFC being accepted before it is merged, however opening a draft pull request for comment

How Has This Been Tested?

Local unit testing only so far

Breaking Changes

At the moment yes, this patch results in DataContent items being returned whenever a complex object is returned from a tool, this may result in breaking changes in clients. Some thought needs to go into how best to tackle this.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update

Checklist

  • I have read the MCP Documentation
  • My code follows the repository's style guidelines
  • New and existing tests pass locally
  • I have added appropriate error handling
  • I have added or updated documentation as needed

Additional context

Updates to documentation will be required if this patch is approved

@davemssavage davemssavage marked this pull request as draft May 11, 2025 13:28
self.fn,
self.is_async,
arguments,
{self.context_kwarg: context}
if self.context_kwarg is not None
else None,
)
if self.output and self.output.get("type") == "object":
Copy link
Author

Choose a reason for hiding this comment

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

This logic is debatable it introduces a breaking change, potential to make this opt-in or opt-out by adding a flag to the @mcp.tool() annotation something like @mcp.tool(enable_data_content=True)

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.

1 participant