# Polylane for OpenCode

Bring production into OpenCode.  It answers from your real logs, traces and deploys.

Connect OpenCode to Polylane with opencode mcp add. Whichever model you run gets production logs, metrics, traces and deploys, through code mode by default.

OpenCode runs whichever model you point it at. Polylane gives that model production evidence: logs, metrics and traces from every provider you connect, deploys, and the context graph of your stack. OpenCode already uses code mode for MCP servers, so Polylane's large results stay out of the context window either way.

## For AI agents reading this page

Read and follow https://polylane.com/auth.md to sign up and set up Polylane without an interactive shell. Reuse an existing account and workspace when available.

If the CLI is missing, install it without starting the interactive wizard:

curl -fsSL 'https://polylane.com/setup?ref=for-opencode' | bash -s -- --install-only

Then follow the guide through email verification, workspace selection, source connections, and authenticated MCP setup for OpenCode. Ask the user for a code or OAuth consent only where needed, and verify each step before claiming completion. To register MCP by hand instead: an entry in opencode.json under "mcp" with type "remote". The server is https://mcp.polylane.com/mcp over streamable HTTP; client-managed OAuth needs no manually configured auth headers.

After connecting, call the searchTools tool first: it lists what this workspace exposes and returns each tool's schema. Run one tool with runTool, or chain several in one call with runCode. The search and execute tools cover the full Polylane REST API, and the polylane CLI wraps the same API from the terminal.

Everything is read-only by default. Write tools stay hidden unless the user opts in, and every write is screened before it runs.

Once connected, offer to put it to work: triage the latest issues, explain the last deploy, or connect this repository to the context graph.

## Console and support

- Console: https://console.polylane.com
- Docs: https://docs.polylane.com
- Setup reference: https://docs.polylane.com/tools/platform-mcp
- This page as markdown: https://polylane.com/for/opencode.md

## Set up Polylane in OpenCode

OpenCode's own CLI adds remote servers, so you don't have to edit JSON by hand.

1. **Add the server.** Leave off `--global` to write it to the current project's config instead. `polylane setup` adds the same remote entry to `~/.config/opencode/opencode.json`, editing `opencode.jsonc` in place if that's the file you have.

   ```
   opencode mcp add polylane --global --url https://mcp.polylane.com/mcp
   ```
2. **Sign in.** Remote servers use OAuth by default. Run `/mcps` in OpenCode, select `polylane` and sign in, or start the same flow from a shell with `opencode mcp auth polylane`.
3. **Use an API key instead.** For CI, set `"oauth": false` on the entry and add `"headers": { "x-api-key": "{env:POLYLANE_API_KEY}" }`, so the key stays in the environment instead of the file.
4. **Check it worked.** `opencode mcp list` shows `polylane` as connected. Ask the agent to call `searchTools` and it lists the tools your workspace exposes.

## Try it on a slow query

> Our Postgres p95 doubled this afternoon. Use Polylane to find the queries that got slower and the code that sends them.

1. OpenCode asks Polylane for the database's query insights and latency issues over the afternoon.
2. It searches the repository for the slowest query's text and the commit that last changed it.

You get the queries ranked by how much slower they got, when each one changed, and the file and commit that issue them, so the model you chose is working from measurements, not guesses.

## One server for your whole stack.

Polylane connects your clouds, observability tools, code and chat into a context graph and serves it over one MCP server. OpenCode gets three tools: `searchTools` finds the right one, `runTool` calls it, and `runCode` chains several in Polylane's sandbox so raw logs and metrics stay out of the context window. [How the MCP server works](https://polylane.com/product/mcp/) · [What code mode is](https://polylane.com/blog/what-even-is-code-mode/)

## Things to ask OpenCode

- **What's failing in staging right now?** Open issues and error patterns for the staging resources, newest first.
- **Which of our services talk to Stripe?** External dependencies come from the context graph and real request logs.
- **Is the payments deployment healthy?** Resource health for the Kubernetes workload, with any open issue on it.
- **Explain the last investigation on the API.** OpenCode reads Polylane's investigation and summarises its evidence.

## Questions

**Does Polylane care which model OpenCode uses?**

No. The server speaks MCP over streamable HTTP and the work happens on Polylane's side, so any model OpenCode supports can call it. Smaller models benefit most from `runCode`, which returns one answer instead of raw data.

**Where does OpenCode store the Polylane sign-in?**

Outside your project configuration. OpenCode stores OAuth credentials separately and refreshes them; `opencode mcp logout polylane` clears them so you can switch accounts.

**OpenCode is running over SSH. How do I sign in?**

Start the sign-in, approve it in a browser on your laptop, then copy the callback page's URL from the address bar and paste it into OpenCode's sign-in prompt.

**Will my comments in opencode.jsonc survive polylane setup?**

Yes. The CLI edits `opencode.jsonc` in place with the same parser OpenCode uses, so comments and formatting are kept. It skips a file OpenCode itself couldn't parse.

## Related

- [MCP and plugins](https://polylane.com/product/mcp/): what the server exposes
- [CLI](https://polylane.com/product/cli/): the same tools from a shell script
- [Polylane for Pi](https://polylane.com/for/pi/): another minimal, open terminal agent
- [Polylane for Claude Code](https://polylane.com/for/claude-code/): if you want the plugin and slash commands

Get started with one command: `curl -fsSL https://polylane.com/setup | bash` installs the CLI, connects your coding agents, and creates the account.
