7 min read

Part 5: Extend OpenCode with MCP

Table of Contents

By now you’ve used opencode to do real work: Part 3 had it clean a CSV and answer a question about it. But so far opencode only really knows two things: the files in front of it, and whatever its training taught it.

That’s about to change. In this Part 5, you’re going to give it the ability to reach the outside world, and that’s where things get exciting.

Picture what your agent could do for you tomorrow:

  • Answer questions that need today’s data: “What are the latest quarterly earnings for these five companies, and who’s growing fastest?” It searches the live web, pulls real figures, and cites sources, not a guess from memory.
  • Bring you a morning briefing: “Scan today’s news on retail, summarize the top 5 stories, and save me a short brief.” It reads a dozen articles and hands you one clean summary.
  • Go get data that has no “export” button: “Open our supplier’s public dashboard, navigate to last month, and copy the table into my workbook.” It drives a real browser, clicks around, and retrieves what you need.
  • Archive evidence for your reports: “Save this page as a PDF” or “grab that competitor’s pricing table as a CSV.”

Each of those is exactly the kind of task you’ve been doing by hand (checking figures, gathering sources, pulling data), now on autopilot. And none of it needs you to be a programmer.

ℹ️

What makes all of this possible is MCP (Model Context Protocol), a standard way to attach extra tools to an AI assistant. Think of it as handing opencode a toolbox it can reach into on demand. Each tool is called an MCP server. In this post you’ll add two of them: Exa (searches the web) and Playwright (drives a browser).

Fun fact: these are the same two servers that keep this blog’s own AI workflow running, so you’re wiring up the exact tricks that power what you’re reading. Here’s how to set them up.

First: open opencode’s settings file

MCP servers are declared in opencode’s config file, called opencode.json, sitting in your user config folder. The easiest way to edit it while keeping the format valid is call opencode and run the /mcp command, which walks you through adding servers. If you’d rather edit by hand, the file lives at:

  • Windows: %USERPROFILE%\.config\opencode\opencode.json

Both servers below get added under the same top-level "mcp" block, alongside whatever’s already there.

For “answer a current question” work, Exa is the add-on you want. Without it, opencode answers from memory; with it, it can search the web and read pages in real time, so you can ask “what are the current revenue numbers for these three companies?” and get today’s answer, not a stale one.

Easiest way: have opencode set it up for you. Copy this, open opencode, paste it in and let it edit its own config:

Add the Exa MCP server to my opencode config so I can search the web live.
Add it to the "mcp" section in opencode.json:
exa: {
  "type": "remote",
  "url": "https://mcp.exa.ai/mcp?tools=web_search_exa,web_fetch_exa,web_search_advanced_exa",
  "enabled": true
}
Keep anything else in the file untouched. Tell me when it's ready.

That’s the whole flow: opencode reads the prompt, adds the config, and tells you it’s ready. Prefer to edit by hand? Here’s the config it ends up with (mirrors the exact setup this blog uses):

"mcp": {
  "exa": {
    "type": "remote",
    "url": "https://mcp.exa.ai/mcp?tools=web_search_exa,web_fetch_exa,web_search_advanced_exa",
    "enabled": true
  }
}

What the pieces mean:

  • "type": "remote" means the Exa server runs online, so opencode just points at it over the internet.
  • the url is Exa’s search server. The ?tools=... part picks which abilities you want (simple search, page reading, advanced filtered search).
  • "enabled": true turns it on.

Exa has a free tier, so you can start without configuring billing. Restart opencode after editing the file (or use /mcp to connect it live without restarting).

Try it. Ask opencode something fact-based and current, like:

“Search the web and tell me the top 5 books on data visualization recommended this year, with a one-line summary of each.”

You should see it reach out and come back with sourced answers. Official docs: exa.ai/docs/reference/exa-mcp.

Server 2: Playwright (browser automation)

Where Exa reads the web, Playwright drives it: it can open a browser, go to a page, scroll, fill forms, log in, and copy the results. That’s huge for data work: grabbing something from a site that has no easy export button, grabbing a table off a dashboard, or checking a live page.

Playwright is a local server, so it spawns a real browser on your machine.

Easiest way: have opencode set it up for you. Same trick as Exa: copy this, paste it into opencode, and it installs the server:

Add the Playwright MCP server to my opencode config so I can control a browser.
Add it to the "mcp" section in opencode.json:
playwright: {
  "type": "local",
  "command": ["npx", "@playwright/mcp@latest"],
  "enabled": true
}
Keep anything else in the file untouched. Tell me when it's ready.

Prefer to do it by hand? Add it like this:

"mcp": {
  "playwright": {
    "type": "local",
    "command": ["npx", "@playwright/mcp@latest"],
    "enabled": true
  }
}

Differences from Exa at a glance:

  • "type": "local": the server runs on your computer rather than on a hosted URL.
  • "command": how opencode starts it. npx @playwright/mcp@latest fetches and runs the Playwright server. The browser itself downloads automatically the first time you use it.

By default it opens a visible browser window (headed mode), so you can watch what it’s doing. If you’d rather it run invisibly in the background, add "--headless" as another line in the command list.

Try it. Give opencode a task that needs interacting with a real site; start simple, something public:

“Open the Wikipedia page for ‘Data visualization’, scroll to the history section, and summarize the first two paragraphs.”

Watch a browser window open and move by itself. Official docs: playwright.dev/mcp.

⚠️

Two safety notes. First, Playwright acts on real websites with your sessions, so only use it on sites you’re allowed to be using and give it specific tasks (don’t hand it your bank login). Second, every MCP server you add puts a little more load on the conversation, so only keep the ones you actually use.

The mental model

You’ve now seen the full picture of what opencode can do:

  • Files (Parts 1 to 3): it edits your project.
  • Skills (Part 4): it follows a packaged method you give it.
  • MCP servers (this part): it can reach the outside world: live web (Exa) and real browsers (Playwright).

Whatever AI tool you pick up later, these three ideas (the agent, the skill, the connector) are the ones that keep showing up. The setup differs slightly per tool, but the shape is always the same.