metadata is lost for mcp tool calls in tool.execute.after hook #2364

Closed
opened 2026-02-16 17:35:20 -05:00 by yindo · 0 comments
Owner

Originally created by @kynnyhsap on GitHub (Oct 30, 2025).

Description

Currently updating metadata in tool.execute.after hook works for regular tools, but NOT for MCP tools. PR to fix it: https://github.com/sst/opencode/pull/3573

export const MCPMetadataExamplePlugin = async ({}) => {
  return {
    'tool.execute.after': async (input, output) => {
      // CURRENTLY this works for regular tools, but not for MCP tools
      output.metadata = {
        custom: true,
      }
    },
  }
}

OpenCode version

0.15.23

Steps to reproduce

  1. Create a plugin with tool.execute.after hook that updates metadata
  2. Ask agent to run some MCP tools
  3. Go to messages of this session and see that metadata is always empty.
export const MCPMetadataExamplePlugin = async ({}) => {
  return {
     'tool.execute.after': async (input, output) => {
      // CURRENTLY this works for regular tools, but not for MCP tools
      output.metadata = {
        custom: true,
      }
    },
  }
}

Screenshot and/or share link

No response

Operating System

macOS 26.0.1

Terminal

Ghostty

Originally created by @kynnyhsap on GitHub (Oct 30, 2025). ### Description Currently updating metadata in `tool.execute.after` hook works for regular tools, but NOT for MCP tools. PR to fix it: https://github.com/sst/opencode/pull/3573 ```typescript export const MCPMetadataExamplePlugin = async ({}) => { return { 'tool.execute.after': async (input, output) => { // CURRENTLY this works for regular tools, but not for MCP tools output.metadata = { custom: true, } }, } } ``` ### OpenCode version 0.15.23 ### Steps to reproduce 1. Create a plugin with `tool.execute.after` hook that updates metadata 2. Ask agent to run some MCP tools 3. Go to messages of this session and see that metadata is always empty. ```typescript export const MCPMetadataExamplePlugin = async ({}) => { return { 'tool.execute.after': async (input, output) => { // CURRENTLY this works for regular tools, but not for MCP tools output.metadata = { custom: true, } }, } } ``` ### Screenshot and/or share link _No response_ ### Operating System macOS 26.0.1 ### Terminal Ghostty
yindo added the bug label 2026-02-16 17:35:20 -05:00
yindo closed this issue 2026-02-16 17:35:20 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#2364