opencode-raven 2.0.0 → 2.1.0
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.
- package/README.md +209 -204
- package/Raven.md +14 -10
- package/example.gif +0 -0
- package/index.ts +1019 -250
- package/mcp-guidance.md +24 -21
- package/package.json +6 -2
package/README.md
CHANGED
|
@@ -4,35 +4,29 @@
|
|
|
4
4
|
<tr>
|
|
5
5
|
<td><img src="Raven.png" alt="Raven" width="768" /></td>
|
|
6
6
|
<td>
|
|
7
|
-
<strong>
|
|
8
|
-
|
|
7
|
+
<strong>Context firewall for <a href="https://opencode.ai">OpenCode</a></strong><br/>
|
|
8
|
+
Raven routes noisy search, docs, web, GitHub, and MCP calls through a free focused agent before they hit your main model, saving cost and context.
|
|
9
9
|
</td>
|
|
10
10
|
</tr>
|
|
11
11
|
</table>
|
|
12
12
|
|
|
13
|
-
##
|
|
13
|
+
## What Raven Does
|
|
14
14
|
|
|
15
|
-
Tool-heavy work floods context. Search, docs, web, GitHub examples, and verbose MCP calls can dump raw results into your expensive main model. Raven is a hard blocker-rerouter: configured tools fail closed for non-Raven agents and must be delegated through `raven_seek`, where a focused Raven agent performs the work and returns a compact answer.
|
|
16
|
-
|
|
17
|
-
Raven fixes three problems:
|
|
18
|
-
|
|
19
|
-
1. **Context flooding** — Keep noisy tool results out of the main session. Raven summarizes tool/MCP output before returning it.
|
|
20
|
-
2. **Cost** — Use a cheaper model like `opencode/deepseek-v4-flash-free` for tool-heavy work while saving your main model's context for decisions and edits.
|
|
21
|
-
3. **Enforcement** — This is not soft nudging. Raven blocks configured tools/MCP prefixes for non-Raven agents and gives them the exact `raven_seek` retry path.
|
|
22
|
-
|
|
23
|
-
Raven defaults to search/fetch/docs/GitHub routing, but it works with any MCP whose opencode tool names share a prefix.
|
|
24
|
-
|
|
25
|
-
Important limitation: opencode still loads enabled MCP tool schemas into the main session. Raven saves context from tool calls and raw results, but it cannot hide initial MCP schemas from the main model until opencode supports agent-scoped MCP visibility.
|
|
15
|
+
Tool-heavy work floods context. Search, docs, web, GitHub examples, and verbose MCP calls can dump raw results into your expensive main model. Raven is a hard blocker-rerouter: configured tools fail closed for non-Raven agents and must be delegated through `raven_seek`, where a focused Raven agent performs the work and returns a compact answer.
|
|
26
16
|
|
|
27
|
-
|
|
17
|
+
Raven fixes three problems:
|
|
28
18
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
19
|
+
1. **Context flooding** - Keep noisy tool results out of the main session. Raven summarizes tool/MCP output before returning it.
|
|
20
|
+
2. **Cost** - Use a cheaper model like `opencode/deepseek-v4-flash-free` for tool-heavy work while saving your main model's context for decisions and edits.
|
|
21
|
+
3. **Enforcement** - This is not soft nudging. Raven blocks configured tools/MCP prefixes for non-Raven agents and gives them the exact `raven_seek` retry path.
|
|
22
|
+
|
|
23
|
+
Raven defaults to routing noisy search/fetch tools and bundles Context7, Exa, and Grep.app as on-demand MCPs that are always handled behind Raven.
|
|
24
|
+
|
|
25
|
+
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.
|
|
26
|
+
|
|
27
|
+
## Install
|
|
34
28
|
|
|
35
|
-
|
|
29
|
+
Add Raven to your `opencode.jsonc` plugins:
|
|
36
30
|
|
|
37
31
|
```jsonc
|
|
38
32
|
{
|
|
@@ -40,207 +34,205 @@ Then add to your `opencode.jsonc`:
|
|
|
40
34
|
}
|
|
41
35
|
```
|
|
42
36
|
|
|
43
|
-
Restart opencode.
|
|
37
|
+
Restart opencode. It will resolve Raven from npm and cache the plugin automatically.
|
|
38
|
+
|
|
39
|
+
Raven checks for package updates and notifies you when a newer version is available. Run `/raven update`, then restart opencode.
|
|
40
|
+
|
|
41
|
+
## Quick Use
|
|
42
|
+
|
|
43
|
+
Run `/raven` to see status, routed tools, on-demand MCP health, and saved context.
|
|
44
|
+
|
|
45
|
+
When a configured tool or MCP is blocked, agents use `raven_seek` to delegate the same request through Raven:
|
|
46
|
+
|
|
47
|
+
```txt
|
|
48
|
+
raven_seek(query: "how to use useEffect cleanup")
|
|
49
|
+
raven_seek(query: "Fetch/read https://example.com and summarize install steps")
|
|
50
|
+
raven_seek(query: "Check whether archivemount/libarchive supports ISO or UDF. Use docs, web, or command output as needed.")
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
You can call Raven directly with `@Raven` in any OpenCode chat. The Raven agent runs with full filesystem and MCP access, without permission prompts.
|
|
54
|
+
|
|
55
|
+
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.
|
|
44
56
|
|
|
45
57
|
## Commands
|
|
46
58
|
|
|
47
59
|
| Command | Action |
|
|
48
60
|
|---------|--------|
|
|
49
|
-
| `/raven` | Show status
|
|
50
|
-
| `/raven
|
|
51
|
-
| `/raven
|
|
52
|
-
| `/raven
|
|
53
|
-
| `/raven route
|
|
54
|
-
| `/raven route tool
|
|
55
|
-
| `/raven route
|
|
56
|
-
| `/raven route
|
|
57
|
-
| `/raven
|
|
61
|
+
| `/raven` | Show status, version, model, routing, on-demand MCP health, stats, reasoning effort, and timeout |
|
|
62
|
+
| `/raven help` | Show all Raven commands |
|
|
63
|
+
| `/raven on` | Enable hard tool/MCP routing |
|
|
64
|
+
| `/raven off` | Disable routing so all agents can use routed tools directly |
|
|
65
|
+
| `/raven route` | Show routed tools, auto-routed global MCP prefixes, and routed tool keywords |
|
|
66
|
+
| `/raven route tool add <name>` | Route a specific tool through Raven |
|
|
67
|
+
| `/raven route tool remove <name>` | Stop routing a specific tool |
|
|
68
|
+
| `/raven route keyword add <keyword>` | Route any tool whose name contains `<keyword>` |
|
|
69
|
+
| `/raven route keyword remove <keyword>` | Stop routing a tool-name keyword |
|
|
70
|
+
| `/raven mcp` | Show on-demand MCP status and generated metadata state |
|
|
71
|
+
| `/raven mcp refresh [server]` | Recheck on-demand MCP health and regenerate tool descriptions/schema estimates |
|
|
72
|
+
| `/raven mcp detail full\|minimized` | Choose full tool descriptions or minimized capability summaries in guidance |
|
|
73
|
+
| `/raven update` | Check npm for a newer Raven, clear OpenCode's plugin cache if needed, then restart opencode |
|
|
58
74
|
| `/raven model <name>` | Change Raven's model (requires restart) |
|
|
59
75
|
| `/raven effort <value>` | Change Raven's reasoning effort (requires restart) |
|
|
60
|
-
| `/raven timeout <seconds>` | Change raven_seek timeout
|
|
61
|
-
| `/raven stats` | Show context saved
|
|
76
|
+
| `/raven timeout <seconds>` | Change `raven_seek` timeout, minimum 10 seconds |
|
|
77
|
+
| `/raven stats` | Show estimated context saved, including avoided MCP schema load, session, and all-time totals |
|
|
62
78
|
|
|
63
|
-
Config persists across restarts in `~/.config/opencode/raven-config.json
|
|
79
|
+
Config persists across restarts in `~/.config/opencode/opencode-raven/raven-config.json`. It is global and shared across all projects.
|
|
64
80
|
|
|
65
|
-
##
|
|
81
|
+
## Example
|
|
66
82
|
|
|
67
|
-
|
|
83
|
+
<p align="center">
|
|
84
|
+
<img src="example.gif" alt="Raven example: searching today's top 30 AI news items while saving 71K context" />
|
|
85
|
+
</p>
|
|
68
86
|
|
|
69
|
-
|
|
87
|
+
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.
|
|
70
88
|
|
|
71
|
-
|
|
72
|
-
/raven update
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
This checks npm, clears Raven's opencode plugin cache when a newer version exists, and tells you to restart opencode.
|
|
89
|
+
## Recommended MCP Setup
|
|
76
90
|
|
|
77
|
-
|
|
91
|
+
Raven's bundled Context7, Exa, and Grep.app MCPs are on-demand by default. They live in `onDemandMcpServers`, so Raven connects to them internally through `raven_mcp` instead of registering their full tool schemas in OpenCode's global MCP config.
|
|
78
92
|
|
|
79
|
-
|
|
80
|
-
bun update --latest opencode-raven
|
|
81
|
-
# or
|
|
82
|
-
npm install opencode-raven@latest
|
|
83
|
-
```
|
|
93
|
+
On-demand MCPs are always behind Raven and do not need routing entries.
|
|
84
94
|
|
|
85
|
-
|
|
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.
|
|
86
96
|
|
|
87
|
-
|
|
88
|
-
Remove-Item -Recurse -Force "$HOME\.cache\opencode\packages\opencode-raven*"
|
|
89
|
-
```
|
|
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.
|
|
90
98
|
|
|
91
|
-
|
|
92
|
-
rm -rf ~/.cache/opencode/packages/opencode-raven*
|
|
93
|
-
```
|
|
99
|
+
All three bundled MCPs work without API keys. Add keys for higher rate limits:
|
|
94
100
|
|
|
95
|
-
|
|
101
|
+
| MCP | URL | API key |
|
|
102
|
+
|-----|-----|---------|
|
|
103
|
+
| Context7 | `https://mcp.context7.com/mcp` | Free key at [context7.com/dashboard](https://context7.com/dashboard) for higher limits |
|
|
104
|
+
| Exa AI | `https://mcp.exa.ai/mcp` | Free key at [exa.ai](https://exa.ai) for higher limits |
|
|
105
|
+
| Grep.app | `https://mcp.grep.app` | Public API, no key needed |
|
|
96
106
|
|
|
97
|
-
|
|
107
|
+
To add an API key to an on-demand MCP, edit Raven config:
|
|
98
108
|
|
|
99
|
-
|
|
109
|
+
```jsonc
|
|
110
|
+
{
|
|
111
|
+
"onDemandMcpServers": {
|
|
112
|
+
"exa": {
|
|
113
|
+
"type": "remote",
|
|
114
|
+
"url": "https://mcp.exa.ai/mcp",
|
|
115
|
+
"headers": { "x-api-key": "{env:EXA_API_KEY}" },
|
|
116
|
+
"description": "Live web search and webpage fetching."
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
```
|
|
100
121
|
|
|
101
|
-
|
|
122
|
+
To add a local stdio MCP:
|
|
102
123
|
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
124
|
+
```jsonc
|
|
125
|
+
{
|
|
126
|
+
"onDemandMcpServers": {
|
|
127
|
+
"localServer": {
|
|
128
|
+
"type": "stdio",
|
|
129
|
+
"command": "bunx",
|
|
130
|
+
"args": ["some-mcp-server"],
|
|
131
|
+
"env": { "API_KEY": "{env:API_KEY}" },
|
|
132
|
+
"cwd": "/optional/path",
|
|
133
|
+
"description": "Local MCP server."
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
107
137
|
```
|
|
108
138
|
|
|
109
|
-
|
|
139
|
+
`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`.
|
|
140
|
+
|
|
141
|
+
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.
|
|
110
142
|
|
|
111
143
|
## Configuration
|
|
112
144
|
|
|
113
|
-
|
|
145
|
+
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.
|
|
114
146
|
|
|
115
|
-
|
|
147
|
+
Edit config manually or use `/raven` commands:
|
|
116
148
|
|
|
117
149
|
```json
|
|
118
150
|
{
|
|
119
|
-
"enabled": true,
|
|
120
|
-
"model": "opencode/deepseek-v4-flash-free",
|
|
121
|
-
"reasoning_effort": "low",
|
|
122
|
-
"ravenInstructions": "",
|
|
123
|
-
"routeTools": ["grep", "glob", "webfetch", "fetch", "bash"],
|
|
124
|
-
"
|
|
125
|
-
"
|
|
126
|
-
"
|
|
127
|
-
|
|
128
|
-
|
|
151
|
+
"enabled": true,
|
|
152
|
+
"model": "opencode/deepseek-v4-flash-free",
|
|
153
|
+
"reasoning_effort": "low",
|
|
154
|
+
"ravenInstructions": "",
|
|
155
|
+
"routeTools": ["grep", "glob", "webfetch", "fetch", "websearch", "bash"],
|
|
156
|
+
"routeToolKeywords": [],
|
|
157
|
+
"onDemandMcpDescriptionDetail": "full",
|
|
158
|
+
"onDemandMcpServers": {
|
|
159
|
+
"context7": {
|
|
160
|
+
"type": "remote",
|
|
161
|
+
"url": "https://mcp.context7.com/mcp",
|
|
162
|
+
"description": "Library/framework documentation lookup."
|
|
163
|
+
},
|
|
164
|
+
"exa": {
|
|
165
|
+
"type": "remote",
|
|
166
|
+
"url": "https://mcp.exa.ai/mcp",
|
|
167
|
+
"description": "Live web search and webpage fetching."
|
|
168
|
+
},
|
|
169
|
+
"grep_app": {
|
|
170
|
+
"type": "remote",
|
|
171
|
+
"url": "https://mcp.grep.app",
|
|
172
|
+
"description": "Public GitHub code search and real-world examples."
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
"excludeAgents": [],
|
|
176
|
+
"excludeTools": [],
|
|
177
|
+
"timeout": 180
|
|
129
178
|
}
|
|
130
179
|
```
|
|
131
180
|
|
|
132
181
|
| Field | Default | Description |
|
|
133
182
|
|-------|---------|-------------|
|
|
134
|
-
| `enabled` | `true` | Whether tool/MCP routing is active |
|
|
135
|
-
| `model` |
|
|
136
|
-
| `reasoning_effort` |
|
|
137
|
-
| `ravenInstructions` | `""` | Extra instructions appended to Raven's prompt. Useful for custom MCP usage rules. |
|
|
138
|
-
| `routeTools` | built-in search/fetch tools plus `bash` | Exact tool names hard-routed through Raven. `bash`
|
|
139
|
-
| `
|
|
140
|
-
| `
|
|
141
|
-
| `
|
|
142
|
-
| `
|
|
143
|
-
| `
|
|
144
|
-
| `
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
All three MCPs work without API keys. Add keys for higher rate limits:
|
|
149
|
-
|
|
150
|
-
| MCP | URL | API key |
|
|
151
|
-
|-----|-----|---------|
|
|
152
|
-
| Context7 | `https://mcp.context7.com/mcp` | Free key at [context7.com/dashboard](https://context7.com/dashboard) — higher limits |
|
|
153
|
-
| Exa AI | `https://mcp.exa.ai/mcp` | Free key at [exa.ai](https://exa.ai) — higher limits |
|
|
154
|
-
| Grep.app | `https://mcp.grep.app` | Not available — public API, no key needed |
|
|
155
|
-
|
|
156
|
-
When `allowBundledMCPServers` is `true`, Raven auto-registers bundled Context7, Exa, and Grep.app MCP defaults. It merges those MCP defaults with your existing `opencode.jsonc` settings, preserving custom headers, URLs, and `enabled: false` overrides. Set `allowBundledMCPServers` to `false` if you do not want Raven to add bundled MCP defaults.
|
|
157
|
-
|
|
158
|
-
To add other MCPs, configure them in `opencode.jsonc`, then add their server prefix to `routeMcpServers` if you want Raven to route them. Raven does not install arbitrary MCPs from `raven-config.json`.
|
|
159
|
-
|
|
160
|
-
Use `ravenInstructions` for extra Raven-only guidance, such as how to use custom MCPs:
|
|
161
|
-
|
|
162
|
-
```json
|
|
163
|
-
{
|
|
164
|
-
"ravenInstructions": "For Linear requests, prefer assigned open issues and include issue keys in the answer."
|
|
165
|
-
}
|
|
166
|
-
```
|
|
167
|
-
|
|
168
|
-
To add an API key, override the MCP in your `opencode.jsonc` with a `headers` field:
|
|
183
|
+
| `enabled` | `true` | Whether tool/MCP routing is active |
|
|
184
|
+
| `model` | from `Raven.md` | Override Raven's model without editing package files |
|
|
185
|
+
| `reasoning_effort` | from `Raven.md` | Override Raven's reasoning effort, such as `low`, `medium`, or `high` |
|
|
186
|
+
| `ravenInstructions` | `""` | Extra instructions appended to Raven's prompt. Useful for custom MCP usage rules. |
|
|
187
|
+
| `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. |
|
|
188
|
+
| `routeToolKeywords` | `[]` | Case-insensitive substrings hard-routed through Raven for globally registered tools with non-standard names. Catches suffix-style names like `web_search_exa`. |
|
|
189
|
+
| `onDemandMcpDescriptionDetail` | `"full"` | On-demand MCP guidance detail. `full` includes tool names/descriptions; `minimized` uses compact capability summaries. |
|
|
190
|
+
| `onDemandMcpServers` | Context7, Exa, Grep.app | MCPs Raven connects to internally on demand, without registering full schemas in OpenCode global MCP config. Supports `remote` and `stdio`. |
|
|
191
|
+
| `excludeAgents` | `[]` | Agents that bypass Raven routing, case-insensitive. |
|
|
192
|
+
| `excludeTools` | `[]` | Exact tools that never get blocked, even if matched by auto-routed global MCP prefixes. |
|
|
193
|
+
| `timeout` | `180` | Max seconds for a `raven_seek` call. On timeout the session is kept for inspection. |
|
|
194
|
+
| `stats` | auto | Session and global estimated context saved by Raven. Managed automatically. |
|
|
195
|
+
|
|
196
|
+
Use `ravenInstructions` for extra Raven-only guidance, such as how to use custom MCPs:
|
|
169
197
|
|
|
170
|
-
```
|
|
198
|
+
```json
|
|
171
199
|
{
|
|
172
|
-
"
|
|
173
|
-
"exa": {
|
|
174
|
-
"type": "remote",
|
|
175
|
-
"url": "https://mcp.exa.ai/mcp",
|
|
176
|
-
"headers": { "x-api-key": "{env:EXA_API_KEY}" },
|
|
177
|
-
"enabled": true
|
|
178
|
-
}
|
|
179
|
-
}
|
|
200
|
+
"ravenInstructions": "For Linear requests, prefer assigned open issues and include issue keys in the answer."
|
|
180
201
|
}
|
|
181
202
|
```
|
|
182
203
|
|
|
183
|
-
|
|
204
|
+
## Routing And Exceptions
|
|
184
205
|
|
|
185
|
-
|
|
206
|
+
By default, Raven routes these built-in tools and auto-routes globally configured MCPs by detected server name:
|
|
207
|
+
|
|
208
|
+
| Config | Default |
|
|
209
|
+
|--------|---------|
|
|
210
|
+
| `routeTools` | `grep`, `glob`, `webfetch`, `fetch`, `websearch`, `bash` |
|
|
211
|
+
| `routeToolKeywords` | none |
|
|
212
|
+
|
|
213
|
+
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.
|
|
214
|
+
|
|
215
|
+
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`:
|
|
216
|
+
|
|
217
|
+
```txt
|
|
218
|
+
/raven route keyword add exa
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
If an MCP is routed but one tool should remain direct, add the exact tool to `excludeTools`:
|
|
222
|
+
|
|
223
|
+
```json
|
|
186
224
|
{
|
|
187
|
-
"
|
|
188
|
-
"exa": { "type": "remote", "url": "https://mcp.exa.ai/mcp", "enabled": false }
|
|
189
|
-
}
|
|
225
|
+
"excludeTools": ["my_mcp_validate"]
|
|
190
226
|
}
|
|
191
227
|
```
|
|
192
228
|
|
|
193
|
-
|
|
229
|
+
To route one specific tool without routing the whole MCP server:
|
|
194
230
|
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
| `event` | Shows startup update notifications after the TUI event stream is ready |
|
|
201
|
-
| `command.execute.before` | Handles `/raven on\|off\|route\|update\|model\|effort\|timeout\|stats\|status` |
|
|
202
|
-
| `tool.execute.before` | Hard-blocks configured tools/MCPs for non-Raven, non-excluded agents (respects `excludeTools`). Error output gives the next `raven_seek(query="...")` call. Injects dynamic `<raven_guidance>` with configured routes into subagent prompts. |
|
|
203
|
-
| `tool.execute.after` | Tracks direct `@Raven` calls for context-saved stats. |
|
|
204
|
-
|
|
205
|
-
### Routed tools (blocked and redirected except for Raven and any agents in `excludeAgents`)
|
|
206
|
-
|
|
207
|
-
By default, Raven routes these built-in tools and MCP server prefixes:
|
|
208
|
-
|
|
209
|
-
| Config | Default |
|
|
210
|
-
|------|--------|
|
|
211
|
-
| `routeTools` | `grep`, `glob`, `webfetch`, `fetch`, `bash` |
|
|
212
|
-
| `routeMcpServers` | `context7`, `exa`, `grep_app` |
|
|
213
|
-
|
|
214
|
-
To route another MCP, add its server prefix. For example, `"linear"` routes every tool named `linear_*` through Raven:
|
|
215
|
-
|
|
216
|
-
```txt
|
|
217
|
-
/raven route mcp add linear
|
|
218
|
-
```
|
|
219
|
-
|
|
220
|
-
This works for any MCP whose opencode tool names share a prefix. For example, if an MCP exposes tools named `my_mcp_search`, `my_mcp_fetch`, and `my_mcp_get_item`, this routes all of them:
|
|
221
|
-
|
|
222
|
-
```txt
|
|
223
|
-
/raven route mcp add my_mcp
|
|
224
|
-
```
|
|
225
|
-
|
|
226
|
-
The prefix must match the actual tool name before `_`. If the tools are named `project_search`, add `project`, not the display name of the MCP. Matching is case-insensitive.
|
|
227
|
-
|
|
228
|
-
If an MCP is routed but one tool should remain direct, add the exact tool to `excludeTools`:
|
|
229
|
-
|
|
230
|
-
```json
|
|
231
|
-
{
|
|
232
|
-
"routeMcpServers": ["context7", "exa", "grep_app", "my_mcp"],
|
|
233
|
-
"excludeTools": ["my_mcp_validate"]
|
|
234
|
-
}
|
|
235
|
-
```
|
|
236
|
-
|
|
237
|
-
To route one specific tool without routing the whole MCP server:
|
|
238
|
-
|
|
239
|
-
```txt
|
|
240
|
-
/raven route tool add linear_search_issues
|
|
241
|
-
```
|
|
242
|
-
|
|
243
|
-
**Bash commands** — intercepted only while `bash` is included in `routeTools` and the command matches a primary search/discovery pattern:
|
|
231
|
+
```txt
|
|
232
|
+
/raven route tool add linear_search_issues
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
`bash` is intercepted only while `bash` is included in `routeTools` and the command matches a primary search/discovery pattern.
|
|
244
236
|
|
|
245
237
|
| Pattern | Examples |
|
|
246
238
|
|---------|----------|
|
|
@@ -248,44 +240,57 @@ To route one specific tool without routing the whole MCP server:
|
|
|
248
240
|
| Filesystem exploration | `Get-ChildItem -Recurse`, `gci -Recurse`, `Get-ChildItem -Filter`, `find -name`, `find -type`, `ls -R`, `ls --recursive`, `dir /s` |
|
|
249
241
|
| Shell bypass | `cmd /c dir /s`, `cmd /c findstr`, `cmd /c find`, `cmd /c tree` |
|
|
250
242
|
|
|
251
|
-
|
|
243
|
+
Unrestricted for non-Raven agents: `read`, `task`, `subtask`, `raven_seek`, non-routed tools, and non-search `bash` commands.
|
|
252
244
|
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
To stop routing search-like bash commands, remove `bash` from `routeTools`:
|
|
256
|
-
|
|
257
|
-
```txt
|
|
258
|
-
/raven route tool remove bash
|
|
259
|
-
```
|
|
245
|
+
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.
|
|
260
246
|
|
|
261
|
-
|
|
247
|
+
To stop routing search-like bash commands, remove `bash` from `routeTools`:
|
|
248
|
+
|
|
249
|
+
```txt
|
|
250
|
+
/raven route tool remove bash
|
|
251
|
+
```
|
|
262
252
|
|
|
263
|
-
|
|
253
|
+
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.
|
|
264
254
|
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
The injected guidance includes the current `routeTools` and `routeMcpServers`, including user-added custom MCP prefixes, so subagents know which calls must go through `raven_seek`.
|
|
268
|
-
|
|
269
|
-
### What Raven Saves
|
|
270
|
-
|
|
271
|
-
Raven saves context from tool call results and raw MCP output by moving the work into a Raven session and returning a compact answer. It does not currently save context from MCP tool schemas that opencode loads into the main session when an MCP is enabled globally.
|
|
272
|
-
|
|
273
|
-
This means large MCPs may still increase the main session's starting context. Raven still prevents repeated verbose tool outputs from accumulating in the main session.
|
|
274
|
-
|
|
275
|
-
## Agent capabilities
|
|
255
|
+
## What Raven Saves
|
|
276
256
|
|
|
277
|
-
Raven
|
|
257
|
+
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`.
|
|
258
|
+
|
|
259
|
+
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.
|
|
260
|
+
|
|
261
|
+
`/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.
|
|
262
|
+
|
|
263
|
+
`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.
|
|
264
|
+
|
|
265
|
+
## How It Works
|
|
266
|
+
|
|
267
|
+
| Hook | What it does |
|
|
268
|
+
|------|--------------|
|
|
269
|
+
| `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. |
|
|
270
|
+
| `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. |
|
|
271
|
+
| `chat.message` | Tracks agent to session mapping for allowlist and Raven exclusion. |
|
|
272
|
+
| `event` | Shows startup update and MCP failure notifications after the TUI event stream is ready. |
|
|
273
|
+
| `command.execute.before` | Handles `/raven help`, routing commands, MCP commands, update checks, model settings, timeout, and stats. |
|
|
274
|
+
| `tool.execute.before` | Hard-blocks configured tools/MCPs for non-Raven, non-excluded agents. Error output gives the next `raven_seek(query="...")` call. Injects dynamic `<raven_guidance>` with configured routes into subagent prompts. |
|
|
275
|
+
| `tool.execute.after` | Tracks direct `@Raven` calls for context-saved stats. |
|
|
276
|
+
|
|
277
|
+
Every non-Raven, non-excluded subagent gets `<raven_guidance>` injected into its prompt at spawn time. The injected guidance includes `routeTools`, auto-detected global MCP prefixes, `routeToolKeywords`, and on-demand MCP capabilities.
|
|
278
|
+
|
|
279
|
+
## Agent Capabilities
|
|
280
|
+
|
|
281
|
+
Raven itself has access to these tools, blocked for other agents when configured by the plugin:
|
|
278
282
|
|
|
279
283
|
| Tool / MCP | Purpose |
|
|
280
284
|
|------------|---------|
|
|
281
285
|
| `read`, `glob`, `grep`, `list` | Local codebase inspection |
|
|
282
|
-
| `bash`
|
|
283
|
-
| `external_directory` | Allowed
|
|
284
|
-
|
|
|
285
|
-
|
|
|
286
|
-
|
|
|
287
|
-
|
|
288
|
-
|
|
286
|
+
| `bash` | Full local shell access, including `rg`, `grep`, `dir`, `ls`, `Get-ChildItem`, and `find` |
|
|
287
|
+
| `external_directory` | Allowed, with no permission prompts when accessing paths outside the workspace |
|
|
288
|
+
| `raven_mcp` | Raven-only bridge to on-demand remote/stdio MCP servers |
|
|
289
|
+
| Context7 | On-demand library/framework/SDK/API docs |
|
|
290
|
+
| Exa AI | On-demand web search, news, pages, products |
|
|
291
|
+
| Grep.app | On-demand public GitHub examples |
|
|
292
|
+
|
|
293
|
+
`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.
|
|
289
294
|
|
|
290
295
|
Raven returns compact findings: answer, sources, relevant details, recommended next step, and uncertainty.
|
|
291
296
|
|
package/Raven.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
---
|
|
2
|
-
description:
|
|
2
|
+
description: Context firewall for OpenCode that routes noisy search, docs, web, GitHub, and MCP calls through a free focused agent before they hit your main model.
|
|
3
3
|
mode: subagent
|
|
4
4
|
hidden: false
|
|
5
5
|
model: opencode/deepseek-v4-flash-free
|
|
@@ -13,14 +13,15 @@ permission:
|
|
|
13
13
|
bash: allow
|
|
14
14
|
task: deny
|
|
15
15
|
raven_seek: deny
|
|
16
|
+
raven_mcp: allow
|
|
16
17
|
external_directory: allow
|
|
17
18
|
---
|
|
18
19
|
|
|
19
20
|
You are Raven.
|
|
20
21
|
|
|
21
|
-
You search, fetch, inspect, and use routed MCPs only.
|
|
22
|
+
You search, fetch, inspect, and use routed MCPs only.
|
|
22
23
|
You return compact findings only.
|
|
23
|
-
Never call `raven_seek`; you are Raven. Use your direct tools and MCPs instead.
|
|
24
|
+
Never call `raven_seek`; you are Raven. Use your direct tools, globally available MCPs, and `raven_mcp` for on-demand MCPs instead.
|
|
24
25
|
|
|
25
26
|
When a query implies multiple independent searches, run tools in parallel (single turn) for speed.
|
|
26
27
|
|
|
@@ -34,6 +35,9 @@ Use tools/MCPs like this:
|
|
|
34
35
|
|
|
35
36
|
**MCP usage guidance:**
|
|
36
37
|
|
|
38
|
+
Use direct MCP tools when they are globally available in your tool list.
|
|
39
|
+
Use `raven_mcp` for on-demand MCPs described in your prompt. If you do not know the exact tool name, call `raven_mcp` with `operation: "list_tools"` first, then call the selected tool with `operation: "call_tool"`. For `call_tool` and `get_prompt`, pass arguments as a JSON object string in `argumentsJson`.
|
|
40
|
+
|
|
37
41
|
*Context7:*
|
|
38
42
|
Use when implementing, configuring, or debugging code that depends on a library, framework, SDK, package, or API.
|
|
39
43
|
Prefer Context7 over memory when docs may be version-specific or recently changed.
|
|
@@ -42,12 +46,12 @@ Prefer Context7 over memory when docs may be version-specific or recently change
|
|
|
42
46
|
Use for live web search, current information, company/product research, reading webpages, comparing tools, and broad external research.
|
|
43
47
|
Use Exa when the answer may depend on recent updates, pricing, docs pages, releases, or online sources.
|
|
44
48
|
|
|
45
|
-
*Grep.app:*
|
|
46
|
-
Use for searching public GitHub code examples, real-world usage patterns, config examples, and how other projects structure similar code.
|
|
47
|
-
Use Grep.app when docs are unclear or when implementation examples would help.
|
|
48
|
-
|
|
49
|
-
*Other routed MCPs:*
|
|
50
|
-
When the caller asks for a configured MCP, use that MCP directly and return a compact summary of only what the primary agent needs.
|
|
49
|
+
*Grep.app:*
|
|
50
|
+
Use for searching public GitHub code examples, real-world usage patterns, config examples, and how other projects structure similar code.
|
|
51
|
+
Use Grep.app when docs are unclear or when implementation examples would help.
|
|
52
|
+
|
|
53
|
+
*Other routed MCPs:*
|
|
54
|
+
When the caller asks for a configured MCP, use that MCP directly and return a compact summary of only what the primary agent needs.
|
|
51
55
|
|
|
52
56
|
Output format:
|
|
53
57
|
|
|
@@ -55,7 +59,7 @@ Answer:
|
|
|
55
59
|
* Short direct finding.
|
|
56
60
|
|
|
57
61
|
Sources / locations:
|
|
58
|
-
* File paths, URLs, docs, examples, MCP records, or local objects checked.
|
|
62
|
+
* File paths, URLs, docs, examples, MCP records, or local objects checked.
|
|
59
63
|
|
|
60
64
|
Relevant details:
|
|
61
65
|
* Small notes only. No long code dumps.
|
package/example.gif
ADDED
|
Binary file
|