Skip to content

fix(opencode): propagate tool.definition hook parameter modifications to MCP tools#31685

Open
davidgut1982 wants to merge 3 commits into
anomalyco:devfrom
davidgut1982:fix/mcp-tool-definition-parameters
Open

fix(opencode): propagate tool.definition hook parameter modifications to MCP tools#31685
davidgut1982 wants to merge 3 commits into
anomalyco:devfrom
davidgut1982:fix/mcp-tool-definition-parameters

Conversation

@davidgut1982

@davidgut1982 davidgut1982 commented Jun 10, 2026

Copy link
Copy Markdown

Issue for this PR

Closes #31677

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

The tool.definition hook in session/tools.ts was passing a {description} object to plugins, but only reading back the description. Any modifications plugins made to parameters (the input schema) were silently dropped — the original MCP tool's schema was used instead.

This fix adds item.inputSchema = defOutput.parameters so the plugin's parameter modifications actually propagate to the final tool registration. Without this, the MCP router plugin's parameter-stripping hook (and any future schema-modifying plugins) would have no effect on MCP tools.

How did you verify your code works?

  • Ran bun test tool/tool-definition-mcp.test.ts — 3/3 tests pass, 9 expect() calls, 0 failures
  • The new test creates a plugin that modifies output.parameters to add a modified boolean property, then verifies the schema change appears on the resolved tool
  • Cherry-picked existing tests from fix(opencode): add missing tool.definition hook for MCP tools #31671 to ensure hook fires and description modification still work

Screenshots / recordings

N/A — no UI changes.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

Add 2 unit tests proving the fix at session/tools.ts lines 120-123:
- Hook fires with correct toolID and description
- Plugin mutation of description propagates to returned tool

Uses Layer.mock for MCP and ToolRegistry services, Layer.succeed
for Plugin.Service with captured hook calls.
- Replace Layer.succeed for Truncate.Service with Layer.mock
  (Truncate.Interface has no 'init' method)
- Add mandatory 'mode' and 'options' fields to test agent objects
@github-actions github-actions Bot added needs:compliance This means the issue will auto-close after 2 hours. and removed needs:compliance This means the issue will auto-close after 2 hours. labels Jun 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Thanks for updating your PR! It now meets our contributing guidelines. 👍

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.

fix: tool.definition hook parameters output silently dropped for MCP tools

1 participant