OpenCode MCP Server
Provides integration with the OpenCode AI coding agent, allowing users to programmatically execute CLI commands, manage and export coding sessions, and discover available AI models from various providers.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@OpenCode MCP Serverrefactor the login function in auth.py to be more efficient"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
OpenCode MCP Server
An MCP (Model Context Protocol) server that provides seamless integration with OpenCode, the open-source AI coding agent for the terminal.
Features
Execute OpenCode Commands: Run any OpenCode CLI command programmatically
Session Management: Create, continue, and export coding sessions
Model Discovery: List available AI models from all configured providers
Async Execution: Non-blocking command execution with timeout handling
JSON Lines Parsing: Robust parsing of OpenCode's streaming output format
Related MCP server: polycode
Tools Available
Tool | Description |
| Execute any OpenCode CLI command with full flexibility |
| Run OpenCode with a simple prompt message |
| Continue an existing OpenCode session |
| List available models, optionally filtered by provider |
| Export session data as JSON |
| Check OpenCode CLI availability and status |
Installation
Prerequisites
Python 3.10+
OpenCode CLI installed and configured
MCP-compatible client (Claude Desktop, etc.)
Install Dependencies
pip install -r requirements.txtConfigure MCP Client
Add to your MCP client configuration (e.g., ~/.claude.json or Claude Desktop settings):
{
"mcpServers": {
"opencode": {
"command": "python",
"args": ["-m", "src.services.fast_mcp.opencode_server"],
"cwd": "/path/to/opencode-mcp"
}
}
}Usage
Basic Usage
Once configured, the MCP tools are available through your MCP client:
# Run a coding task
opencode_run(message="Create a Python function that calculates fibonacci numbers")
# List available models
opencode_list_models(provider="anthropic")
# Continue a previous session
opencode_continue_session(session_id="abc123", message="Now add unit tests")
# Check status
opencode_get_status()Tool Parameters
execute_opencode_command
{
"prompt": str, # Required: The prompt/task for OpenCode
"model": str, # Optional: Model in provider/model format (e.g., "anthropic/claude-sonnet-4-20250514")
"agent": str, # Optional: Agent to use (e.g., "build", "plan")
"session": str, # Optional: Session ID to continue
"continue_session": bool, # Optional: Whether to continue last session
"timeout": int # Optional: Timeout in seconds (default: 300, max: 600)
}opencode_run
{
"message": str, # Required: Message/prompt to send
"model": str, # Optional: Model to use
"agent": str, # Optional: Agent to use
"files": [str], # Optional: Files to attach
"timeout": int # Optional: Timeout in seconds
}opencode_continue_session
{
"session_id": str, # Required: Session ID to continue
"message": str, # Optional: Follow-up message
"timeout": int # Optional: Timeout in seconds
}Configuration
Environment variables (prefix: OPENCODE_):
Variable | Default | Description |
|
| Path to OpenCode CLI |
| None | Default model to use |
| None | Default agent to use |
|
| Default timeout (seconds) |
|
| Maximum timeout (seconds) |
|
| Logging level |
Architecture
src/services/fast_mcp/opencode_server/
├── __init__.py
├── __main__.py # Entry point
├── server.py # MCP server & tool definitions
├── opencode_executor.py # CLI execution wrapper
├── models.py # Pydantic models
├── settings.py # Configuration
└── handlers/
├── __init__.py
├── execution.py # Run/continue operations
├── session.py # Session management
└── discovery.py # Model/status discoveryDevelopment
Running Tests
pytest tests/ -vCode Formatting
black src/
ruff check src/Roadmap
Planned features for v2.0:
opencode_import_session- Import sessions from JSON/URLopencode_list_sessions- List all sessions with filteringopencode_get_stats- Usage statistics and cost trackingopencode_list_agents- List available agentsopencode_github_run- GitHub Actions integration (async)opencode_pr_checkout- PR workflow support
Contributing
Contributions are welcome! Please read the contributing guidelines before submitting PRs.
License
MIT License - see LICENSE for details.
Related Projects
OpenCode - The AI coding agent this server integrates with
Model Context Protocol - The protocol specification
MCP SDK - Python SDK for MCP
Acknowledgments
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityBmaintenanceBridges MCP clients to OpenCode's headless API, enabling AI to delegate autonomous coding tasks like building features, debugging, and refactoring across multiple projects.Last updated340104MIT
- Alicense-qualityDmaintenanceMCP server providing 13 tools to control opencode, Gemini CLI, and Qwen Code AI coding agents with session continuity and auth checking.Last updatedMIT
- Alicense-qualityDmaintenanceA Model Context Protocol (MCP) server that enables remote access to OpenCode AI coding agent, allowing MCP-compatible clients to leverage OpenCode's capabilities.Last updatedMIT
- Alicense-qualityFmaintenanceA comprehensive MCP server integrating OpenAI GPT models for AI-powered tasks like code analysis, generation, and translation, along with system utilities, Docker management, network diagnostics, and web tools.Last updatedMIT
Related MCP Connectors
Hosted MCP server connecting claude.ai, ChatGPT and other AI apps to your own computer
Search your AI chat history (ChatGPT, Claude, Codex) from any MCP client. Remote, private, read-only
Augments MCP Server - A comprehensive framework documentation provider for Claude Code
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/nosolosoft/opencode-mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server