For AI agents: a documentation index is available at the root level at /llms.txt and /llms-full.txt. Append /llms.txt to any URL for a page-level index, or .md for the markdown version of any page.
13.5kProductPricingSign inStart free trialBook a demo
DocsAPIsSDKsEnterprise EdgeGuidesAcademyRelease notes
DocsAPIsSDKsEnterprise EdgeGuidesAcademyRelease notes
    • Home
  • Get started
    • Quickstart
    • Introduction to feature flags
    • Unleash architecture overview
  • Core concepts
    • Overview
    • Import and export
      • Unleash hosting options
        • MCP server
        • GitHub Copilot
        • Claude Code
        • Kiro
        • Cursor
        • OpenCode
      • Developer Toolbar

Unleash reduces the risk of releasing new features, drives innovation by streamlining the software release process, and increases revenue by optimizing end-user experience. While we serve the needs of the world's largest, most security-conscious organizations, we are also rated the “Easiest Feature Management system to use” by G2.

GitHubGitHubLinkedInLinkedInX (Twitter)X (Twitter)SlackSlackStack OverflowStack OverflowYouTubeYouTube

Server SDKs

  • Node.js
  • Java
  • Go
  • Rust
  • Ruby
  • Python
  • .NET
  • PHP
  • All SDKs

Frontend SDKs

  • JavaScript
  • React
  • Next.js
  • Vue
  • iOS
  • Android
  • Flutter

Feature Flag use cases

  • Secure, scalable feature flags
  • Rollbacks
  • FedRAMP, SOC2, ISO2700 compliance
  • Progressive or gradual rollouts
  • Trunk-based development
  • Software kill switches
  • A/B testing
  • Feature management
  • Canary releases

Product

  • Quickstart
  • Unleash architecture
  • Pricing
  • Product vision
  • Open live demo
  • Open source
  • Enterprise feature management platform
  • Unleash vs LaunchDarkly

Support

  • Help center
  • Status
  • Changelog
Made in a cosy atmosphere in the Nordic countries.Copyright © 2026 Unleash
LogoLogo
13.5kProductPricingSign inStart free trialBook a demo
On this page
  • Prerequisites
  • Install the MCP server
  • Tool reference
  • Workflows
  • Evaluate and wrap code in feature flags
  • Agent-guided flag evaluation
  • Manage rollouts across environments
  • Clean up after rollout
  • Discover and audit flags
  • AGENTS.md templates
  • Standard AGENTS.md with FeatureOps policies
  • Domain-specific instructions via opencode.json
  • Custom agent definitions
  • FeatureOps agent
  • Flag reviewer agent
  • Skill and command definitions
  • evaluate-and-flag skill
  • cleanup-flag skill
  • evaluate-flag command
  • Team distribution
  • Prompt patterns
  • Enterprise governance
  • Troubleshooting
  • Best practices
  • Related resources
Integrate and deployAI coding assistants

Integrate Unleash with OpenCode

||View as Markdown|
Was this page helpful?

Last updated May 26, 2026

Previous

Developer Toolbar

Next
Built with

The Unleash MCP server connects OpenCode to your Unleash instance, enabling AI-assisted feature flag management. You can evaluate code changes, create flags, generate wrapping code, manage rollouts, and clean up flags from within OpenCode’s terminal-first development environment.

OpenCode supports MCP across three interfaces:

  • OpenCode TUI — The primary terminal-based interface with custom agents, skills, and commands
  • 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. When developers can switch providers between sessions, governance cannot live in the model. It must live in the tools. Custom agents with fine-grained permission controls are the primary governance mechanism, ensuring consistent FeatureOps behavior regardless of which model writes the code.

Prerequisites

Before you begin, make sure you have the following:

  • Node.js 18 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
$UNLEASH_DEFAULT_PROJECT=default
$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 UNLEASH_DEFAULT_PROJECT
$fi

Restart your terminal or run source ~/.zshrc to load the variables.

VariableDescriptionRequired
UNLEASH_BASE_URLYour Unleash instance URL.Yes
UNLEASH_PATA personal access token with flag creation permissions.Yes
UNLEASH_DEFAULT_PROJECTThe default project for flag operations. If omitted, you must specify projectId in each tool call.No
2

Create the configuration file

Create opencode.json at your project root:

opencode.json
1{
2 "mcp": {
3 "unleash": {
4 "type": "local",
5 "command": ["npx", "-y", "@unleash/mcp@latest", "--log-level", "error"],
6 "environment": {
7 "UNLEASH_BASE_URL": "{env:UNLEASH_BASE_URL}",
8 "UNLEASH_PAT": "{env:UNLEASH_PAT}",
9 "UNLEASH_DEFAULT_PROJECT": "{env:UNLEASH_DEFAULT_PROJECT}"
10 }
11 }
12 }
13}

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_evaluate_change, unleash_create_flag, unleash_get_flag_state, 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.

Tool reference

The Unleash MCP server exposes several tools. The following table summarizes each tool and when to use it.

ToolDescriptionWhen to use
evaluate_changeAnalyzes a code change and determines whether it should be behind a feature flag.Before implementing risky changes
detect_flagSearches for existing flags that match a description to prevent duplicates.Before creating new flags
create_flagCreates a new feature flag with proper naming, typing, and metadata.When no suitable flag exists
wrap_changeGenerates framework-specific code to guard a feature behind a flag.After creating a flag
list_projectsLists Unleash projects available to the configured token, with optional pagination.Discovering available projects
list_flagsLists feature flags in a project (active by default; set archived=true for archived flags).Auditing flag inventory; discovering existing flags before creating new ones
get_flag_stateReturns the current state, strategies, and metadata for a flag.Debugging, status checks
set_flag_rolloutConfigures rollout percentages and activation strategies.Gradual releases
toggle_flag_environmentEnables or disables a flag in a specific environment.Testing, staged rollouts
remove_flag_strategyDeletes a rollout strategy from a flag.Simplifying flag configuration
cleanup_flagReturns file locations and instructions for removing a flag after rollout.After full rollout

Workflows

The Unleash MCP server supports these core workflows: evaluate and wrap code in feature flags, discover and audit flags, manage rollouts across environments, and clean up after rollout. OpenCode adds a fifth workflow unique to its architecture: agent-guided flag evaluation.

Evaluate and wrap code in feature flags

Use this workflow when implementing a change that might affect production stability, such as a payment integration, authentication flow, or external API call.

1

Evaluate the change

Tell the agent what you are working on:

Evaluate whether the Stripe payment integration should be behind a feature flag.
The change modifies the checkout service and handles credit card processing.

The agent calls evaluate_change and returns a recommendation with a suggested flag name.

2

Check for duplicates

The agent automatically calls detect_flag to search for existing flags. If a suitable flag exists, the agent suggests reusing it instead of creating a duplicate.

3

Create the flag

If no suitable flag exists:

Create a release flag for the Stripe payment integration.

The agent calls create_flag with the appropriate name, type, and description. The flag is created in Unleash, disabled by default.

4

Wrap the code

Generate framework-specific guard code:

Wrap the Stripe checkout handler with the stripe-payment-integration flag.
This is a Node.js Express application.

The agent calls wrap_change and returns code like this:

checkout.js
1const { isEnabled } = require('unleash-client');
2
3app.post('/checkout', async (req, res) => {
4 const context = { userId: req.user.id };
5
6 if (isEnabled('stripe-payment-integration', context)) {
7 // New Stripe payment flow
8 const result = await stripeService.processPayment(req.body);
9 return res.json(result);
10 } else {
11 // Existing payment flow
12 const result = await legacyPaymentService.process(req.body);
13 return res.json(result);
14 }
15});

Agent-guided flag evaluation

Use this workflow to automate flag evaluation using a custom FeatureOps agent with permission controls. The agent evaluates risk without the developer explicitly asking, and its behavior is identical regardless of which model is selected.

1

Define a FeatureOps agent

Create a custom agent with a system prompt encoding your team’s policies (see custom agent definitions below for a complete example). The agent’s prompt instructs it to always call evaluate_change before writing implementation code.

2

Switch to the FeatureOps agent

Press Tab in the TUI to switch agents, or start a new session with --agent featureops. The agent’s system prompt loads into context and guides every interaction.

3

Create and wrap in one flow

Describe your change. The agent calls evaluate_change, detect_flag, create_flag, and wrap_change as part of the same implementation. Because the agent’s permission is set to "ask" for edit operations, you approve each modification before it takes effect.

Agent-guided evaluation catches risk during implementation rather than during code review. The flag becomes part of the development flow, not an afterthought. Because agents are model-independent, the same governance applies whether the developer uses Claude, GPT, Gemini, or a local model.

Manage rollouts across environments

Use this workflow to enable a flag in staging for testing while keeping it disabled in production.

Check flag state
Enable in staging
Configure rollout
What is the current state and rollout strategies for stripe-payment-integration?

The agent calls get_flag_state and returns the flag metadata, enabled environments, and active strategies.

AI assistants can make mistakes and toggle the wrong flag. Enable change requests on production environments to require human approval before changes take effect. See the MCP server documentation for details.

Clean up after rollout

Use this workflow when a feature has been fully rolled out and the flag is no longer needed.

Clean up the stripe-payment-integration flag. The feature is fully rolled out.

The agent calls cleanup_flag and returns:

  • All files and line numbers where the flag is used
  • Which code path to preserve (the “enabled” branch)
  • Suggestions for tests to run after removal

Review the list, remove the conditional branches, and delete the flag from Unleash.

Feature flags should be temporary. Regularly clean up flags after successful rollouts to prevent technical debt.

Discover and audit flags

Use this workflow to take inventory of existing flags before creating new ones, or to run a periodic audit for cleanup candidates.

1

List available projects (optional)

If you don’t already know the target project, the agent calls list_projects to enumerate projects the configured token can access. Skip this step if UNLEASH_DEFAULT_PROJECT is set.

2

List active flags

The agent calls list_flags with the target projectId. The default response returns active (non-archived) flags only.

3

List archived flags

For a full audit, the agent calls list_flags a second time with archived=true. Active and archived flags are disjoint result sets in Unleash; both calls are needed for complete inventory.

4

Cross-reference with the codebase

The agent compares the returned flags against references in your code. Flags present in Unleash but unused in code (especially archived ones) are cleanup candidates — chain into the Clean up after rollout workflow to remove them safely.

AGENTS.md templates

OpenCode uses AGENTS.md files for project-level instructions, similar to Cursor Rules or Claude Code’s CLAUDE.md. Store your FeatureOps policies in AGENTS.md so the agent considers feature flags automatically in every session.

For more details on project instructions, see the OpenCode rules documentation.

Standard AGENTS.md with FeatureOps policies

This file loads into every agent session. Use it for organization-wide flag standards.

AGENTS.md
1# Project Instructions
2
3## Feature Flag Conventions
4
5When making changes to this codebase, follow these feature flag practices:
6
71. **Always evaluate risk** – Before implementing high-risk changes (payments,
8 authentication, data migrations, external integrations), use the Unleash MCP
9 server to evaluate whether a feature flag is needed.
10
112. **Naming conventions** – Use the format `{domain}-{feature}-{variant}`.
12 Examples: `checkout-stripe-integration`, `auth-sso-google`, `api-rate-limiting`.
13
143. **Flag types**:
15 - `release` – For gradual feature rollouts
16 - `experiment` – For A/B tests and experiments
17 - `operational` – For system behavior toggles
18 - `kill-switch` – For emergency shutdowns
19 - `permission` – For role-based access
20
214. **Prefer reuse** – Before creating a new flag, check if a similar flag already
22 exists using the detect_flag tool.
23
245. **Clean up after rollout** – Once a feature is fully released (100% rollout for
25 2+ weeks), use cleanup_flag to remove dead code.
26
27## Unleash MCP Server
28
29This project uses the Unleash MCP server for feature flag management. Configuration
30is in `opencode.json`. Credentials are sourced from environment variables.
31
32Available tools: evaluate_change, detect_flag, create_flag, wrap_change,
33list_projects, list_flags, get_flag_state, set_flag_rollout,
34toggle_flag_environment, remove_flag_strategy, cleanup_flag.

Domain-specific instructions via opencode.json

Create additional instruction files for high-risk domains and load them via the instructions field in opencode.json. This field supports glob patterns and remote URLs.

opencode.json
1{
2 "instructions": ["AGENTS.md", "docs/featureops-policy.md", "docs/domain-policies/*.md"],
3 "mcp": {
4 "unleash": {
5 "type": "local",
6 "command": ["npx", "-y", "@unleash/mcp@latest", "--log-level", "error"],
7 "environment": {
8 "UNLEASH_BASE_URL": "{env:UNLEASH_BASE_URL}",
9 "UNLEASH_PAT": "{env:UNLEASH_PAT}",
10 "UNLEASH_DEFAULT_PROJECT": "{env:UNLEASH_DEFAULT_PROJECT}"
11 }
12 }
13 }
14}
docs/domain-policies/payments.md
1# Payments Domain — Feature Flag Policy
2
3All changes in the payments domain require feature flags. No exceptions.
4
5- Use `kill-switch` type for external payment provider integrations
6 (Stripe, PayPal, etc.)
7- Use `release` type for internal payment logic changes
8- Naming: `payments-{feature}-{variant}`
9 (e.g., `payments-stripe-checkout`, `payments-refund-v2`)
10- Always include a fallback path for external provider calls
11- Evaluate risk with evaluate_change before writing implementation code

Custom agent definitions

Custom agents are OpenCode’s primary governance mechanism. Each agent has a mode, a system prompt, and fine-grained permission controls that gate what the agent can do. Permissions support three levels per tool: ask (prompt for approval), allow (execute without prompting), and deny (block entirely).

For more details on agents, see the OpenCode agents documentation.

Agents can be defined in two formats: JSON in opencode.json or as markdown files in .opencode/agents/.

FeatureOps agent

A primary agent with a custom prompt that always evaluates changes for feature flags. Edit operations require approval; destructive bash commands are blocked.

JSON format
Markdown format
opencode.json (agent section)
1{
2 "agent": {
3 "featureops": {
4 "description": "Feature flag management with Unleash governance policies",
5 "mode": "primary",
6 "prompt": "{file:.opencode/agents/featureops-prompt.md}",
7 "permission": {
8 "read": "allow",
9 "edit": "ask",
10 "bash": {
11 "*": "deny",
12 "npx @unleash/mcp*": "allow",
13 "npm test*": "allow",
14 "git status": "allow",
15 "git diff*": "allow"
16 },
17 "glob": "allow",
18 "grep": "allow",
19 "skill": "allow"
20 }
21 }
22 }
23}
.opencode/agents/featureops-prompt.md
1You are a FeatureOps agent. Your job is to evaluate code changes for risk and
2manage feature flags using the Unleash MCP server.
3
4## Workflow
5
61. When the developer describes a change, always call evaluate_change first
72. If a flag is needed, call detect_flag to check for duplicates
83. Only create a new flag if no suitable existing flag is found
94. Use wrap_change to generate framework-specific guard code
105. Suggest a rollout strategy based on the change's risk level
11
12## Naming Convention
13
14Use the format {domain}-{feature}-{variant}. Examples:
15- checkout-stripe-integration
16- auth-sso-google
17- api-rate-limiting
18
19## Flag Types
20
21- release: Gradual feature rollouts
22- experiment: A/B tests
23- operational: System behavior toggles
24- kill-switch: Emergency shutdowns
25- permission: Role-based access

Flag reviewer agent

A read-only subagent that evaluates code changes for feature flag compliance without creating or modifying anything.

.opencode/agents/flag-reviewer.md
1---
2description: Reviews code changes for feature flag compliance
3mode: subagent
4temperature: 0.1
5permission:
6 read: allow
7 edit: deny
8 bash: deny
9 glob: allow
10 grep: allow
11---
12You are a feature flag reviewer. Analyze code changes and determine:
13
141. Whether the changes should be behind a feature flag (use evaluate_change)
152. Whether existing flags are being used correctly (use get_flag_state)
163. Whether any flags should be cleaned up (use cleanup_flag for analysis only)
17
18Do NOT create or modify flags. Report findings and recommendations.

Skill and command definitions

Skills and commands package reusable workflows and common operations. Skills define multi-step processes that agents invoke automatically. Commands define prompt templates that developers invoke with /command-name in the TUI.

evaluate-and-flag skill

.opencode/skills/evaluate-and-flag/SKILL.md
1---
2name: evaluate-and-flag
3description: Evaluate whether current code changes need a feature flag, then
4 create and wrap the flag if needed. Handles duplicate detection, naming
5 conventions, and framework-specific wrapping.
6---
7
8## What I do
9
10Evaluate the current code changes for risk and create a feature flag if needed.
11
12## Steps
13
141. **Evaluate risk** – Call evaluate_change with a description of the current
15 changes. Include the component, service, and risk factors.
16
172. **Check for duplicates** – If a flag is needed, call detect_flag to check for
18 existing similar flags. Present matches to the developer.
19
203. **Create the flag** – If no suitable flag exists, call create_flag with:
21 - Name following {domain}-{feature}-{variant} convention
22 - Appropriate type (release, experiment, operational, kill-switch, permission)
23 - Clear description
24
254. **Wrap the code** – Call wrap_change to generate framework-specific guard code.
26 Insert the code at the appropriate location.
27
285. **Suggest rollout** – Recommend a rollout strategy:
29 - Low risk: Enable immediately in staging, 50% in production
30 - Medium risk: 10% then 50% then 100% over 48 hours
31 - High risk: 10% then 25% then 50% then 100% over one week with error monitoring
32
33## When to skip
34
35- CSS-only changes
36- Documentation updates
37- Test file changes
38- Dependency version bumps (unless major versions)

cleanup-flag skill

.opencode/skills/cleanup-flag/SKILL.md
1---
2name: cleanup-flag
3description: Safely remove a feature flag after successful rollout. Handles code
4 removal, test validation, and cleanup recommendations.
5---
6
7## What I do
8
9Remove a feature flag and its associated conditional code after a feature has
10been fully rolled out.
11
12## Steps
13
141. **Verify rollout status** – Call get_flag_state to confirm the flag is at
15 100% rollout and has been stable.
16
172. **Get cleanup instructions** – Call cleanup_flag to get:
18 - File locations where the flag is used
19 - Which code path to preserve (usually "enabled")
20 - Tests to run after cleanup
21
223. **Remove conditional code** – Remove the feature flag check, keeping only
23 the enabled code path. Remove unused imports and dead code.
24
254. **Run tests** – Execute the project's test suite to verify nothing breaks.
26
275. **Recommend flag deletion** – After code changes are merged, recommend
28 deleting the flag from Unleash via the Admin UI or API.
29
30## Safety checks
31
32- Confirm all code is committed before making changes
33- Create a snapshot before cleanup
34- Run tests after cleanup
35- Do not delete the flag from Unleash until code changes are merged

evaluate-flag command

.opencode/commands/evaluate-flag.md
1---
2description: Evaluate whether changes need a feature flag
3agent: featureops
4---
5Evaluate whether the following changes should be behind a feature flag using
6the Unleash MCP server.
7
8Focus on: $ARGUMENTS
9
10Steps:
111. Call evaluate_change with the description
122. If a flag is needed, call detect_flag to check for duplicates
133. If no suitable flag exists, suggest a name and type
144. Ask for approval before creating the flag

Usage: /evaluate-flag Stripe payment integration in the checkout service

Team distribution

Commit the .opencode/ directory to version control so the entire team shares the same agents, skills, and commands:

.opencode/
├── agents/
│ ├── featureops.md
│ ├── featureops-prompt.md
│ └── flag-reviewer.md
├── skills/
│ ├── evaluate-and-flag/
│ │ └── SKILL.md
│ └── cleanup-flag/
│ └── SKILL.md
└── commands/
├── evaluate-flag.md
└── cleanup-flag.md

Prompt patterns

The following prompt patterns help you use the MCP tools effectively.

Evaluate and create a flag

Intent: Determine if a change requires a feature flag, then create and wrap it.

Prompt:

Evaluate whether the [description of change] should be behind a feature flag.
The change modifies [component/service].

Expected behavior: The agent calls evaluate_change, then detect_flag, create_flag, and wrap_change as needed.

Detect and reuse existing flags

Intent: Avoid duplicate flags when similar functionality exists.

Prompt:

Before creating a new flag for [feature], check if a similar flag already exists
and suggest reusing it if appropriate.

Expected behavior: The agent calls detect_flag and presents matches with confidence levels.

Toggle or check flag state

Intent: Enable, disable, or query a flag in a specific environment.

Prompts:

Enable [flagName] in the staging environment.
What is the current state and rollout strategies for [flagName]?

Expected behavior: The agent calls toggle_flag_environment or get_flag_state.

Clean up a flag

Intent: Safely remove flagged code and delete unused flags.

Prompts:

Clean up the [flagName] flag now that the feature has fully shipped.
Clean up the [flagName] flag after the A/B testing experiment, only keep [variant].

Expected behavior: The agent calls cleanup_flag and provides removal instructions.

Discover and audit flags

Intent: Take inventory of existing flags and identify cleanup candidates.

Prompts:

List all feature flags in the [projectId] project and identify any that should be cleaned up.
Run a flag audit: list all projects, then check for flags at 100% rollout for more than 14 days.

Expected behavior: The agent calls list_projects (if no project is specified), then list_flags for active and archived flags. It cross-references results against code and reports cleanup candidates.

Agent-guided evaluation (FeatureOps agent)

Intent: Automatically evaluate code changes based on encoded policies using a custom agent.

Trigger: Switch to the FeatureOps agent via Tab key or start with --agent featureops.

Expected behavior: The agent’s system prompt instructs it to call evaluate_change whenever the developer describes a code change. If a flag is needed, the agent notifies you and offers to create it. Permission controls gate flag creation with "ask", so you approve before the flag is created. This works identically across all LLM providers.

Skill-orchestrated workflow

Intent: Run a multi-step FeatureOps workflow using a skill.

Trigger: The agent discovers the evaluate-and-flag skill automatically when the context is relevant, or you ask for it directly.

Expected behavior: The skill orchestrates the full workflow: evaluate the current changes, check for duplicates, create the flag if needed, wrap the code, and suggest a rollout strategy. Each step calls the appropriate MCP tool.

CLI-based evaluation

Intent: Evaluate and flag changes from the terminal without the interactive TUI.

Prompts:

$# Non-interactive evaluation
$opencode run "Evaluate whether the Stripe integration should be behind a feature flag"
$
$# With specific agent and model
$opencode run --agent featureops --model anthropic/claude-sonnet-4-20250514 \
> "Evaluate the Stripe payment integration for feature flagging"
$
$# Batch processing with the attach pattern
$opencode serve &
$opencode run --attach http://localhost:4096 "Evaluate changes in src/payments/"
$opencode run --attach http://localhost:4096 "Evaluate changes in src/auth/"
$
$# CI/CD with GitHub Actions
$opencode github run --event '{"action":"opened","pull_request":{...}}' \
> --github-token "$GITHUB_TOKEN"

Expected behavior: The CLI agent uses the same MCP tools as the TUI. In non-interactive mode, the agent outputs results and exits. The attach pattern avoids cold-booting MCP servers for each invocation.

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 FeatureOps agent definitions and permission policies via managed config. A managed FeatureOps agent with "edit": "ask" ensures every file change requires approval, 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 and the .opencode/ directory to version control. This ensures all team members use the same MCP servers, agents, and skills with the same permission policies.

Use custom agents with "ask" permissions for write operations like create_flag and toggle_flag_environment. Read-only operations like get_flag_state, detect_flag, and evaluate_change can safely use "allow".

Troubleshooting

MCP server not appearing in OpenCode
  • 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
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.env and 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_URL does not include /api at 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 18+. 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.

Best practices

Follow these guidelines for effective feature flag management with OpenCode.

Keep humans in the loop

While the MCP server can automate flag creation, high-risk changes should involve human review. Use custom agents with "ask" permissions for flag creation, rollout plans, and cleanup decisions.

Define naming conventions

Establish organization-wide standards for flag names (e.g., domain-feature-variant) and types. Encode these in AGENTS.md and in custom agent prompts so the agent applies them automatically.

Prevent duplication

Always use detect_flag before creating new flags. This keeps naming consistent and reduces fragmentation across services.

Keep flags temporary

Feature flags should be removed after successful rollouts. Use cleanup_flag regularly to prevent technical debt.

Use project scope for teams

Configure MCP servers at project scope (opencode.json) and commit to version control along with .opencode/ definitions. All team members get the same configuration, agents, and skills.

Use custom agents for governance

Define a FeatureOps agent with permission controls that gate flag creation and enforce your team’s policies. Agents work the same regardless of which model the developer selects.

Related resources

  • Unleash MCP server on GitHub
  • OpenCode homepage
  • OpenCode documentation
  • OpenCode MCP configuration
  • OpenCode agents documentation
  • Impact Metrics
  • Unleash architecture overview