Skip to content

tool.execute.after hook receives raw MCP result instead of assembled output #21149

Closed as not planned

Description

@YumaKakuya

The tool.execute.after hook fires for MCP tools before the output text is assembled from the raw CallToolResult.content[] array. Plugins hooking this event receive the raw MCP SDK result (which has a content array of {type, text} objects) instead of the {title, output, metadata} shape declared in the Hooks type definition.

This means any plugin that tries to read or transform output.output gets undefined, and even if the plugin mutates the raw result, the text assembly rebuilds the output from result.content independently. The hook is effectively a no-op for MCP tool output transformation.

The Hooks type in packages/plugin/src/index.ts declares the output parameter as:

"tool.execute.after": (
  input: { tool: string; sessionID: string; callID: string; args: any },
  output: { title: string; output: string; metadata: any; attachments?: ... }
) => Promise<void>

But the actual call in packages/opencode/src/session/prompt.ts passes the raw MCP result object before text extraction.

Native tools (bash, read, etc.) are not affected — they have their own hook paths that pass the correct shape.

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 6, 2026
  2. github-actions commented on Apr 6, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  3. YumaKakuya commented on Apr 6, 2026

    @YumaKakuya
    Author

    Not a duplicate. #21145 and #21146 were filed under the wrong account and have both been closed. This issue (#21149) is the correct one, with the fix in PR #21150.

  4. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  5. github-actions commented on Jul 6, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions