Skip to content

fix(mcp): carry each MCP tool's output schema, title and annotations - #99

Open
hilariie wants to merge 1 commit into
mainfrom
fix/mcp-tool-output-schema
Open

hilariie wants to merge 1 commit into
mainfrom
fix/mcp-tool-output-schema

Conversation

@hilariie

@hilariie hilariie commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Port of genkit-ai/genkit#6903, adapted to this repo's Tool API.

Why

An MCP server can declare an outputSchema, a title and annotations for a tool. Here, handles from get_active_tools() already sent the output schema to the model, but <client>:tool/* selectors did not, and the title and annotations were dropped on both paths.

Changes

  • mcp_tool_to_action sets the server's outputSchema as the tool's model_output_schema, so both paths send it. Tools without one still send none.
  • mcp_tools_to_handles only existed to add that schema to handles, so it is removed and get_active_tools() uses mcp_tools_to_actions.
  • metadata['mcp'] also holds the tool's title and annotations. Hints the server left out stay absent, and unknown keys are kept as sent. Neither is sent to the model.

How this differs from upstream

  • Upstream writes metadata[ORIGINAL_OUTPUT_SCHEMA_KEY] directly. Here the model_output_schema setter writes the same key, and also onto the tool.v2 wire action.
  • The README and the new client test read tool.metadata['mcp'], because a local Tool is itself the action (upstream: tool.action().metadata['mcp']).

Should land after #90.

Port of genkit-ai/genkit#6903, adapted to this repo's Tool API.

mcp_tool_to_action now sets the server's outputSchema as the tool's
model_output_schema, so <client>:tool/* selectors send it to the model
as get_active_tools() handles already did. mcp_tools_to_handles only
existed to add that schema, so it is removed. metadata['mcp'] also
keeps the tool's title and annotations, leaving out what the server
did not send.

Upstream-Commit: genkit-ai/genkit@6606da9
Upstream-PR: genkit-ai/genkit#6903

@huangjeff5 huangjeff5 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

The implementation and tests look good: mcp_tool_to_action sets model_output_schema and preserves title and annotations on metadata['mcp'] for both get_active_tools() and <client>:tool/*.

Verified locally in a temporary worktree:

  • uv run --no-sync pytest packages/genkit-mcp/tests: 263 passed on the PR head, and 269 passed when merged with main (resolving the README.md conflict in favor of main).
  • ruff check, ruff format --check, pyright, and ty pass on packages/genkit-mcp.

Holding approval/auto-merge because:

  1. packages/genkit-mcp/README.md has a merge conflict with main (and maintainer edits are disabled on the branch).
  2. The PR notes it should land after #90, which is still open.

Please rebase onto main (keeping the updated README structure) and let us know once #90 is resolved.

This branch has not been deployed

No deployments
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.

2 participants