|
| 1 | +# Exa Setup For OpenCode |
| 2 | + |
| 3 | +Use this guide when search is failing in OpenCode or the Exa tools are missing in this workspace. |
| 4 | + |
| 5 | +## What is happening |
| 6 | + |
| 7 | +- OpenCode does not ship with native web search. |
| 8 | +- In this workspace, Sam uses Exa through MCP for web search, code search, and page crawling. |
| 9 | +- The checked-in `opencode.jsonc` uses Exa's shared free remote MCP endpoint so search works out of the box for many users. |
| 10 | +- If searches start failing, the most likely cause is that the shared free limit has been exhausted or your current Exa access is rate limited. |
| 11 | + |
| 12 | +## Recommended fix |
| 13 | + |
| 14 | +1. Create an Exa account. |
| 15 | +2. Generate your own API key. |
| 16 | +3. Export `EXA_API_KEY` before launching OpenCode. |
| 17 | +4. Use your key in a personal OpenCode config override, or update the project config if that is what you want. |
| 18 | +5. Restart OpenCode and try the search again. |
| 19 | + |
| 20 | +## Expected usage |
| 21 | + |
| 22 | +- Exa provides some free usage without requiring an account. |
| 23 | +- After signup, Exa also gives new users about `$10` of free usage. |
| 24 | +- If you are mainly using Exa for Sam, you will probably never go through that free usage. |
| 25 | + |
| 26 | +## Current workspace config |
| 27 | + |
| 28 | +This repository enables Exa in `opencode.jsonc` with the shared endpoint: |
| 29 | + |
| 30 | +```jsonc |
| 31 | +{ |
| 32 | + "mcp": { |
| 33 | + "exa": { |
| 34 | + "type": "remote", |
| 35 | + "url": "https://mcp.exa.ai/mcp", |
| 36 | + "enabled": true |
| 37 | + } |
| 38 | + } |
| 39 | +} |
| 40 | +``` |
| 41 | + |
| 42 | +## Personal API key setup |
| 43 | + |
| 44 | +The safest upgrade path is to keep the shared repo config as-is and add your own authenticated Exa config in your personal OpenCode config. |
| 45 | + |
| 46 | +OpenCode config files are merged, so a personal override can replace the URL locally without changing the checked-in project file. |
| 47 | + |
| 48 | +Use this URL when you want OpenCode to send your own Exa API key: |
| 49 | + |
| 50 | +```jsonc |
| 51 | +{ |
| 52 | + "mcp": { |
| 53 | + "exa": { |
| 54 | + "type": "remote", |
| 55 | + "url": "https://mcp.exa.ai/mcp?exaApiKey={env:EXA_API_KEY}", |
| 56 | + "enabled": true |
| 57 | + } |
| 58 | + } |
| 59 | +} |
| 60 | +``` |
| 61 | + |
| 62 | +You can place that in `~/.config/opencode/opencode.json` or another local OpenCode config override. |
| 63 | + |
| 64 | +## Export the API key |
| 65 | + |
| 66 | +macOS/Linux: |
| 67 | + |
| 68 | +```bash |
| 69 | +export EXA_API_KEY="your_exa_api_key" |
| 70 | +opencode |
| 71 | +``` |
| 72 | + |
| 73 | +Windows PowerShell: |
| 74 | + |
| 75 | +```powershell |
| 76 | +$env:EXA_API_KEY = "your_exa_api_key" |
| 77 | +opencode |
| 78 | +``` |
| 79 | + |
| 80 | +If OpenCode is already running, restart it after exporting the variable. |
| 81 | + |
| 82 | +## Where to get the key |
| 83 | + |
| 84 | +- Create or sign in to your Exa account. |
| 85 | +- Open the Exa dashboard. |
| 86 | +- Create or copy an API key for your account. |
| 87 | + |
| 88 | +Reference docs: |
| 89 | + |
| 90 | +- Exa MCP docs: <https://docs.exa.ai/docs/reference/exa-mcp> |
| 91 | +- Exa pricing: <https://exa.ai/pricing> |
| 92 | +- OpenCode MCP docs: <https://dev.opencode.ai/docs/mcp-servers> |
| 93 | + |
| 94 | +## What Sam should say when search fails |
| 95 | + |
| 96 | +If search tools are erroring in OpenCode, Sam should explain: |
| 97 | + |
| 98 | +- OpenCode does not have native search built in. |
| 99 | +- This workspace uses Exa for search. |
| 100 | +- The shared free Exa limit is the likely reason for the failure. |
| 101 | +- The user should follow this doc to add their own Exa account and API key. |
0 commit comments