MCP & LSP
OpenCode extends external capabilities via MCP (Model Context Protocol) and gets live language diagnostics via LSP (Language Server Protocol).
MCP Overview
MCP lets the agent call databases, browsers, Slack, custom APIs, etc., without baking that logic into OpenCode itself.
Config locations:
- Global:
mcpin~/.config/opencode/opencode.json - Project: project root
opencode.json
Configure MCP Servers
stdio (local process)
SSE / HTTP (remote)
Use /connect in TUI for Providers interactively; MCP is usually maintained in config files.
MCP and Permissions
MCP tool names often include a server prefix. Control via permission:
Security:
- Enable only MCP servers the project needs
- Default write/network MCP to
ask - Review MCP server source and scope
Common MCP Use Cases
Explore subagent + read-only MCP avoids Build accidentally writing to production systems.
LSP Integration
OpenCode can connect language servers and surface diagnostics (errors, warnings) after edits so the agent can self-correct.
Enable
opencode.json:
Install the corresponding LSP binaries on your machine.
With the agent
- Agent edits
foo.ts - LSP returns type errors
- Agent reads diagnostics and fixes
More reliable than the model guessing types alone.
LSP permission
permission.lsp controls LSP tool access; usually allow by default.
MCP vs LSP
Both can run together—they complement each other.