Skip to content

feat(mcp): forward plugin-set _meta to downstream MCP tool calls#21539

Open
moghtader wants to merge 3 commits intoanomalyco:devfrom
moghtader:feat/mcp-forward-tool-use-id-meta
Open

feat(mcp): forward plugin-set _meta to downstream MCP tool calls#21539
moghtader wants to merge 3 commits intoanomalyco:devfrom
moghtader:feat/mcp-forward-tool-use-id-meta

Conversation

@moghtader
Copy link
Copy Markdown

Issue for this PR

Closes #17084

Type of change

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

What does this PR do?

Plugins can mutate args in tool.execute.before but there's no way to set _meta on downstream MCP tools/call requests. I need this to forward correlation IDs to my MCP servers without stuffing them into tool arguments.

This adds _meta as an optional field on the tool.execute.before hook output. If a plugin sets it, it gets forwarded in client.callTool(). When no plugin sets it, nothing changes.

How did you verify your code works?

Built with bun run build -- --single, called MCP tools through a proxy server, confirmed _meta shows up in the JSON-RPC request when set by a plugin and is absent when not.

Checklist

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 8, 2026

The following comment was made by an LLM, it may be inaccurate:

Based on my search, here are related PRs that might be relevant to this PR (excluding the current PR #21539):

Related PRs:

  1. feat(plugin): add messageID to tool.execute.before/after hooks #15831 - feat(plugin): add messageID to tool.execute.before/after hooks

    • Related because it also extends the tool.execute.before/after hooks with additional fields
  2. feat(plugin): surface agent and parentAgent in plugin hook input #15412 - feat(plugin): surface agent and parentAgent in plugin hook input

    • Related because it adds new context to plugin hooks similar to what this PR does with _meta
  3. fix(opencode): allow tool hooks to replace call arguments #20009 - fix(opencode): allow tool hooks to replace call arguments

    • Related because it deals with tool hook mutation capabilities
  4. fix: Allow plugin hooks to mutate tool call args before context creation #20053 - fix: Allow plugin hooks to mutate tool call args before context creation

    • Related because it addresses plugin mutations in tool calls, similar to the args mutation mentioned in this PR

These PRs all deal with enhancing the plugin hook system for tool execution, which is the same area being modified by PR #21539.

@moghtader moghtader force-pushed the feat/mcp-forward-tool-use-id-meta branch 2 times, most recently from df2283c to 5623429 Compare April 8, 2026 16:04
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]: Support _meta when calling downstream MCP tools

2 participants