Combining local multi-LLM routing with Model Context Protocol (MCP) turns AI CLI tools like OpenCode into full-fledged infrastructure and development agents.
1. Configuring 9router Gateway in OpenCode
9router acts as a local proxy gateway (http://127.0.0.1:20128/v1) using @ai-sdk/openai-compatible. It routes model aliases to specialized LLM combos:
9router/codegen-combo– Primary agent for building and complex refactoring.9router/quick-combo– Lightweight agent for fast codebase exploration (explorersubagent).
{ "provider": { "9router": { "npm": "@ai-sdk/openai-compatible", "options": { "baseURL": "http://127.0.0.1:20128/v1", "apiKey": "sk-7808cd13d16801d8-2hfyu1-45f240fe" }, "models": { "codegen-combo": { "name": "codegen-combo" }, "quick-combo": { "name": "quick-combo" } } } }, "model": "9router/codegen-combo" }
2. Integrating Local MCP Servers
Model Context Protocol (MCP) gives OpenCode direct access to external tools and live infrastructure:
Active MCP Integrations
- MikroTik MCP (
mcp-server-mikrotik): Allows AI agents to query and configure network interfaces, firewall rules, and routes over SSH (192.168.88.1:22). - CodeGraph MCP (
codegraph serve --mcp): Provides instant 1-call knowledge graph exploration of repository symbols and call paths. - Playwright MCP (
@playwright/mcp@latest): Enables browser automation and UI testing directly from CLI agent prompts. - Shadcn & 21st.dev MCP: Fetches component definitions and modern UI design system primitives.
{ "mcp": { "mikrotik": { "type": "local", "command": ["uvx", "mcp-server-mikrotik"], "environment": { "MIKROTIK_HOST": "192.168.88.1", "MIKROTIK_PORT": "22" }, "enabled": true }, "codegraph": { "type": "local", "command": ["codegraph", "serve", "--mcp"], "enabled": true } } }
Summary
With 9router handling resilient LLM failovers and MCP providing real-time infrastructure tools, OpenCode can inspect network topologies, execute code refactoring, and run automated browser checks within a single session.