Connect OpenCode
Connect OpenCode to Krutrim Cloud using local MCP tools and a private API key.
Connect OpenCode to Krutrim Cloud through a local MCP server. OpenCode launches the server and adds its Cloud tools alongside the tools already available to your agent.
This guide covers local stdio. For the hosted setup and supported client examples, start with Hosted MCP.
Before you begin
Install OpenCode and make sure
uvxis available in the environment that launches it.Complete the package installation and API-key setup in Local MCP (stdio) before using the local configuration below.
Set
KRUTRIM_API_KEYprivately in the environment used to start OpenCode. Use the raw API key, without aBearerprefix or surrounding spaces.
Connect with local stdio
Open the OpenCode configuration
Open ~/.config/opencode/opencode.json for a global user configuration. OpenCode also supports JSONC. Merge the example with existing settings; do not overwrite your other MCP servers.
OpenCode merges configuration from multiple locations. Project or managed settings can override a value, so check the effective scope if this server is configured elsewhere.
Add the local MCP server
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"krutrim-cloud": {
"type": "local",
"command": [
"uvx",
"krutrim-mcp-server"
],
"enabled": true,
"environment": {
"KRUTRIM_API_KEY": "{env:KRUTRIM_API_KEY}"
}
}
}
}OpenCode uses mcp, a command array, and environment—not the mcpServers / env shape used by some other clients.
The
{env:KRUTRIM_API_KEY}reference reads the key from OpenCode’s launch environment. If the variable is unset, it becomes an empty string. Keep the real key out of repository configuration and restart OpenCode after key changes.
Next steps
Before changing Cloud resources, follow the safety guidance in the MCP Overview. Start with a read-only request and review the exact region and resource identifiers.
Need help? Open Troubleshooting for startup, API-key, and tool-discovery checks.
Official references
Last updated
Was this helpful?

