opencode-raven 2.1.5 → 2.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/CHANGELOG.md +220 -0
  2. package/README.md +212 -317
  3. package/index.ts +679 -438
  4. package/package.json +22 -4
package/README.md CHANGED
@@ -1,317 +1,212 @@
1
- # opencode-raven
2
-
3
- [![npm version](https://img.shields.io/npm/v/opencode-raven.svg)](https://www.npmjs.com/package/opencode-raven)
4
- [![npm downloads](https://img.shields.io/npm/dm/opencode-raven.svg)](https://www.npmjs.com/package/opencode-raven)
5
- [![license](https://img.shields.io/npm/l/opencode-raven.svg)](LICENSE)
6
-
7
- <table>
8
- <tr>
9
- <td width="40%"><img src="Raven.png" alt="Raven" width="100%" /></td>
10
- <td>
11
- Raven gives OpenCode useful search tools by default and optional on-demand MCPs for any remote or local MCP you want to add. It keeps noisy tool work behind a focused Raven agent, so your main model gets compact answers instead of raw search results, docs pages, GitHub examples, MCP output, or large MCP schemas.
12
-
13
- ## Why Use Raven?
14
-
15
- * Routed search, fetch, and bash discovery work through Raven.
16
- * Context7, Exa, and Grep.app are bundled as on-demand MCP defaults.
17
- * Any extra MCP can be added under `onDemandMcpServers` when you want it.
18
- * Configured noisy tools and MCPs are blocked for non-Raven agents and forced through `raven_seek`.
19
- </td>
20
- </tr>
21
- </table>
22
-
23
- ## Example
24
-
25
- <p align="center">
26
- <img src="example.gif" alt="Raven example: searching today's top 30 AI news items while saving 71K context" />
27
- </p>
28
-
29
- In this example, the main model asks for the top 30 AI news items from today. Raven handles the noisy search/web work in a focused agent and returns the compact result, saving about 71K context that would otherwise have landed in the main session.
30
-
31
- ## Install
32
-
33
- Add Raven to your `opencode.jsonc` plugins:
34
-
35
- ```jsonc
36
- {
37
- "plugin": ["opencode-raven"]
38
- }
39
- ```
40
-
41
- Restart opencode. It will resolve Raven from npm and cache the plugin automatically.
42
-
43
- That is enough to start using Raven. The default config already includes routed search/fetch tools and bundled on-demand MCPs for Context7, Exa, and Grep.app. Add any other MCP under `onDemandMcpServers` only if you want more capabilities.
44
-
45
- Raven checks for package updates and notifies you when a newer version is available. Run `/raven update`, then restart opencode.
46
-
47
- ## Quick Use
48
-
49
- Run `/raven` to see status, routed tools, on-demand MCP health, and saved context.
50
-
51
- When a configured tool or MCP is blocked, agents use `raven_seek` to delegate the same request through Raven:
52
-
53
- ```txt
54
- raven_seek(query: "how to use useEffect cleanup")
55
- raven_seek(query: "Fetch/read https://example.com and summarize install steps")
56
- raven_seek(query: "Check whether archivemount/libarchive supports ISO or UDF. Use docs, web, or command output as needed.")
57
- ```
58
-
59
- You can call Raven directly with `@Raven` in any OpenCode chat. The Raven agent runs with full filesystem and MCP access, without permission prompts.
60
-
61
- The main agent does not see Raven's internal tool calls or raw tool output, just the final findings. Raven parallelizes independent tool calls internally within a single session.
62
-
63
- ## Commands
64
-
65
- | Command | Action |
66
- |---------|--------|
67
- | `/raven` | Show status, version, model, routing, on-demand MCP health, stats, reasoning effort, and timeout |
68
- | `/raven help` | Show all Raven commands |
69
- | `/raven on` | Enable hard tool/MCP routing |
70
- | `/raven off` | Disable routing so all agents can use routed tools directly |
71
- | `/raven route` | Show routed tools, auto-routed global MCP prefixes, and routed tool keywords |
72
- | `/raven route tool add <name>` | Route a specific tool through Raven |
73
- | `/raven route tool remove <name>` | Stop routing a specific tool |
74
- | `/raven route keyword add <keyword>` | Route any tool whose name contains `<keyword>` |
75
- | `/raven route keyword remove <keyword>` | Stop routing a tool-name keyword |
76
- | `/raven mcp` | Show on-demand MCP status and generated metadata state |
77
- | `/raven mcp refresh [server]` | Recheck on-demand MCP health and regenerate tool descriptions/schema estimates |
78
- | `/raven mcp detail full\|minimized` | Choose full tool descriptions or minimized capability summaries in guidance |
79
- | `/raven update` | Check npm for a newer Raven, clear OpenCode's plugin cache if needed, then restart opencode |
80
- | `/raven model <name>` | Change Raven's model (requires restart) |
81
- | `/raven effort <value>` | Change Raven's reasoning effort (requires restart) |
82
- | `/raven timeout <seconds>` | Change `raven_seek` timeout, minimum 10 seconds |
83
- | `/raven stats` | Show estimated context saved, including avoided MCP schema load, session, and all-time totals |
84
-
85
- Config persists across restarts in `~/.config/opencode/opencode-raven/raven-config.json`. It is global and shared across all projects.
86
-
87
- ## Recommended MCP Setup
88
-
89
- You do not need to configure MCPs just to try Raven. Raven gives you the search tools up front, supports any MCP as an on-demand MCP, and bundles Context7, Exa, and Grep.app as defaults. Add more MCPs only when you want extra capabilities.
90
-
91
- On-demand MCPs live in `onDemandMcpServers`, so Raven connects to them internally through `raven_mcp` only when needed instead of registering their full tool schemas in OpenCode's global MCP config. Context7, Exa, and Grep.app are included there by default, but the same setup works for any remote or local MCP you want to add.
92
-
93
- On-demand MCPs are always behind Raven and do not need routing entries.
94
-
95
- Raven checks configured on-demand MCPs after startup. `/raven` and `/raven mcp` show loaded, failed, and pending MCPs. Loaded MCPs count toward avoided schema-load stats, while failed or pending MCPs do not. Raven shows a warning toast after startup or manual refresh if any configured on-demand MCP fails to load.
96
-
97
- Raven also warns if the same MCP server name is configured both globally in OpenCode and in Raven's `onDemandMcpServers`. Prefer one location: on-demand for schema hiding, or global only when direct main-agent access is required.
98
-
99
- Important limitation: MCPs enabled directly in OpenCode config still load their tool schemas into the main session. Raven saves context from tool calls and raw results for those global MCPs, but schema hiding requires putting the MCP in Raven's `onDemandMcpServers`. **Strongly recommended:** configure noisy/search/docs/web MCPs as on-demand MCPs unless you need direct main-agent access.
100
-
101
- All three bundled MCPs work without API keys. Add keys for higher rate limits:
102
-
103
- | MCP | URL | API key |
104
- |-----|-----|---------|
105
- | Context7 | `https://mcp.context7.com/mcp` | Free key at [context7.com/dashboard](https://context7.com/dashboard) for higher limits |
106
- | Exa AI | `https://mcp.exa.ai/mcp` | Free key at [exa.ai](https://exa.ai) for higher limits |
107
- | Grep.app | `https://mcp.grep.app` | Public API, no key needed |
108
-
109
- To add an API key to an on-demand MCP, edit Raven config:
110
-
111
- ```jsonc
112
- {
113
- "onDemandMcpServers": {
114
- "exa": {
115
- "type": "remote",
116
- "url": "https://mcp.exa.ai/mcp",
117
- "headers": { "x-api-key": "{env:EXA_API_KEY}" },
118
- "description": "Live web search and webpage fetching."
119
- }
120
- }
121
- }
122
- ```
123
-
124
- ### Add Your Own On-Demand MCP
125
-
126
- To add another MCP, put it under `onDemandMcpServers`. Raven will connect to it only when needed, discover its tools, and generate guidance automatically. Your main model does not need to load that MCP's full schema up front.
127
-
128
- Use `remote` for hosted MCPs and `local` for command-based MCPs.
129
-
130
- To add an OpenCode-style local MCP:
131
-
132
- ```jsonc
133
- {
134
- "onDemandMcpServers": {
135
- "unityMCP": {
136
- "type": "local",
137
- "command": [
138
- "C:\\Users\\evila\\.local\\bin\\uvx.exe",
139
- "--offline",
140
- "--from",
141
- "mcpforunityserver==9.7.1",
142
- "mcp-for-unity",
143
- "--transport",
144
- "stdio"
145
- ],
146
- "enabled": true
147
- }
148
- }
149
- }
150
- ```
151
-
152
- This matches OpenCode's local MCP shape: `type: "local"`, `command` as an array, optional `environment`, optional `timeout`, and optional `enabled`. Raven also supports `cwd` and `description`. `enabled` defaults to `true`; set it to `false` to keep a server in config without loading it.
153
-
154
- `description` is user-authored and never overwritten. Raven fills missing generated metadata after startup or when you run `/raven mcp refresh [server]`, storing tool summaries, MCP health, and avoided schema-load estimates separately in `~/.config/opencode/opencode-raven/autogenerated-on-demand-mcp-metadata.json`.
155
-
156
- Raven also writes generated main-model guidance to `~/.config/opencode/opencode-raven/autogenerated-on-demand-guidance.md` and injects that file into OpenCode instructions at startup.
157
-
158
- ## Configuration
159
-
160
- Raven config lives at `~/.config/opencode/opencode-raven/raven-config.json`. It is auto-created on first run and auto-migrated on startup when new config fields are added. Old root files such as `~/.config/opencode/raven-config.json` are moved into the `opencode-raven` folder automatically.
161
-
162
- Edit config manually or use `/raven` commands:
163
-
164
- ```json
165
- {
166
- "enabled": true,
167
- "model": "opencode/deepseek-v4-flash-free",
168
- "reasoning_effort": "low",
169
- "ravenInstructions": "",
170
- "routeTools": ["grep", "glob", "webfetch", "fetch", "websearch", "bash"],
171
- "routeToolKeywords": [],
172
- "onDemandMcpDescriptionDetail": "full",
173
- "onDemandMcpServers": {
174
- "context7": {
175
- "enabled": true,
176
- "type": "remote",
177
- "url": "https://mcp.context7.com/mcp",
178
- "description": "Library/framework documentation lookup."
179
- },
180
- "exa": {
181
- "enabled": true,
182
- "type": "remote",
183
- "url": "https://mcp.exa.ai/mcp",
184
- "description": "Live web search and webpage fetching."
185
- },
186
- "grep_app": {
187
- "enabled": true,
188
- "type": "remote",
189
- "url": "https://mcp.grep.app",
190
- "description": "Public GitHub code search and real-world examples."
191
- }
192
- },
193
- "excludeAgents": [],
194
- "excludeTools": [],
195
- "timeout": 600
196
- }
197
- ```
198
-
199
- | Field | Default | Description |
200
- |-------|---------|-------------|
201
- | `enabled` | `true` | Whether tool/MCP routing is active |
202
- | `model` | from `Raven.md` | Override Raven's model without editing package files |
203
- | `reasoning_effort` | from `Raven.md` | Override Raven's reasoning effort, such as `low`, `medium`, or `high` |
204
- | `ravenInstructions` | `""` | Extra instructions appended to Raven's prompt. Useful for custom MCP usage rules. |
205
- | `routeTools` | built-in search/fetch tools plus `bash` | Exact tool names hard-routed through Raven. `bash` routes only search-like bash commands, not every bash call. |
206
- | `routeToolKeywords` | `[]` | Case-insensitive substrings hard-routed through Raven for globally registered tools with non-standard names. Catches suffix-style names like `web_search_exa`. |
207
- | `onDemandMcpDescriptionDetail` | `"full"` | On-demand MCP guidance detail. `full` includes tool names/descriptions; `minimized` uses compact capability summaries. |
208
- | `onDemandMcpServers` | Context7, Exa, Grep.app | MCPs Raven connects to internally on demand, without registering full schemas in OpenCode global MCP config. Supports OpenCode-style `remote` and `local` entries. Each server supports `enabled`, defaulting to `true`. |
209
- | `excludeAgents` | `[]` | Agents that bypass Raven routing, case-insensitive. |
210
- | `excludeTools` | `[]` | Exact tools that never get blocked, even if matched by auto-routed global MCP prefixes. |
211
- | `timeout` | `600` | Max seconds for a `raven_seek` call. Provider/API retry errors and no-initial-response startup failures are reported quickly; after provider failures, routed tools tell the user how to switch Raven's model instead of retrying Raven. On timeout the session is kept for inspection. |
212
- | `stats` | auto | Session and global estimated context saved by Raven. Managed automatically. |
213
-
214
- Use `ravenInstructions` for extra Raven-only guidance, such as how to use custom MCPs:
215
-
216
- ```json
217
- {
218
- "ravenInstructions": "For Linear requests, prefer assigned open issues and include issue keys in the answer."
219
- }
220
- ```
221
-
222
- ## Routing And Exceptions
223
-
224
- By default, Raven routes these built-in tools and auto-routes globally configured MCPs by detected server name:
225
-
226
- | Config | Default |
227
- |--------|---------|
228
- | `routeTools` | `grep`, `glob`, `webfetch`, `fetch`, `websearch`, `bash` |
229
- | `routeToolKeywords` | none |
230
-
231
- Global MCPs configured in OpenCode are auto-routed through Raven by server name. For example, an MCP named `linear` routes tools named `linear_*`. This works for any MCP whose OpenCode tool names use the normal `<server>_<tool>` prefix. Matching is case-insensitive.
232
-
233
- If a server uses suffix-style or mixed tool names, route by keyword instead. For example, `exa` catches names like `web_search_exa` and `web_fetch_exa`:
234
-
235
- ```txt
236
- /raven route keyword add exa
237
- ```
238
-
239
- If an MCP is routed but one tool should remain direct, add the exact tool to `excludeTools`:
240
-
241
- ```json
242
- {
243
- "excludeTools": ["my_mcp_validate"]
244
- }
245
- ```
246
-
247
- To route one specific tool without routing the whole MCP server:
248
-
249
- ```txt
250
- /raven route tool add linear_search_issues
251
- ```
252
-
253
- `bash` is intercepted only while `bash` is included in `routeTools` and the command matches a primary search/discovery pattern.
254
-
255
- | Pattern | Examples |
256
- |---------|----------|
257
- | Content search | `rg`, `grep`, `egrep`, `fgrep`, `git grep`, `ack`, `ag`, `findstr`, `Select-String` |
258
- | Filesystem exploration | `Get-ChildItem -Recurse`, `gci -Recurse`, `Get-ChildItem -Filter`, `find -name`, `find -type`, `ls -R`, `ls --recursive`, `dir /s` |
259
- | Shell bypass | `cmd /c dir /s`, `cmd /c findstr`, `cmd /c find`, `cmd /c tree` |
260
-
261
- Unrestricted for non-Raven agents: `read`, `task`, `subtask`, `raven_seek`, non-routed tools, and non-search `bash` commands.
262
-
263
- Allowed output filters: piped filters like `command | grep ...`, `command | rg ...`, `command | findstr ...`, and `command | head ...` are allowed. Raven only blocks search commands when they are used as primary discovery commands, not when they filter bounded output from another command.
264
-
265
- To stop routing search-like bash commands, remove `bash` from `routeTools`:
266
-
267
- ```txt
268
- /raven route tool remove bash
269
- ```
270
-
271
- Quoted content and shell comments in bash commands are stripped before pattern matching. For example, `echo "use grep here"` and `# use grep later` do not trigger routing.
272
-
273
- ## What Raven Saves
274
-
275
- Raven saves context from tool call results and raw MCP output by moving the work into a Raven session and returning a compact answer. On-demand MCPs also avoid loading full MCP tool schemas into the main OpenCode session because Raven connects to them internally through `raven_mcp`.
276
-
277
- MCPs configured directly in OpenCode `opencode.jsonc` still load globally and may increase the main session's starting context. Use `onDemandMcpServers` for MCPs you want Raven to keep behind the context firewall.
278
-
279
- `/raven stats` uses a balanced estimate: Raven's final session token total minus the first Raven assistant turn's input/cache baseline, then minus the compact answer returned to the main session. This counts tool/web/MCP result context Raven handled while avoiding Raven's starting prompt and tool-schema overhead.
280
-
281
- `Avoided MCP schema load` is a separate estimate based on full loaded on-demand MCP tool schemas discovered by Raven but not loaded into the main model. Failed or pending MCPs do not count toward this total. It is stored in autogenerated MCP metadata and shown separately from delegated session savings.
282
-
283
- ## How It Works
284
-
285
- | Hook | What it does |
286
- |------|--------------|
287
- | `config` | Registers Raven agent, loads MCP routing guidance, and starts on-demand MCP health/metadata checks. Bundled MCPs are on-demand by default, not injected into global OpenCode MCP config. |
288
- | `tool` | Registers `raven_seek` and Raven-only `raven_mcp`. `raven_seek` creates Raven sessions with timeout, error recovery, timing, and session tree visibility. Tracks context saved for stats. |
289
- | `chat.message` | Tracks agent to session mapping for allowlist and Raven exclusion. |
290
- | `event` | Shows startup update and MCP failure notifications after the TUI event stream is ready. |
291
- | `command.execute.before` | Handles `/raven help`, routing commands, MCP commands, update checks, model settings, timeout, and stats. |
292
- | `tool.execute.before` | Hard-blocks configured tools/MCPs for non-Raven, non-excluded agents. Error output gives the next `raven_seek(query="...")` call or recovery instructions if Raven's provider is unavailable. Tracks direct Raven subagent calls for stats. |
293
- | `tool.execute.after` | Tracks direct `@Raven` calls for context-saved stats. |
294
-
295
- Raven routing guidance is loaded through OpenCode instructions at startup. Subagent prompts are not modified; if a non-Raven agent calls a routed tool, Raven blocks it and returns the exact `raven_seek(query="...")` call to use.
296
-
297
- ## Agent Capabilities
298
-
299
- Raven itself has access to these tools, blocked for other agents when configured by the plugin:
300
-
301
- | Tool / MCP | Purpose |
302
- |------------|---------|
303
- | `read`, `glob`, `grep`, `list` | Local codebase inspection |
304
- | `bash` | Full local shell access, including `rg`, `grep`, `dir`, `ls`, `Get-ChildItem`, and `find` |
305
- | `external_directory` | Allowed, with no permission prompts when accessing paths outside the workspace |
306
- | `raven_mcp` | Raven-only bridge to on-demand remote/local MCP servers |
307
- | Context7 | On-demand library/framework/SDK/API docs |
308
- | Exa AI | On-demand web search, news, pages, products |
309
- | Grep.app | On-demand public GitHub examples |
310
-
311
- `raven_seek` is denied inside Raven itself so Raven cannot recursively call its own wrapper tool. Raven uses direct tools, globally available MCPs, and `raven_mcp` for on-demand MCPs instead.
312
-
313
- Raven returns compact findings: answer, sources, relevant details, recommended next step, and uncertainty.
314
-
315
- ## Disclaimer
316
-
317
- opencode-raven is not built by the OpenCode team and is not affiliated with OpenCode in any way.
1
+ <div align="center">
2
+ <h1>opencode-raven</h1>
3
+ <p><strong>Keep noisy tool work out of your main OpenCode context.</strong></p>
4
+ <p>
5
+ <a href="https://www.npmjs.com/package/opencode-raven"><img src="https://img.shields.io/npm/v/opencode-raven.svg" alt="npm version" /></a>
6
+ <a href="https://www.npmjs.com/package/opencode-raven"><img src="https://img.shields.io/npm/dm/opencode-raven.svg" alt="npm downloads" /></a>
7
+ <a href="LICENSE"><img src="https://img.shields.io/npm/l/opencode-raven.svg" alt="license" /></a>
8
+ </p>
9
+ </div>
10
+
11
+ <table>
12
+ <tr>
13
+ <td width="28%" align="center" valign="middle">
14
+ <img src="Raven.png" alt="Raven" width="180" />
15
+ </td>
16
+ <td valign="top">
17
+ <h2>Why Raven</h2>
18
+ <p>Raven delegates search, web, documentation, GitHub, command-inspection, and MCP work to a focused subagent, then returns a compact answer to the main session.</p>
19
+ <ul>
20
+ <li>Routes OpenCode tools and globally configured MCPs through <code>raven_seek</code>.</li>
21
+ <li>Keeps optional on-demand MCP schemas out of the main model's tool list.</li>
22
+ <li>Preconfigures Context7, Exa, and Grep.app endpoints.</li>
23
+ <li>Tracks estimated main-session context avoided by delegation.</li>
24
+ </ul>
25
+ </td>
26
+ </tr>
27
+ </table>
28
+
29
+ ## Install
30
+
31
+ Raven requires OpenCode 1.15.12 or newer. Add it to `opencode.jsonc`:
32
+
33
+ ```jsonc
34
+ {
35
+ "plugin": ["opencode-raven"]
36
+ }
37
+ ```
38
+
39
+ Restart OpenCode, then run `/raven` to verify the loaded version, model, routing, MCP health, and estimated savings.
40
+
41
+ OpenCode resolves the package from npm and caches it automatically.
42
+
43
+ ## Example
44
+
45
+ <p align="center">
46
+ <img src="example.gif" alt="Raven automatically delegating web research while reducing main-session context" />
47
+ </p>
48
+
49
+ In this run, Raven handled the search-heavy web research in a child session and returned only the compact findings, keeping roughly 71K tokens of estimated tool and search context from flooding the main session. Actual savings vary by task, model, and tool output.
50
+
51
+ ## How It Works
52
+
53
+ **Raven works automatically.** Ask OpenCode for what you need as usual. You do not need to mention Raven, run a command, or manually call a delegation tool.
54
+
55
+ 1. Your agent attempts to use a routed search, fetch, shell-discovery, or MCP tool.
56
+ 2. Raven blocks the noisy direct call and gives the agent the exact `raven_seek` retry.
57
+ 3. The agent continues automatically through a linked Raven child session.
58
+ 4. Raven performs the tool-heavy work and returns only compact findings to the main session.
59
+
60
+ The main model receives Raven's final answer instead of its raw tool output. Child sessions remain available in OpenCode's session/subagent view for inspection.
61
+
62
+ For direct control, mention `@Raven` in any chat. This sends the request straight to the Raven agent, but it is optional and not required for automatic routing.
63
+
64
+ Under the hood, Raven registers two tools:
65
+
66
+ | Tool | Purpose |
67
+ |------|---------|
68
+ | `raven_seek` | Creates a linked Raven child session and returns its compact result. |
69
+ | `raven_mcp` | Raven-only bridge to MCPs configured under `onDemandMcpServers`. |
70
+
71
+ OpenCode's built-in tools already exist; Raven routes selected calls instead of replacing those tools. Global MCPs also remain globally registered, so their schemas still enter the main session even when Raven routes their calls.
72
+
73
+ On-demand MCPs are different: Raven discovers and calls them internally, so their full schemas are not registered globally. Enabled servers are probed after startup to discover tools and health, then per-session connections are opened when Raven uses them. "On-demand" describes schema exposure and normal use, not the absence of a startup health probe.
74
+
75
+ ## Configuration
76
+
77
+ Raven creates its global configuration here:
78
+
79
+ ```txt
80
+ ~/.config/opencode/opencode-raven/raven-config.json
81
+ ```
82
+
83
+ Manual edits require an OpenCode restart. `/raven on`, `/raven off`, routing changes, and timeout changes apply immediately unless the command says otherwise.
84
+
85
+ | Field | Fresh-install default | Description |
86
+ |-------|-----------------------|-------------|
87
+ | `enabled` | `true` | Enables hard routing. It does not disable Raven's update check or MCP health probes. |
88
+ | `model` | From `Raven.md` | Raven model override. Availability and pricing depend on the provider. |
89
+ | `reasoning_effort` | `low` | Raven model reasoning option. |
90
+ | `ravenInstructions` | `""` | Extra Raven-only instructions. |
91
+ | `routeTools` | Search/fetch tools plus `bash` | Exact tools routed through Raven. `bash` only intercepts search-like commands. |
92
+ | `routeToolKeywords` | `[]` | Case-insensitive tool-name substrings, useful for nonstandard MCP tool names. |
93
+ | `onDemandMcpDescriptionDetail` | `"full"` | `full` includes tool names and short summaries; `minimized` includes capability summaries only. |
94
+ | `onDemandMcpServers` | Context7, Exa, Grep.app | Remote HTTP/SSE or local stdio MCP definitions. |
95
+ | `excludeAgents` | `[]` | Agents allowed to bypass routing. |
96
+ | `excludeTools` | `[]` | Exact tools never routed by Raven. |
97
+ | `timeout` | `600` | Raven delegation and fallback MCP timeout in seconds; minimum 10. |
98
+
99
+ ## On-Demand MCPs
100
+
101
+ Fresh installs include:
102
+
103
+ | MCP | Endpoint | Authentication |
104
+ |-----|----------|----------------|
105
+ | Context7 | `https://mcp.context7.com/mcp` | Optional key for higher limits |
106
+ | Exa | `https://mcp.exa.ai/mcp` | Optional key for higher limits |
107
+ | Grep.app | `https://mcp.grep.app` | Public API |
108
+
109
+ Provider access policies can change. `/raven mcp` shows the result of Raven's current startup probe.
110
+
111
+ Merge changes into the existing `onDemandMcpServers` object; replacing it removes omitted defaults. Header and environment values support `{env:VARIABLE}` placeholders.
112
+
113
+ Custom remote MCP or keyed endpoint:
114
+
115
+ ```jsonc
116
+ {
117
+ "onDemandMcpServers": {
118
+ "myDocs": {
119
+ "type": "remote",
120
+ "url": "https://example.com/mcp",
121
+ "headers": { "Authorization": "Bearer {env:MY_DOCS_TOKEN}" }
122
+ }
123
+ }
124
+ }
125
+ ```
126
+
127
+ Custom local stdio MCP:
128
+
129
+ ```jsonc
130
+ {
131
+ "onDemandMcpServers": {
132
+ "myLocal": {
133
+ "type": "local",
134
+ "command": ["bunx", "some-mcp-server"],
135
+ "environment": { "API_KEY": "{env:MY_LOCAL_KEY}" },
136
+ "cwd": "C:\\path\\to\\workspace",
137
+ "timeout": 60000
138
+ }
139
+ }
140
+ }
141
+ ```
142
+
143
+ Per-server `timeout` values are milliseconds. Local servers inherit the OpenCode process environment. Set `enabled: false` to keep an entry without probing or loading it.
144
+
145
+ Generated MCP metadata and main-model guidance live beside `raven-config.json`. Refresh them with `/raven mcp refresh [server]`.
146
+
147
+ ## Routing
148
+
149
+ Default routed tools are `grep`, `glob`, `webfetch`, `fetch`, `websearch`, and search-like `bash` commands.
150
+
151
+ Global MCPs are automatically routed when their OpenCode tool names use the normal `<server>_<tool>` prefix. Use a keyword for suffix-style names:
152
+
153
+ ```txt
154
+ /raven route keyword add exa
155
+ ```
156
+
157
+ Route or unroute exact tools:
158
+
159
+ ```txt
160
+ /raven route tool add linear_search_issues
161
+ /raven route tool remove bash
162
+ ```
163
+
164
+ `excludeTools` leaves selected tools direct even if their MCP prefix is routed. `excludeAgents` bypasses routing for selected agents.
165
+
166
+ When `bash` is routed, Raven intercepts primary discovery commands such as `rg`, recursive `grep`, `find -name`, `dir /s`, and `Get-ChildItem -Recurse`, including common quoted shell wrappers. Bounded output filters such as `command | grep ...` remain direct.
167
+
168
+ ## Commands
169
+
170
+ | Command | Action |
171
+ |---------|--------|
172
+ | `/raven` | Show status, routing, MCP health, version, model, timeout, and stats. |
173
+ | `/raven help` | Show command help. |
174
+ | `/raven on` / `/raven off` | Enable or disable hard routing. |
175
+ | `/raven route` | Show and edit routed tools and keywords. |
176
+ | `/raven mcp` | Show on-demand MCP health and generated metadata. |
177
+ | `/raven mcp refresh [server]` | Recheck MCP health and regenerate metadata. |
178
+ | `/raven mcp detail full|minimized` | Set generated guidance detail; restart afterward. |
179
+ | `/raven model <provider/model>` | Change Raven's model; restart afterward. |
180
+ | `/raven effort <value>` | Change Raven's reasoning effort; restart afterward. |
181
+ | `/raven timeout <seconds>` | Change the delegation timeout. |
182
+ | `/raven stats` | Show estimated context avoided. |
183
+ | `/raven update` | Check npm, clear Raven's OpenCode package cache when needed, and show restart instructions. |
184
+
185
+ ## Security And Privacy
186
+
187
+ Raven is optimized for autonomous inspection:
188
+
189
+ - It has read, search, unrestricted shell, external-directory, and configured MCP access without normal permission prompts.
190
+ - Its `edit` tool is denied, but shell access is not a read-only sandbox and can modify the system.
191
+ - Queries are sent to Raven's configured model provider.
192
+ - Remote MCP requests are sent to their services; local MCP entries launch local commands and inherit environment values.
193
+ - Startup performs an npm update check and probes enabled on-demand MCPs.
194
+
195
+ Review `Raven.md` and your MCP commands before using Raven in sensitive environments.
196
+
197
+ ## Context Estimates
198
+
199
+ `/raven stats` reports delegated-session context and avoided on-demand MCP schema bytes. These are heuristic estimates based on OpenCode token metadata and serialized schemas, not billing measurements or guaranteed savings.
200
+
201
+ ## Troubleshooting
202
+
203
+ - Provider or quota failure: run `/raven model <provider/model>`, then restart OpenCode.
204
+ - MCP failure: run `/raven mcp`, then `/raven mcp refresh <server>` after correcting its URL, command, environment, or credentials.
205
+ - Stale plugin version: run `/raven update`, restart OpenCode, and follow the cache-clearing instructions it prints if needed.
206
+ - Remove Raven: delete `"opencode-raven"` from `plugin`, restart, then optionally remove `~/.config/opencode/opencode-raven/`.
207
+
208
+ See [CHANGELOG.md](CHANGELOG.md) for release history.
209
+
210
+ ## Disclaimer
211
+
212
+ opencode-raven is an independent project and is not affiliated with the OpenCode team. Released under the [MIT License](LICENSE).