anomalyco / anomalyco/opencode
MCP local server config: 'connection closed' / 'Ignoring MCP config entry without type' with command string + args + env fields
@jlongster is already working on this.
Since Aug 8, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Summary
Configuring a local stdio MCP server in opencode.jsonc the way it's documented in most MCP server READMEs (e.g. @datalens-tech/mcp) fails in OpenCode 1.18.14/1.18.15. Several different misleading errors appear depending on the exact shape of the config entry.
What I expected
Standard MCP server README config (from datalens-tech/datalens-mcp README):
{
"mcp": {
"datalens": {
"type": "stdio",
"command": "npx",
"args": ["-y", "@datalens-tech/mcp@latest"],
"env": {
"DATALENS_ORG_ID": "<org-id>"
}
}
}
}
I expected this to be accepted (or at least a clear error message pointing at the correct schema).
What actually happened
None of the error messages point at the real fix. Observed errors in sequence:
- With
"type": "stdio"+command: "npx"+args+env:
Configuration is invalid at .../opencode.jsonc
Expected { readonly "type": "local", ... } | { readonly "type": "remote", ... }, got {...} mcp.datalens
Missing key mcp.datalens.enabled
- With
"type": "local","enabled": true,commandas array,env:
● ✗ datalens failed
MCP error -32000: Connection closed
- With
"type": "local","enabled": true,commandas string +args:
▲ No MCP servers configured
and in logs:
message="Ignoring MCP config entry without type" key=datalens
Root cause / working config
OpenCode's actual schema (documented at https://opencode.ai/docs/mcp-servers/) differs from the generic MCP READMEs:
commandmust be an array (["npx", "-y", "..."]), not a string with a separateargsfield- environment variables go under
environment, notenv "type": "local"(notstdio)timeoutis helpful sincenpxfirst fetch can exceed the default 5000ms
Working config:
"mcp": {
"datalens": {
"type": "local",
"command": ["npx", "-y", "@datalens-tech/mcp@latest"],
"environment": {
"DATALENS_ORG_ID": "<org-id>"
},
"enabled": true,
"timeout": 30000
}
}
After this, opencode mcp list shows datalens connected and list_commands works.
Suggested improvements
- Validate config with a clear message instead of the misleading
"Ignoring MCP config entry without type"whencommandis a string. - Accept the common README shape (
commandstring +args) or auto-coerce it, since it's the de-facto standard in MCP server docs. - Emit a deprecation/helper message when
envkey is used instead ofenvironment.
Environment
- OpenCode 1.18.15 (Debian package, TUI)
- Linux, x86_64
- Config path:
~/.config/opencode/opencode.jsonc
Reported by: Igor Golov (igor.programmer@gmail.com)
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.