OpenCode reads MCP servers fromDocumentation Index
Fetch the complete documentation index at: https://docs.sharc.sh/llms.txt
Use this file to discover all available pages before exploring further.
opencode.json. The interactive opencode mcp add command can’t set environment variables, so we recommend editing the config file directly — it’s a single 6-line block.
Install
Open your OpenCode config file:- macOS / Linux:
~/.config/opencode/opencode.json - Windows:
%USERPROFILE%\.config\opencode\opencode.json
sharc entry under mcp:
opencode.json already exists, just add the sharc block inside the mcp object — keep your other entries.
Verify
sharc with a ✓ connected status.
From inside OpenCode, ask:
index_codebase, search_code, clear_index, get_indexing_status, start_watch, stop_watch, get_watch_status).
Keep the API key out of config (optional)
OpenCode supports{env:VAR} substitution. Set SHARC_API_KEY in your shell environment and reference it instead of pasting the literal key:
Troubleshooting
MCP error -32000: Connection closed
If opencode mcp list shows sharc as failed:
- Confirm the
environmentblock exists andSHARC_API_KEYis set - Confirm
npxis on your PATH:npx --version - Check OpenCode logs:
opencode --log-level DEBUG