fix: mcp tool not triggering hooks (#2320)

This commit is contained in:
Aiden Cline
2025-08-29 21:51:06 -05:00
committed by GitHub
parent 9a330b4f0f
commit a3f4a030b4

View File

@@ -863,11 +863,31 @@ export namespace Session {
const execute = item.execute
if (!execute) continue
item.execute = async (args, opts) => {
await Plugin.trigger(
"tool.execute.before",
{
tool: key,
sessionID: input.sessionID,
callID: opts.toolCallId,
},
{
args,
},
)
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",
{
tool: key,
sessionID: input.sessionID,
callID: opts.toolCallId,
},
result,
)
return {
output,