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
  • auth ensures 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"
  • --attach connects 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