Skip to content

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

Closed

Description

@sorted-ai-bot

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 doesn't fully meet our contributing guidelines.

    What needs to be fixed:

    • No issue template was used. Please use one of the three required templates: Bug Report, Feature Request, or Question.
    • Bug reports must include a proper Description field with reproduction steps and system information.
    • The issue appears to be AI-generated content, which is not acceptable per our contributing guidelines.

    Please edit this issue to address the above within 2 hours, or it will be automatically closed.


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

    If you believe this was flagged incorrectly, please let a maintainer know.

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

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)needs:complianceThis means the issue will auto-close after 2 hours.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions