OpenCode
OpenCode is an open-source AI coding tool with first-class espctl support.
Configuration
Add to opencode.json in your project folder, or
~/.config/opencode/opencode.json to make espctl available everywhere:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"espctl": {
"type": "local",
"command": ["/path/to/espctl", "mcp", "serve"],
"enabled": true,
"environment": {
"CONTROL_BASE_URL": "https://esphome.cloud",
"MCP_AUTH_SECRET": "your-access-key"
}
}
}
}
Four things to notice compared to the JSON-based AI tools:
- The top-level key is
mcp, notmcpServers. commandis a single array with the program and all its arguments together, not a separatecommand+args.- The environment-variable key is
environment, notenv. typemust be"local"for a program launched on your computer (which espctl is).
The path/value rules are otherwise the same as in Claude Code.
Check it’s working
Restart OpenCode. In any chat:
What espctl tools can you call?
You should see the standard ~40-tool list. If not, OpenCode’s logs will
show the actual error — usually under ~/.local/share/opencode/logs/
on Linux or ~/Library/Logs/opencode/ on macOS.
OpenCode-specific notes
- OpenCode supports a per-server
cwdfield, at the same level ascommand:"espctl": { "type": "local", "command": ["/path/to/espctl", "mcp", "serve"], "cwd": "/path/to/your/esp-idf/project", "enabled": true, "environment": { ... } } - The
enabledflag lets you keep espctl in your config but turn it off temporarily without deleting the entry.
Tip
Ask OpenCode:
Read the
install://opencoderesource.
…and espctl will return a copy-paste-ready config block.