Skip to content

feat(mcp): forward plugin request metadata - #38579

Open
dialupdisaster wants to merge 1 commit into
anomalyco:devfrom
DEVtheOPS:mcp-request-meta
Open

feat(mcp): forward plugin request metadata#38579
dialupdisaster wants to merge 1 commit into
anomalyco:devfrom
DEVtheOPS:mcp-request-meta

Conversation

@dialupdisaster

Copy link
Copy Markdown

Issue for this PR

Closes#17084

Updates the implementation proposed in #21539 and #21624 for the current MCP tool paths.

Type of change

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

What does this PR do?

Plugins can now set optional _meta fields in tool.execute.before. OpenCode forwards them to downstream MCP tools/call requests without exposing them as tool arguments.

The forwarding covers both normal MCP tools and code-mode child calls. A shared call path preserves MCP SDK 1.29's own metadata, including progress tokens, and supports SEP-414 trace context without adding metadata by default.

How did you verify your code works?

  • bun typecheck in packages/opencode and packages/plugin
  • root bun typecheck (30 packages)
  • env -u OPENCODE_DISABLE_CLAUDE_CODE bun test in packages/opencode (3,199 pass, 0 fail)
  • bun run test:httpapi in packages/opencode (208/208 in coverage, auth, and effect modes)
  • focused normal, code-mode, and in-memory MCP transport tests

bun lint still reports the existing octal-escape error in packages/session-ui/src/v2/components/prompt-input/index.tsx; changed files have no lint errors.

Screenshots / recordings

Not applicable; no UI changes.

Checklist

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

@github-actions

Copy link
Copy Markdown
Contributor

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

Based on my search, I found related PRs that should be reviewed for context:

Potentially Related PRs:

  1. feat(mcp): forward session ID and plugin _meta to MCP tool calls #21624 - feat(mcp): forward session ID and plugin _meta to MCP tool calls

  2. feat(mcp): add mcp.call.before plugin hook for per-call MCP request headers #28319 - feat(mcp): add mcp.call.before plugin hook for per-call MCP request headers

    • Related feature addressing similar MCP request customization through plugins

These are not duplicates but rather related/predecessor work. The current PR (#38579) is an updated implementation of the approach outlined in #21624 adapted for current MCP tool paths.

Sign up for freeto 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

1 participant

@dialupdisaster