anomalyco / anomalyco/opencode
mcp: local tool calls return result: null, response text goes to Logs instead
@nexxeln is already working on this.
Since Sep 14, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
Summary
MCP local server tools return result: null in the execute runtime; the actual response text is emitted to Logs instead of being available as the tool result. All 42 tools from the same MCP server exhibit the identical behavior.
Environment
- opencode version: 2.0.3
- OS: Windows_NT 10.0.26200 (MINGW64_NT-10.0-26200, win32 x64)
- Terminal: xterm-256color (MINGW64 / Git Bash)
- Shell: /usr/bin/bash (Git Bash), COMSPEC: C:\WINDOWS\system32\cmd.exe
- Install/channel: npm global, latest
- Active plugins: none (all disabled in config)
- MCP server: @cocaxcode/api-testing-mcp@0.13.4 (local, via npx)
- MCP SDK (server side): @modelcontextprotocol/sdk@1.29.0
Reproduction
- Configure a local MCP server in opencode.jsonc:
"api-testing": {
"type": "local",
"command": ["npx", "-y", "@cocaxcode/api-testing-mcp@latest"],
"enabled": true
} - Start opencode, open a session.
- In a tools code block, call any MCP tool, e.g.:
const result = await tools["api-testing"].env_list();
console.log(result); // null - Observe the output:
result: null
Logs: [ { "name": "local_dev", ... } ]
Expected Behavior
result should contain the parsed tool response (the array of environments), matching what the MCP server returns:
{ "content": [{ "type": "text", "text": "[{ "name": "local_dev", ... }]" }] }
The content[0].text value should be parsed and returned as the tool result, not logged separately.
Actual Behavior
Every MCP tool call returns result: null. The actual response text appears under a Logs: heading in the output. This is consistent across all 42 tools from the api-testing MCP server.
Sample output:
null
Logs:
[
{
"name": "local_dev",
"active": true,
"default": true,
"group": "rh-front",
"variableCount": 2,
"spec": "rh-remote-v3"
}
]
The MCP server's response format is correct per the MCP protocol — the issue is on the OpenCode client side, which fails to pass content[0].text through as the tool return value.
Additional Context
- The MCP server logs show mcp connected server=api-testing tools=42 — connection and tool registration succeed.
- No errors in ~/.local/share/opencode/log/opencode.log related to MCP.
- All 42 tools (env_list, api_spec_list, api_import, collection_list, etc.) exhibit the same result: null behavior.
- Tool validation errors (wrong argument names/types) DO return proper error messages — only successful calls produce null.
- The MCP server uses @modelcontextprotocol/sdk@1.29.0; OpenCode's bundled MCP client version is unknown but should be compatible.
- Config: opencode.jsonc with "type": "local" MCP, shell "sh", "lsp": false.
Plugins
No response
OpenCode version
v2.0.3
Steps to reproduce
No response
Screenshot and/or share link
No response
Operating System
No response
Terminal
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.