Skip to main content
OpenCode reads MCP servers from the mcp section of its config file, opencode.json.

Global or per project?


Add the server

OpenCode can read the key from an environment variable, so the key never lands in the config file. Export it in your shell profile:
Then add the server:
opencode.json
{env:EXTRACT_API_KEY} is replaced with the value of the variable when OpenCode starts. Already have servers configured? Add 2extract as another key inside the existing mcp object.
Because the key comes from the environment, a project-level opencode.json with this config is safe to commit. Each teammate exports their own key.

Verify

Start OpenCode and ask:
What is my 2extract balance?
A number comes back, and no proxy was created.

Troubleshooting

Check that type is remote, enabled is true, and the URL keeps the /mcp path. Then restart OpenCode - the config is read at startup.
The variable must be set in the shell that starts OpenCode. Run echo $EXTRACT_API_KEY there; an empty line means OpenCode sends Bearer with no key. The variable holds the bare key (2xt_...) - the config adds Bearer.
A scope problem rather than a connection problem. The key is missing the scope those tools need - see Overview.

Next steps

Tools

Everything the agent can call.

Other clients

Any other MCP client.