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
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
Configure MCP Client
Add to your MCP client configuration (e.g., ~/.claude.json or Claude Desktop settings):
Usage
Basic Usage
Once configured, the MCP tools are available through your MCP client:
Tool Parameters
execute_opencode_command
opencode_run
opencode_continue_session
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
Development
Running Tests
Code Formatting
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