Skip to navigation

Integrate Unleash with OpenCode

View as Markdown

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 run for 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).

1

Create a credentials file

Store your Unleash credentials in a centralized file and source it from your shell profile:

mkdir -p ~/.unleash
cat > ~/.unleash/mcp.env << 'EOF'
UNLEASH_BASE_URL=https://your-instance.getunleash.io
UNLEASH_PAT=your-personal-access-token
EOF
chmod 600 ~/.unleash/mcp.env

Add to your ~/.zshrc or ~/.bashrc:

# Unleash MCP credentials
if [ -f ~/.unleash/mcp.env ]; then
source ~/.unleash/mcp.env
export UNLEASH_BASE_URL UNLEASH_PAT
fi

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}".

VariableDescriptionRequired
UNLEASH_BASE_URLYour Unleash instance URL.Yes
UNLEASH_PATA personal access token with flag creation permissions.Yes
UNLEASH_MCP_SEND_FEEDBACKSet to true to opt in to feedback reports. With false, the assistant doesn’t see the send_feedback tool.No
2

Create the configuration file

Create opencode.json at your project root:

opencode.json
{
"mcp": {
"unleash": {
"type": "local",
"command": ["npx", "-y", "@unleash/mcp@latest"],
"environment": {
"UNLEASH_BASE_URL": "{env:UNLEASH_BASE_URL}",
"UNLEASH_PAT": "{env:UNLEASH_PAT}"
}
}
}
}

This file contains no credentials, only variable references that expand at runtime. You can safely commit it to version control.

3

Verify the installation

Run the MCP list command to confirm the server is connected:

opencode mcp list

The output should show unleash: connected.

Within an agent session, ask: “What Unleash MCP tools are available?” The agent lists all available tools.

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:

LocationScopeUse case
opencode.json (project root)ProjectTeam-shared, version controlled
~/.config/opencode/opencode.jsonGlobalPersonal settings across all projects

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 (.mobileconfig profiles), /etc/opencode/ on Linux, and %ProgramData%\opencode on 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

  • Verify opencode.json for syntax errors
  • Check that the mcp key is at the top level of the JSON object
  • Confirm the command field is an array of strings, not a single string
  • Run opencode mcp list to check server status
  • Restart OpenCode after making changes
  • 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.env and exports the variables
  • 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_URL does not include /api at the end
  • Test directly: curl -H "Authorization: $UNLEASH_PAT" "$UNLEASH_BASE_URL/api/admin/projects"

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.

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.

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.

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).

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.

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.

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.