Integrate Unleash with OpenCode
The Unleash MCP server connects OpenCode to your Unleash instance, enabling AI-assisted feature flag management. This page covers how to install and configure the server in OpenCode. To learn what the server can do, see Unleash MCP server.
OpenCode supports MCP across three interfaces:
- OpenCode TUI — The primary terminal-based interface
- OpenCode CLI — Non-interactive mode via
opencode runfor scripts and CI/CD - Desktop app — GUI alternative available for macOS, Windows, and Linux
OpenCode is model-neutral, supporting 75+ LLM providers through Models.dev, including Anthropic (Claude), OpenAI (GPT), Google (Gemini), xAI (Grok), and local models via Ollama.
Prerequisites
Before you begin, make sure you have the following:
- Node.js 24 or later: The MCP server is distributed as an npm package
- OpenCode: TUI, CLI, or desktop app installed
- An Unleash instance: Cloud or self-hosted, with API access enabled
- A personal access token (PAT): With permissions to create and manage feature flags
Install the MCP server
The Unleash MCP server runs as a local stdio process. The same configuration works across all OpenCode interfaces (TUI, CLI, and desktop app).
Create a credentials file
Store your Unleash credentials in a centralized file and source it from your shell profile:
Add to your ~/.zshrc or ~/.bashrc:
Restart your terminal or run source ~/.zshrc to load the variables.
To opt in to feedback reports, also add UNLEASH_MCP_SEND_FEEDBACK=true to ~/.unleash/mcp.env, export it from your shell profile, and reference it in opencode.json as "UNLEASH_MCP_SEND_FEEDBACK": "{env:UNLEASH_MCP_SEND_FEEDBACK}".
Tool namespacing: OpenCode prefixes MCP tool names with the server name.
The Unleash tools appear as unleash_search, unleash_release, unleash_inspect, and so on.
Configuration scopes:
Both are merged; project takes precedence on conflict. For team collaboration, use the project-level file.
OpenCode also supports {file:path} substitution as an alternative to {env:VAR}.
Create individual credential files (e.g., ~/.unleash/pat) containing only the value, then reference them with "UNLEASH_PAT": "{file:~/.unleash/pat}".
This is useful when credentials are managed by a secrets tool that writes individual files.
Tools and workflows
Once the server is connected, OpenCode can use every tool the Unleash MCP server exposes. To learn what the server can do and see step-by-step workflows, read Unleash MCP server. For the current list of tools, see the README on GitHub.
Feedback reports
To opt in to feedback reports, set UNLEASH_MCP_SEND_FEEDBACK to "true" in the environment block of opencode.json. OpenCode doesn’t show consent prompts, so feedback reports stay off until you set the variable. To learn more, see Clients without a consent prompt.
To hide the send_feedback tool from the assistant, set the variable to "false". To learn what a report contains, see What is recorded.
Enterprise governance
OpenCode Enterprise provides controls relevant to MCP server deployment in organizations.
- SSO integration — Central config integrates with your organization’s SSO provider. Enables credential access for internal AI gateways through existing identity systems. No separate OpenCode accounts needed.
- Private AI gateway — Restrict all AI provider access to internal infrastructure. Disable all external providers to ensure requests route through approved channels. Combined with the Unleash MCP server (which connects to your own Unleash instance), the entire stack operates within your network.
- Managed configuration — Non-overridable policies deployed via MDM on macOS (
.mobileconfigprofiles),/etc/opencode/on Linux, and%ProgramData%\opencodeon Windows. Managed config has the highest precedence in the configuration hierarchy, so individual developers cannot override these settings. - Agent permission restrictions — Enforce agent permission policies via managed config, such as requiring approval for every file change regardless of the developer’s local configuration.
- Disabled providers list — Restrict which LLM providers are available to developers. Useful for organizations that need to route all AI traffic through approved gateways.
For MCP server governance, commit opencode.json to version control. This ensures all team members use the same MCP servers with the same permission policies.
Use custom agents with "ask" permissions for write operations like release, kill_switch, and manage_flag. Read-only operations like search, inspect, and evaluate can safely use "allow".
Troubleshooting
MCP server not appearing in OpenCode
- Verify
opencode.jsonfor syntax errors - Check that the
mcpkey is at the top level of the JSON object - Confirm the
commandfield is an array of strings, not a single string - Run
opencode mcp listto check server status - Restart OpenCode after making changes
Environment variables not expanding
- OpenCode uses
{env:VAR}syntax (curly braces, no dollar sign prefix) - Restart your terminal after modifying your shell profile
- Verify variables are exported:
echo $UNLEASH_BASE_URL - Check that your shell profile sources
~/.unleash/mcp.envand exports the variables
Authentication failed
- Confirm your Unleash PAT is valid and has not expired
- Check that the PAT has permissions to create and manage feature flags
- Verify that
UNLEASH_BASE_URLdoes not include/apiat the end - Test directly:
curl -H "Authorization: $UNLEASH_PAT" "$UNLEASH_BASE_URL/api/admin/projects"
No envFile support
OpenCode does not support envFile like Cursor or VS Code. Use {env:VAR} substitution in the environment object and source credentials from your shell profile. Alternatively, use {file:path} substitution to read credentials from individual files. If you are migrating from Cursor, replace envFile references with {env:VAR} entries.
Command format errors
OpenCode’s MCP command field takes an array (["npx", "-y", "@unleash/mcp@latest"]), not a string with separate args like Cursor or Claude Code. This is a common migration mistake. Each argument must be a separate element in the array.
Node.js not found
Local servers using npx require Node.js 24+. Verify with node --version. If Node.js is installed but not found by OpenCode, check that OpenCode inherits your shell PATH.
Tool approval prompts
By default, agents with "ask" permissions request approval before executing MCP tools. Configure permissions in agent definitions or use managed config to set organization-wide defaults. The five built-in agents have their own permission presets (Build has full access, Plan and Explore are read-only).
Variable substitution confusion
OpenCode uses {env:VAR} (curly braces, no dollar sign). Claude Code uses ${VAR}. Cursor uses ${env:VAR}. Mixing formats between tools is a common error when teams use multiple AI assistants. Check that your opencode.json uses the correct syntax.
MCP context overhead
If you have many MCP servers configured, their tool descriptions may exceed the model’s context window. Use "enabled": false to disable servers you don’t need for the current project. Consider the context impact when adding multiple MCP servers.
Feedback is disabled
send_feedback returns this message until you opt in, because OpenCode doesn’t show consent prompts. To opt in, set UNLEASH_MCP_SEND_FEEDBACK to "true" in the environment block of opencode.json and restart OpenCode. Feedback settings don’t affect flag operations.