OpenCode CLI MCP Commands
This page focuses on Model Context Protocol (MCP) server management using the OpenCode CLI.
If youβre looking to add servers, authenticate, debug connections, or list available MCP servers, this guide is for you.
π Quick Start (MCP)
# Add a new MCP server (local or remote)
opencode mcp add
# Authenticate the server
opencode mcp auth [name]
# List all configured servers
opencode mcp list
# Test connection
opencode mcp debug [name]
β Most Used MCP Commands
Add a Server
opencode mcp add
- Follow the interactive prompt to configure a local or remote MCP server.
List MCP Servers
opencode mcp list
opencode mcp ls
- Shows server names, type, and connection status.
Authenticate MCP Server
opencode mcp auth my-server
opencode mcp auth list
opencode mcp auth ls
authensures OpenCode can securely access your MCP server.
Logout from MCP Server
opencode mcp logout my-server
Debug MCP Server
opencode mcp debug my-server
- Checks connectivity and server health.
π Examples
Connect a Local MCP Server
opencode mcp add
# Enter name: local-filesystem
# Server type: Filesystem MCP
# Path: /path/to/data
opencode mcp auth local-filesystem
opencode mcp list
Connect a Remote MCP Server
opencode mcp add
# Enter name: github-server
# Server type: GitHub MCP
# URL: https://my-mcp-server.example.com
opencode mcp auth github-server
opencode mcp debug github-server
Use MCP in a Task
opencode run --attach http://localhost:4096 "Summarize last 5 GitHub issues"
--attachconnects to an existing MCP server for live context.
π§ Common Use Cases
- Browser Automation: via Playwright MCP
- File Access: via Filesystem MCP
- Repository Data: via GitHub MCP
- Database Queries: via PostgreSQL MCP (read-only)
For detailed MCP protocol internals and JSON-RPC spec, see the OpenCode MCP Explained.
Related Documentation
- CLI Commands Hub β Back to full CLI reference
- OpenCode MCP Explained β Deep technical reference
- Playwright MCP Setup
- MCP Configuration Guide