OpenCode MCP Server
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
OpenCode MCP Server
MCP server that exposes OpenCode as a tool/subagent for IDEs and AI clients
Overview
OpenCode MCP Server allows any MCP-compatible client (Cursor, Windsurf, Claude Desktop, Claude Code, Opencode, Antigravity, Zed, etc.) to delegate coding tasks to OpenCode as a subagent. This enables powerful multi-tool workflows where your primary AI assistant can call upon OpenCode for:
Code implementation and refactoring
File operations and search
Code analysis and planning
Multi-turn coding sessions
Agent delegation (build, plan, custom agents)
Model and provider management
Skill discovery and creation
Sub-MCP server management
Related MCP server: agentmux
Features
Full OpenCode Integration: Access all OpenCode capabilities via MCP tools
21 Tools: Streamlined toolset for coding, config, agents, skills, and MCP management
Hybrid Config Persistence: Config changes apply immediately AND persist to
opencode.jsonTool Annotations: MCP-compliant annotations for better LLM discoverability
Dual Transport: stdio (local) and HTTP (remote) with stateless/stateful modes
Type-Safe: Full TypeScript support with Zod v4 validation
Actionable Errors: Error messages include specific suggestions for resolution
Request Timeouts: Configurable timeout handling with proper cleanup
Structured Logging: Debug, info, warn, error levels via environment variable
Session Management: Create and manage coding sessions
Agent Delegation: Delegate tasks to specialized agents (build, plan, explore)
Skill System: Discover and create reusable skill definitions
MCP Management: List and enable/disable MCP servers
Quick Start
Installation
# Clone the repository
git clone https://github.com/Traves-Theberge/opencode-mcp.git
cd opencode-mcp
# Install dependencies and build
npm install
npm run buildPrerequisites
OpenCode installed: Install OpenCode
OpenCode server running: Start with
opencode serveor the TUIAPI keys configured: Set up your LLM provider keys in OpenCode
This MCP server built: Run
npm run buildin the project directory
Configure in Your IDE
OpenCode MCP Server works with all major AI-enabled IDEs:
IDE | Config File | Setup Guide |
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
| ||
|
Quick Config (Antigravity)
Add to ~/.gemini/antigravity/mcp_config.json:
{
"mcpServers": {
"opencode": {
"command": "node",
"args": ["/path/to/opencode-mcp/dist/index.js"],
"env": {
"OPENCODE_SERVER_URL": "http://localhost:4096",
"OPENCODE_DEFAULT_PROJECT": "/path/to/your/project"
}
}
}
}Note: Replace
/path/to/opencode-mcpwith the actual path where you cloned the repository.
Quick Config (Cursor)
Add to ~/.cursor/mcp.json:
{
"mcpServers": {
"opencode": {
"command": "node",
"args": ["/path/to/opencode-mcp/dist/index.js"],
"env": {
"OPENCODE_SERVER_URL": "http://localhost:4096",
"OPENCODE_DEFAULT_PROJECT": "/path/to/your/project"
}
}
}
}Quick Config (Claude Desktop)
Add to ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"opencode": {
"command": "node",
"args": ["/path/to/opencode-mcp/dist/index.js"],
"env": {
"OPENCODE_SERVER_URL": "http://localhost:4096",
"OPENCODE_DEFAULT_PROJECT": "/path/to/your/project"
}
}
}
}See docs/setup-guides/ for complete setup instructions for all supported IDEs.
Available Tools (21)
Execution (5)
Tool | Description |
| Execute a coding task through OpenCode |
| Create a new session |
| Send a prompt to a session |
| List all sessions |
| Abort a running session |
Files (4)
Tool | Description |
| Read a file from the project |
| Search text in files |
| Find files by name/pattern |
| Find workspace symbols |
Config (5)
Tool | Description |
| List available models |
| Configure model options |
| List providers |
| Get configuration |
| Update configuration |
Agents (2)
Tool | Description |
| List available agents |
| Delegate to an agent |
Skills (2)
Tool | Description |
| List available skills |
| Create a skill |
MCP Management (2)
Tool | Description |
| List MCP servers |
| Enable/disable MCP server |
Tool Config (1)
Tool | Description |
| List all tools |
Usage Examples
Basic Task Execution
Use opencode_run to implement a React hook for fetching data with loading and error statesCode Review with Planning Agent
Use opencode_agent_delegate to have the plan agent review the authentication module for security issuesFile Search
Use opencode_file_search to find all uses of deprecated functionsModel Configuration
Use opencode_model_configure to set reasoningEffort to high for deep thinking tasksCreate a Skill
Use opencode_skill_create to create a skill for database migration patternsConfiguration Files
This project includes pre-configured files for various AI coding agents:
Root-Level Config Files
File | Format | Used By |
| Universal | Codex, Cursor, Gemini CLI, Claude Code, Windsurf, Zed, Cline |
| Claude Code | Claude Code |
| Plain text | Cursor |
| Plain text | Windsurf |
| Markdown | Cline |
| YAML+Markdown | Continue.dev |
| Markdown | GitHub Copilot |
configs/ Directory
configs/
├── agents/
│ ├── AGENTS.md # Universal agent format
│ └── CLAUDE.md # Claude Code specific
├── skills/
│ └── SKILL.md # Agent Skills format (agentskills.io)
├── rules/
│ ├── cursor.md # Cursor rules
│ ├── continue.md # Continue rules (YAML frontmatter)
│ └── copilot-instructions.md
├── mcp/
│ └── templates.md # MCP config templates
└── README.md # Config documentationAgent Skills Format (SKILL.md)
Based on agentskills.io specification:
---
name: skill-name
description: When to use this skill
---
# Instructions...See configs/README.md for installation instructions.
Transport Modes
stdio (Default)
Best for local IDE integration
Single client connection
No configuration needed
HTTP
Best for remote access and multiple clients
Supports stateless and stateful sessions
Configure with environment variables:
MCP_TRANSPORT=http MCP_HTTP_PORT=3000 npx @opencode-mcp/serverEndpoints:
Endpoint | Method | Description |
| GET | Health check |
| GET | API documentation |
| POST | Stateless MCP requests |
| GET | SSE streaming (stateless) |
| POST | Stateful MCP requests |
| GET | SSE streaming (stateful) |
| DELETE | Close stateful session |
Modes:
Stateless (default): No session state between requests, better for scaling
Stateful: Session state maintained via sessionId, required for multi-turn context
Environment Variables
Variable | Default | Description |
|
| OpenCode server URL |
|
| Auto-start OpenCode |
| - | Default model |
|
| Request timeout in ms |
| - | Default project directory (used when workingDirectory not specified) |
| auto-detected | Path to opencode.json for config persistence |
|
| Log level (debug, info, warn, error, none) |
|
| Include timestamps in logs |
|
| Transport mode (stdio or http) |
|
| HTTP port |
|
| CORS origins (comma-separated, restrict in production) |
Config Persistence
Config tools (opencode_model_configure, opencode_config_update) use a hybrid approach:
API Update - Changes apply immediately to the running OpenCode server
File Persistence - Changes are saved to
opencode.jsonfor persistence across restarts
Config Path Detection
The config file location is auto-detected in this priority:
OPENCODE_CONFIG_PATHenvironment variable (explicit override)Project local:
{workingDirectory}/.opencode/opencode.jsonGlobal:
~/.config/opencode/opencode.json
Changes are deep-merged with existing config, preserving other settings.
Project Directory Detection
OpenCode MCP Server uses this priority to determine the working directory:
Explicit
workingDirectoryparameter - passed in tool callOPENCODE_DEFAULT_PROJECTenvironment variable - set in MCP configAuto-detection - searches for
.git,package.json, etc. from current directoryFallback - current working directory of MCP server process
Recommended: Set OPENCODE_DEFAULT_PROJECT in your MCP config to avoid specifying the directory every time:
{
"mcpServers": {
"opencode": {
"command": "node",
"args": ["/path/to/opencode-mcp/dist/index.js"],
"env": {
"OPENCODE_SERVER_URL": "http://localhost:4096",
"OPENCODE_DEFAULT_PROJECT": "/path/to/your/project"
}
}
}
}Error Handling
All tools return errors in a consistent format with actionable suggestions:
Error: <operation> failed.
Details: <error message>
Suggestions:
1. <actionable suggestion>
2. <another suggestion>See Error Handling Guide for details.
Development
# Clone and install
git clone https://github.com/opencode-mcp/server.git
cd server
npm install
# Run in dev mode
npm run dev
# Run tests
npm test
# Run linting
npm run lint
# Build
npm run buildSecurity
OpenCode MCP Server is designed with security in mind:
stdio transport (default): Local-only access, requires system access
No credential storage: API keys managed by OpenCode, not MCP server
Input validation: All inputs validated with Zod schemas
CORS configurable: Restrict origins for HTTP transport
Request limits: Configurable body size limits and timeouts
For production deployments with HTTP transport, see the Security Guide.
Documentation
API Reference - Complete tool documentation with annotations
IDE Setup Guide - Configure your IDE
Logging Guide - Configure logging levels
Error Handling Guide - Error format and categories
Security Guide - Security considerations and best practices
Architecture - System design
Contributing
Contributions are welcome! Please read our Contributing Guide for details.
License
MIT License - see LICENSE for details.
Acknowledgments
OpenCode - The AI coding agent this server integrates
Model Context Protocol - The protocol that makes this possible
MCP TypeScript SDK - The SDK used to build this server
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
This server cannot be deployed
Maintenance
Related MCP Connectors
Remote MCP access to user-authorized Linux, Windows and Intel Mac devices for AI assistants.
1MCP server for your apps' tools and custom tools, plus hosted AI agents and approval-gated workflows
Remote MCP learning coach for coding agents.
Hosted MCP server and Agent Skills for specs, engineering threads, and project memory.
Related MCP Servers
- AlicenseNot gradedqualityBmaintenanceEnables any MCP client to launch and manage subagent sessions in installed coding agents like Codex, Claude Code, Grok, and OpenCode, using your existing logins and chosen models.15 npmMIT
- AlicenseBqualityBmaintenanceEnables any MCP host to delegate work to multiple coding-agent CLIs such as Codex, Claude Code, and Antigravity as subagents, preserving native sessions and supporting team-based supervision and agent-to-agent messaging.1711 npmApache 2.0
- AlicenseBqualityBmaintenanceEnables a host coding agent to launch and coordinate real subagent sessions in other agent CLIs and accounts, sharing existing MCP servers, skills, plugins, and instructions. Supports two-way messaging, automatic account failover, and mixed-CLI delegation while leaving credentials with the vendor CLIs.814Apache 2.0
- AlicenseNot gradedqualityAmaintenanceEnables any MCP-compatible client to run reusable, Markdown-defined coding agents (such as code reviewers, test writers, or investigators) through a chosen coding CLI backend. Supports shared backend and model configuration across clients, permission levels, and session continuation for longer tasks.127 npmMIT