OpenCode
Connect OpenCode to Ternary by adding Ternary as a remote MCP server and authenticating through OAuth.
Before you start
You need:
- An existing Ternary account
- Access to at least one Ternary tenant
- OpenCode installed and configured
Step 1: Add Ternary
OpenCode reads MCP servers from an opencode.json file.
Use one of these locations:
- Every project:
~/.config/opencode/opencode.jsonin your home folder - This project only:
opencode.jsonin the project folder
Open that file in a text editor. If it does not exist yet, create it.
If the file already has other settings, add the "ternary" block inside "mcp". Do not replace the rest of the file.
Paste the configuration for the region where your Ternary tenant is hosted:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"ternary": {
"type": "remote",
"url": "https://core-api.ternary.app/mcp",
"oauth": {
"clientId": "https://core-api.ternary.app/oauth/client-metadata.json"
}
}
}
}{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"ternary": {
"type": "remote",
"url": "https://core-api.eu.ternary.app/mcp",
"oauth": {
"clientId": "https://core-api.ternary.app/oauth/client-metadata.json"
}
}
}
}Save the file. The client ID stays the same for US and EU. Do not add a client secret.
Step 2: Authenticate
Open a terminal. Paste this command and press Enter:
opencode mcp auth ternaryRun this in your shell, not as a message inside an OpenCode session. If OpenCode is already open, use a separate terminal window.
OpenCode starts the Ternary browser sign-in flow.
- Sign in with your existing Ternary account.
- Approve access.
- Return to the terminal.
If the browser does not open, run the same command again. You can also start OpenCode and authenticate from /mcps.
To confirm Ternary is connected, run:
opencode mcp listternary should appear and show as authenticated.
Step 3: Ask a question
Try:
Using Ternary, show last month's spend by provider.
Which budgets need attention?
List recent cost alerts.
Troubleshooting
Authentication fails with Unknown client
Check that both the server URL and client ID match the values above exactly.
The server URL must not have a trailing slash.
Sign-in fails
Make sure your Ternary account exists in the region selected by the MCP server URL.
No tenants appear
Ask your Ternary administrator to confirm that your user has an explicit tenant role.
See Troubleshooting Ternary MCP for shared issues.
Updated about 5 hours ago
