Connect OpenCode to Semlith
How to connect OpenCode to Semlith over MCP, the command or file that adds it, and how to check the connection works.
${SEMLITH_BIN} where the binary goes, the path which semlith prints. Set up your agent client explains it and the HTTP form.OpenCode — opencode.json in the project root, or the same file under
~/.config/opencode/. The root key is mcp, the HTTP transport is spelled
remote, and an entry is ignored until enabled is true. The installed CLI has
no global scope flag (opencode mcp add --help on 1.18.11 lists only --url,
--env and --header), so its registration lands in the project file and
semlith does not run it. OpenCode v2’s documentation adds --global
(https://opencode.ai/v2/docs/mcp-servers); once your build accepts it,
opencode mcp add semlith --global -- semlith mcp is the form to use. Until
then the user-level file below covers every project, and semlith setup --register-all writes it. The path is the same on Windows,
%USERPROFILE%\.config\opencode\opencode.json (not %APPDATA%), and an
existing opencode.jsonc there is read in its place.
{
"mcp": {
"semlith": {
"type": "local",
"command": ["${SEMLITH_BIN}", "mcp"],
"enabled": true
}
}
}OpenCode reads a user-level AGENTS.md. semlith setup --register-all appends
the rule block to it between markers of its own, backing the file up first.
Nothing outside the markers is touched, and a second run replaces what is
between them.
${SEMLITH_RULES}Or against a daemon on another machine, over HTTP:
{
"mcp": {
"semlith": {
"type": "remote",
"url": "http://127.0.0.1:7365/mcp",
"enabled": true,
"headers": { "Authorization": "Bearer ${SEMLITH_AGENT_KEY}" }
}
}
}opencode mcp add semlith -- "${SEMLITH_BIN}" mcp