This page documents the Model Context Protocol (MCP) configuration system in oh-my-opencode. The system follows a 3-tier architecture to merge built-in capabilities, local Claude Code configurations, and dynamic skill-embedded servers.
The system merges MCP servers from three distinct sources. The configuration logic ensures that servers are prioritized, environment variables are expanded, and authentication is handled via OAuth where necessary.
The following diagram illustrates how the SkillMcpManager and various loaders interact to provide a unified toolset to the agents.
3-Tier MCP Integration Flow
Sources: packages/omo-opencode/src/mcp/AGENTS.md1-20 packages/omo-opencode/src/features/AGENTS.md18-23 packages/claude-code-compat-core/src/features/claude-code-mcp-loader/loader.test.ts11-73
Built-in MCPs are core tools provided out-of-the-box. These include both remote search services and local structural analysis tools.
| MCP Name | Implementation Package | Purpose |
|---|---|---|
lsp | lsp-tools-mcp | Provides lsp_diagnostics, lsp_goto_definition, etc. packages/AGENTS.md32 |
ast_grep | ast-grep-mcp | Provides ast_grep_search and ast_grep_replace packages/AGENTS.md33 |
git_bash | git-bash-mcp | Windows-only tool for Codex edition packages/AGENTS.md34 |
websearch | Remote | Remote search via Exa or Tavily. |
The lsp and ast_grep tools are registered as Tier-1 stdio MCPs, ensuring low-latency access to codebase intelligence packages/omo-opencode/src/tools/AGENTS.md21
Sources: packages/AGENTS.md30-35 packages/omo-opencode/src/tools/AGENTS.md7-21
The system maintains compatibility with the Claude Code ecosystem by scanning for .mcp.json and ~/.claude.json files.
The getSystemMcpServerNames function scans multiple locations in priority order:
.mcp.json in the current working directory packages/claude-code-compat-core/src/features/claude-code-mcp-loader/loader.test.ts42-56.claude/.mcp.json packages/claude-code-compat-core/src/features/claude-code-mcp-loader/loader.test.ts75-86~/.claude.json packages/claude-code-compat-core/src/features/claude-code-mcp-loader/loader.test.ts205-216Higher-precedence configurations (like project-local files) can override or disable servers defined at the user level packages/claude-code-compat-core/src/features/claude-code-mcp-loader/loader.test.ts136-169
Sources: packages/claude-code-compat-core/src/features/claude-code-mcp-loader/loader.test.ts11-254 packages/omo-opencode/src/features/AGENTS.md23
Skills defined in SKILL.md files can embed MCP server definitions. These are managed by the SkillMcpManager within the omo-opencode adapter, utilizing primitives from mcp-client-core packages/omo-opencode/src/features/AGENTS.md18
The manager handles the connection pooling and JSON-RPC dispatch for tools defined within skills. It ensures that servers are only spawned when a tool is actually invoked by an agent.
Skill MCP Tool Execution Flow
Sources: packages/omo-opencode/src/features/AGENTS.md18 packages/AGENTS.md56
For enterprise or protected remote MCP servers, the system implements a robust OAuth 2.0 flow. This feature is integrated into the mcp-oauth module and mcp-client-core packages/omo-opencode/src/features/AGENTS.md21
oh-my-opencode mcp-oauth commands packages/omo-opencode/src/AGENTS.md63Sources: packages/omo-opencode/src/features/AGENTS.md21 packages/omo-opencode/src/AGENTS.md60-63
The system supports ${VAR} style environment expansion in MCP configurations. This is handled by the claude-code-mcp-loader adapter shims packages/omo-opencode/src/features/AGENTS.md23
.mcp.json files are treated with restricted permissions to prevent malicious command execution during discovery.stdio MCP processes are monitored for idleness.lsp tools, the lsp-daemon package allows multiple sessions to share a single warm LSP process via unix sockets/named pipes, significantly reducing startup overhead packages/AGENTS.md35Sources: packages/omo-opencode/src/features/AGENTS.md23 packages/AGENTS.md35 packages/AGENTS.md52
Refresh this wiki