Skip to content

The open source coding agent.

TypeScript

fix: allow `tool.execute.after` hook to modify MCP tool output (#3381)

Andrew Pashynnyk3c7b229d8bf3
diff --git a/packages/opencode/src/session/prompt.ts b/packages/opencode/src/session/prompt.ts
index b49b22a521c..ee8e3677568 100644
--- a/packages/opencode/src/session/prompt.ts
+++ b/packages/opencode/src/session/prompt.ts
@@ -588,10 +588,7 @@ export namespace SessionPrompt {
},
)
const result = await execute(args, opts)
- const output = result.content
- .filter((x: any) => x.type === "text")
- .map((x: any) => x.text)
- .join("\n\n")
+
await Plugin.trigger(
"tool.execute.after",
{
@@ -602,6 +599,11 @@ export namespace SessionPrompt {
result,
)
+ const output = result.content
+ .filter((x: any) => x.type === "text")
+ .map((x: any) => x.text)
+ .join("\n\n")
+
return {
title: "",
metadata: {},