-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Description
Bug
All external MCP tools crash with TypeError: undefined is not an object (evaluating 'output.output.toLowerCase') since v3.5.0 (and v3.4.1 before it was yanked). Built-in tools (bash, read, write, grep) are unaffected.
Root Cause
Three tool.execute.after hooks access output.output without null/type guards:
| File | Line | Code |
|---|---|---|
src/hooks/comment-checker/hook.ts |
L95 | const outputLower = output.output.toLowerCase() |
src/hooks/edit-error-recovery/hook.ts |
L47 | const outputLower = output.output.toLowerCase() |
src/hooks/task-resume-info/hook.ts |
L24-31 | output.output.startsWith(), .includes(), .trimEnd() |
All three hooks declare output as { title: string; output: string; metadata: unknown }, but for MCP tool results, output.output is undefined.
Contributing upstream factor: AI SDK v6.0.74 changed tool result structure from {output, metadata, title} to {type, value} via createToolModelOutput() in stream-text.ts. This means output.output is now always undefined for MCP tools. See anomalyco/opencode#13042, anomalyco/opencode#12987.
Why v3.5.0 and v3.5.1 still have this
v3.4.1 was yanked for this exact issue, but the hook source code was never patched. v3.5.0 and v3.5.1 shipped with the same unguarded calls.
Workaround
"disabled_hooks": ["comment-checker"]Or downgrade to v3.4.0 with "auto_update": false.
Suggested Fix
Add null/type guard at the top of each tool.execute.after handler:
if (!output.output || typeof output.output !== "string") returnThis single line in each of the three hooks would prevent the crash.
Related
- TypeError: output.output.toLowerCase() crashes on MCP tools with undefined output #1737 (same TypeError report)
- FYI: v3.4.1 broke all external MCP tools (published & yanked) #1720 (v3.4.1 broke all external MCP tools)
- PR fix: guard against undefined output.output in tool.execute.after hooks #1735 (community fix attempt)
- MCP tools crash: TypeError on value.output.output in processor.ts (AI SDK 6.0.74 breaking change) anomalyco/opencode#13042 (upstream AI SDK breaking change)
- Kubernetes MCP server tools fail with TypeError: output.output.toLowerCase anomalyco/opencode#12987 (upstream duplicate)
Affected Versions
- v3.4.1 (yanked)
- v3.5.0
- v3.5.1