claude-mcp-bridge 0.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/LICENSE +21 -0
- package/README.md +312 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +256 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/ping.d.ts +18 -0
- package/dist/tools/ping.d.ts.map +1 -0
- package/dist/tools/ping.js +78 -0
- package/dist/tools/ping.js.map +1 -0
- package/dist/tools/query.d.ts +27 -0
- package/dist/tools/query.d.ts.map +1 -0
- package/dist/tools/query.js +138 -0
- package/dist/tools/query.js.map +1 -0
- package/dist/tools/review.d.ts +31 -0
- package/dist/tools/review.d.ts.map +1 -0
- package/dist/tools/review.js +204 -0
- package/dist/tools/review.js.map +1 -0
- package/dist/tools/search.d.ts +23 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +50 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/structured.d.ts +27 -0
- package/dist/tools/structured.d.ts.map +1 -0
- package/dist/tools/structured.js +88 -0
- package/dist/tools/structured.js.map +1 -0
- package/dist/utils/env.d.ts +3 -0
- package/dist/utils/env.d.ts.map +1 -0
- package/dist/utils/env.js +30 -0
- package/dist/utils/env.js.map +1 -0
- package/dist/utils/errors.d.ts +5 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +58 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/files.d.ts +22 -0
- package/dist/utils/files.d.ts.map +1 -0
- package/dist/utils/files.js +60 -0
- package/dist/utils/files.js.map +1 -0
- package/dist/utils/git.d.ts +14 -0
- package/dist/utils/git.d.ts.map +1 -0
- package/dist/utils/git.js +57 -0
- package/dist/utils/git.js.map +1 -0
- package/dist/utils/model.d.ts +7 -0
- package/dist/utils/model.d.ts.map +1 -0
- package/dist/utils/model.js +45 -0
- package/dist/utils/model.js.map +1 -0
- package/dist/utils/parse.d.ts +28 -0
- package/dist/utils/parse.d.ts.map +1 -0
- package/dist/utils/parse.js +141 -0
- package/dist/utils/parse.js.map +1 -0
- package/dist/utils/prompts.d.ts +19 -0
- package/dist/utils/prompts.d.ts.map +1 -0
- package/dist/utils/prompts.js +37 -0
- package/dist/utils/prompts.js.map +1 -0
- package/dist/utils/retry.d.ts +9 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +29 -0
- package/dist/utils/retry.js.map +1 -0
- package/dist/utils/security.d.ts +18 -0
- package/dist/utils/security.d.ts.map +1 -0
- package/dist/utils/security.js +37 -0
- package/dist/utils/security.js.map +1 -0
- package/dist/utils/spawn.d.ts +30 -0
- package/dist/utils/spawn.d.ts.map +1 -0
- package/dist/utils/spawn.js +170 -0
- package/dist/utils/spawn.js.map +1 -0
- package/package.json +61 -0
- package/prompts/review-agentic.md +23 -0
- package/prompts/review-quick.md +25 -0
- package/prompts/search.md +13 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Tim Birrell
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
# claude-mcp-bridge
|
|
2
|
+
|
|
3
|
+
[](https://www.npmjs.com/package/claude-mcp-bridge)
|
|
4
|
+
[](https://opensource.org/licenses/MIT)
|
|
5
|
+
[](https://nodejs.org/)
|
|
6
|
+
[](https://www.typescriptlang.org/)
|
|
7
|
+
[](https://modelcontextprotocol.io/)
|
|
8
|
+
|
|
9
|
+
MCP server that wraps [Claude Code CLI](https://github.com/anthropics/claude-code) as a subprocess, exposing code execution, agentic review, web search, and structured output as MCP tools.
|
|
10
|
+
|
|
11
|
+
Works with any MCP client: Codex CLI, Gemini CLI, Cursor, Windsurf, VS Code, or any tool that speaks [Model Context Protocol](https://modelcontextprotocol.io/).
|
|
12
|
+
|
|
13
|
+
## Do you need this?
|
|
14
|
+
|
|
15
|
+
If you're in a terminal agent (Codex CLI, Gemini CLI) with shell access, you can call Claude Code CLI directly:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
# Quick review of current diff
|
|
19
|
+
git diff origin/main...HEAD | claude -p --bare "Review this diff for bugs and security issues"
|
|
20
|
+
|
|
21
|
+
# Agentic review (Claude reads files, follows imports, checks tests)
|
|
22
|
+
claude -p --bare --allowed-tools "Read Grep Glob Bash(git diff:*,git log:*,git show:*)" \
|
|
23
|
+
"Review the changes on this branch vs main"
|
|
24
|
+
|
|
25
|
+
# Analyze specific files
|
|
26
|
+
claude -p --bare --allowed-tools "Read" "Analyze src/utils/parse.ts for edge cases"
|
|
27
|
+
|
|
28
|
+
# With budget cap
|
|
29
|
+
claude -p --bare --max-budget-usd 0.50 "Is this retry logic sound?"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
`--bare` skips hooks, memory, and plugins for clean subprocess use. `--allowed-tools` controls exactly what Claude can access. `--max-budget-usd` prevents runaway costs.
|
|
33
|
+
|
|
34
|
+
**Use this MCP bridge instead when:**
|
|
35
|
+
- Your client has no shell access (Cursor, Windsurf, Claude Desktop, VS Code)
|
|
36
|
+
- You need structured output with native `--json-schema` validation
|
|
37
|
+
- You need session resume across calls (`--resume SESSION_ID`)
|
|
38
|
+
- You need concurrency management and security hardening
|
|
39
|
+
- You want cost metadata surfaced in MCP responses
|
|
40
|
+
|
|
41
|
+
## Installation
|
|
42
|
+
|
|
43
|
+
### Prerequisites
|
|
44
|
+
|
|
45
|
+
- Node.js >= 18
|
|
46
|
+
- [Claude Code CLI](https://github.com/anthropics/claude-code) installed and on PATH
|
|
47
|
+
- `ANTHROPIC_API_KEY` set for bare mode
|
|
48
|
+
|
|
49
|
+
### From source
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
git clone https://github.com/hampsterx/claude-mcp-bridge.git
|
|
53
|
+
cd claude-mcp-bridge
|
|
54
|
+
npm install
|
|
55
|
+
npm run build
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### MCP client configuration
|
|
59
|
+
|
|
60
|
+
Add to your MCP client config (e.g. `~/.claude/settings.json`, Cursor settings, etc.):
|
|
61
|
+
|
|
62
|
+
```json
|
|
63
|
+
{
|
|
64
|
+
"mcpServers": {
|
|
65
|
+
"claude-mcp-bridge": {
|
|
66
|
+
"command": "node",
|
|
67
|
+
"args": ["/path/to/claude-mcp-bridge/dist/index.js"],
|
|
68
|
+
"env": {
|
|
69
|
+
"ANTHROPIC_API_KEY": "sk-ant-..."
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
Or if installed globally:
|
|
77
|
+
|
|
78
|
+
```json
|
|
79
|
+
{
|
|
80
|
+
"mcpServers": {
|
|
81
|
+
"claude-mcp-bridge": {
|
|
82
|
+
"command": "claude-mcp-bridge"
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
## Tools
|
|
89
|
+
|
|
90
|
+
### `query`
|
|
91
|
+
|
|
92
|
+
Execute a prompt via Claude Code CLI with optional file context and session resume.
|
|
93
|
+
|
|
94
|
+
```json
|
|
95
|
+
{
|
|
96
|
+
"prompt": "Explain the error handling in this file",
|
|
97
|
+
"files": ["src/utils/errors.ts"],
|
|
98
|
+
"model": "sonnet",
|
|
99
|
+
"workingDirectory": "/path/to/repo",
|
|
100
|
+
"timeout": 60000,
|
|
101
|
+
"maxBudgetUsd": 0.50
|
|
102
|
+
}
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
| Parameter | Type | Default | Description |
|
|
106
|
+
|-----------|------|---------|-------------|
|
|
107
|
+
| `prompt` | string | (required) | The prompt to send to Claude |
|
|
108
|
+
| `files` | string[] | | File paths relative to workingDirectory (text or images) |
|
|
109
|
+
| `model` | string | `sonnet` | Model alias or full Claude model name |
|
|
110
|
+
| `sessionId` | string | | Session ID to resume a multi-turn conversation |
|
|
111
|
+
| `noSessionPersistence` | boolean | | Disable session persistence for one-off calls |
|
|
112
|
+
| `workingDirectory` | string | `cwd` | Working directory for file resolution and CLI execution |
|
|
113
|
+
| `timeout` | number | 60000 | Timeout in ms (120000 for image queries) |
|
|
114
|
+
| `maxResponseLength` | number | | Soft limit on response length in words |
|
|
115
|
+
| `maxBudgetUsd` | number | | Cost cap in USD |
|
|
116
|
+
| `effort` | string | | `low`, `medium`, `high`, or `max` |
|
|
117
|
+
|
|
118
|
+
Supports images (.png, .jpg, .jpeg, .gif, .webp, .bmp) up to 5MB each. Text files are inlined into the prompt; image paths are passed to Claude's Read tool.
|
|
119
|
+
|
|
120
|
+
### `structured`
|
|
121
|
+
|
|
122
|
+
Generate JSON that conforms to a provided JSON Schema using Claude CLI's native `--json-schema` validation.
|
|
123
|
+
|
|
124
|
+
```json
|
|
125
|
+
{
|
|
126
|
+
"prompt": "Extract all function signatures from this file",
|
|
127
|
+
"schema": "{\"type\":\"object\",\"properties\":{\"functions\":{\"type\":\"array\",\"items\":{\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\"},\"params\":{\"type\":\"array\",\"items\":{\"type\":\"string\"}}},\"required\":[\"name\"]}}},\"required\":[\"functions\"]}",
|
|
128
|
+
"files": ["src/index.ts"],
|
|
129
|
+
"workingDirectory": "/path/to/repo"
|
|
130
|
+
}
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
| Parameter | Type | Default | Description |
|
|
134
|
+
|-----------|------|---------|-------------|
|
|
135
|
+
| `prompt` | string | (required) | What to generate or extract |
|
|
136
|
+
| `schema` | string | (required) | JSON Schema as a JSON string (max 20KB) |
|
|
137
|
+
| `files` | string[] | | Text file paths to include as context (no images) |
|
|
138
|
+
| `model` | string | `sonnet` | Model alias or full model name |
|
|
139
|
+
| `sessionId` | string | | Session ID to resume |
|
|
140
|
+
| `noSessionPersistence` | boolean | | Disable session persistence |
|
|
141
|
+
| `workingDirectory` | string | `cwd` | Working directory for file resolution |
|
|
142
|
+
| `timeout` | number | 60000 | Timeout in ms |
|
|
143
|
+
| `maxBudgetUsd` | number | | Cost cap in USD |
|
|
144
|
+
|
|
145
|
+
Returns clean JSON in the first content block. Metadata (model, session, cost) in a separate content block so JSON parsing isn't broken.
|
|
146
|
+
|
|
147
|
+
### `review`
|
|
148
|
+
|
|
149
|
+
Repo-aware code review with two modes:
|
|
150
|
+
|
|
151
|
+
**Agentic mode** (default): Claude explores the repo using Read, Grep, Glob, and git commands. It follows imports, checks tests, and reads surrounding context. Slower but thorough.
|
|
152
|
+
|
|
153
|
+
**Quick mode** (`quick: true`): Reviews a pre-computed diff only. No tool calls, no file exploration. Faster, cheaper, good for small changes.
|
|
154
|
+
|
|
155
|
+
```json
|
|
156
|
+
{
|
|
157
|
+
"base": "main",
|
|
158
|
+
"focus": "security and error handling",
|
|
159
|
+
"workingDirectory": "/path/to/repo",
|
|
160
|
+
"maxBudgetUsd": 1.00
|
|
161
|
+
}
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
| Parameter | Type | Default | Description |
|
|
165
|
+
|-----------|------|---------|-------------|
|
|
166
|
+
| `uncommitted` | boolean | `true` | Review uncommitted changes (staged + unstaged) |
|
|
167
|
+
| `base` | string | | Base branch/ref to diff against (overrides uncommitted) |
|
|
168
|
+
| `focus` | string | | Review focus area (e.g. "security", "error handling") |
|
|
169
|
+
| `quick` | boolean | `false` | Use quick (diff-only) mode instead of agentic |
|
|
170
|
+
| `model` | string | `opus` | Model alias or full model name |
|
|
171
|
+
| `sessionId` | string | | Session ID to resume |
|
|
172
|
+
| `noSessionPersistence` | boolean | | Disable session persistence |
|
|
173
|
+
| `workingDirectory` | string | `cwd` | Repository root |
|
|
174
|
+
| `timeout` | number | 300000 / 120000 | 5min (agentic) or 2min (quick) |
|
|
175
|
+
| `maxResponseLength` | number | | Soft limit on response length in words |
|
|
176
|
+
| `maxBudgetUsd` | number | | Cost cap in USD |
|
|
177
|
+
| `effort` | string | `high` | `low`, `medium`, `high`, or `max` |
|
|
178
|
+
|
|
179
|
+
Agentic mode allowed tools: `Read`, `Grep`, `Glob`, `Bash(git diff:*)`, `Bash(git log:*)`, `Bash(git show:*)`, `Bash(git status:*)`.
|
|
180
|
+
|
|
181
|
+
### `search`
|
|
182
|
+
|
|
183
|
+
Web search via Claude Code CLI using WebSearch and WebFetch tools.
|
|
184
|
+
|
|
185
|
+
```json
|
|
186
|
+
{
|
|
187
|
+
"query": "What changed in MCP SDK v1.12?",
|
|
188
|
+
"maxResponseLength": 500
|
|
189
|
+
}
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
| Parameter | Type | Default | Description |
|
|
193
|
+
|-----------|------|---------|-------------|
|
|
194
|
+
| `query` | string | (required) | Search query or question |
|
|
195
|
+
| `model` | string | `sonnet` | Model alias or full model name |
|
|
196
|
+
| `sessionId` | string | | Session ID to resume |
|
|
197
|
+
| `noSessionPersistence` | boolean | | Disable session persistence |
|
|
198
|
+
| `workingDirectory` | string | `cwd` | Working directory for the CLI |
|
|
199
|
+
| `timeout` | number | 120000 | Timeout in ms |
|
|
200
|
+
| `maxResponseLength` | number | | Soft limit on response length in words |
|
|
201
|
+
| `maxBudgetUsd` | number | | Cost cap in USD |
|
|
202
|
+
| `effort` | string | `medium` | `low`, `medium`, `high`, or `max` |
|
|
203
|
+
|
|
204
|
+
### `ping`
|
|
205
|
+
|
|
206
|
+
Health check. No parameters. Returns CLI availability, auth status, configured models, server version, and capability flags.
|
|
207
|
+
|
|
208
|
+
```
|
|
209
|
+
cliFound: true
|
|
210
|
+
version: 1.0.33 (Claude Code)
|
|
211
|
+
authStatus: ok
|
|
212
|
+
defaultModel: sonnet
|
|
213
|
+
fallbackModel: haiku
|
|
214
|
+
serverVersion: 0.1.0
|
|
215
|
+
nodeVersion: v22.12.0
|
|
216
|
+
maxConcurrent: 3
|
|
217
|
+
capabilities: bareMode=true, jsonOutput=true, jsonSchema=true, sessionResume=true
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## Configuration
|
|
221
|
+
|
|
222
|
+
All configuration is through environment variables. None are required if Claude CLI is on PATH and `ANTHROPIC_API_KEY` is already set in your environment.
|
|
223
|
+
|
|
224
|
+
### Models
|
|
225
|
+
|
|
226
|
+
| Variable | Default | Description |
|
|
227
|
+
|----------|---------|-------------|
|
|
228
|
+
| `CLAUDE_DEFAULT_MODEL` | | Shared default for all tools |
|
|
229
|
+
| `CLAUDE_QUERY_MODEL` | `sonnet` | Default model for query |
|
|
230
|
+
| `CLAUDE_STRUCTURED_MODEL` | `sonnet` | Default model for structured |
|
|
231
|
+
| `CLAUDE_SEARCH_MODEL` | `sonnet` | Default model for search |
|
|
232
|
+
| `CLAUDE_REVIEW_MODEL` | `opus` | Default model for review |
|
|
233
|
+
| `CLAUDE_FALLBACK_MODEL` | `haiku` | Fallback on quota exhaustion (set to `none` to disable) |
|
|
234
|
+
|
|
235
|
+
Model resolution order: explicit parameter > tool-specific env var > `CLAUDE_DEFAULT_MODEL` > built-in default.
|
|
236
|
+
|
|
237
|
+
### Effort and budget
|
|
238
|
+
|
|
239
|
+
| Variable | Default | Description |
|
|
240
|
+
|----------|---------|-------------|
|
|
241
|
+
| `CLAUDE_REVIEW_EFFORT` | `high` | Default effort for review tool |
|
|
242
|
+
| `CLAUDE_SEARCH_EFFORT` | `medium` | Default effort for search tool |
|
|
243
|
+
| `CLAUDE_QUERY_EFFORT` | | Default effort for query tool |
|
|
244
|
+
| `CLAUDE_MAX_BUDGET_USD` | | Global cost cap in USD (per call) |
|
|
245
|
+
|
|
246
|
+
### Runtime
|
|
247
|
+
|
|
248
|
+
| Variable | Default | Description |
|
|
249
|
+
|----------|---------|-------------|
|
|
250
|
+
| `CLAUDE_MAX_CONCURRENT` | `3` | Max simultaneous Claude CLI processes |
|
|
251
|
+
| `CLAUDE_CLI_PATH` | `claude` | Custom path to Claude CLI binary |
|
|
252
|
+
| `ANTHROPIC_API_KEY` | | API key for bare mode auth |
|
|
253
|
+
|
|
254
|
+
## Security
|
|
255
|
+
|
|
256
|
+
### Subprocess environment isolation
|
|
257
|
+
|
|
258
|
+
Only a strict allowlist of environment variables is passed to Claude CLI subprocesses: `ANTHROPIC_API_KEY`, `CLAUDE_CONFIG_DIR`, `CLAUDE_CODE_USE_BEDROCK`, `CLAUDE_CODE_USE_VERTEX`, `AWS_REGION`, `AWS_DEFAULT_REGION`, `HOME`, `PATH`, `USER`, `SHELL`, `LANG`, `TERM`, `XDG_CONFIG_HOME`. Everything else is stripped.
|
|
259
|
+
|
|
260
|
+
### Path sandboxing
|
|
261
|
+
|
|
262
|
+
All file paths are resolved to absolute paths via `realpath()` and verified to stay within the working directory. Symlink traversal and `..` path components that escape the sandbox are rejected.
|
|
263
|
+
|
|
264
|
+
### Git argument injection prevention
|
|
265
|
+
|
|
266
|
+
The `base` parameter in the review tool is validated against `/^[\w./-]+$/` before being passed to git commands, preventing argument injection (e.g. a malicious ref like `--output=/tmp/pwned`).
|
|
267
|
+
|
|
268
|
+
### Output redaction
|
|
269
|
+
|
|
270
|
+
CLI output is scanned for sensitive patterns before being returned: Anthropic API keys (`sk-ant-*`), Bearer tokens, token assignments, and base64-encoded strings that look like secrets are replaced with `[REDACTED]`.
|
|
271
|
+
|
|
272
|
+
### Limits
|
|
273
|
+
|
|
274
|
+
| Limit | Value |
|
|
275
|
+
|-------|-------|
|
|
276
|
+
| Max file size (text) | 1 MB |
|
|
277
|
+
| Max file size (image) | 5 MB |
|
|
278
|
+
| Max files per request | 20 |
|
|
279
|
+
| Max JSON Schema size | 20 KB |
|
|
280
|
+
| Hard timeout cap | 10 minutes |
|
|
281
|
+
| Concurrency queue timeout | 30 seconds |
|
|
282
|
+
|
|
283
|
+
## Concurrency
|
|
284
|
+
|
|
285
|
+
Requests are queued with a FIFO scheduler. Default: 3 concurrent Claude CLI processes. If all slots are busy, new requests wait up to 30 seconds before being rejected. Timed-out processes are killed with SIGTERM, then SIGKILL after 5 seconds. On Unix, the entire process group is killed to clean up child processes.
|
|
286
|
+
|
|
287
|
+
## Development
|
|
288
|
+
|
|
289
|
+
```bash
|
|
290
|
+
npm run build # Compile TypeScript
|
|
291
|
+
npm run dev # Watch mode
|
|
292
|
+
npm test # Run unit tests (vitest)
|
|
293
|
+
npm run lint # ESLint
|
|
294
|
+
npm run typecheck # Type check without emitting
|
|
295
|
+
npm run smoke # Smoke test against live Claude CLI
|
|
296
|
+
```
|
|
297
|
+
|
|
298
|
+
### Smoke tests
|
|
299
|
+
|
|
300
|
+
```bash
|
|
301
|
+
node scripts/smoke-test.mjs query ~/my-repo
|
|
302
|
+
node scripts/smoke-test.mjs structured ~/my-repo
|
|
303
|
+
node scripts/smoke-test.mjs review ~/my-repo
|
|
304
|
+
node scripts/smoke-test.mjs search
|
|
305
|
+
node scripts/smoke-test.mjs ping
|
|
306
|
+
```
|
|
307
|
+
|
|
308
|
+
Requires Claude CLI installed and `ANTHROPIC_API_KEY` set.
|
|
309
|
+
|
|
310
|
+
## License
|
|
311
|
+
|
|
312
|
+
MIT
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,256 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { createRequire } from "node:module";
|
|
3
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import { executeQuery } from "./tools/query.js";
|
|
7
|
+
import { executeReview } from "./tools/review.js";
|
|
8
|
+
import { executeSearch } from "./tools/search.js";
|
|
9
|
+
import { executePing } from "./tools/ping.js";
|
|
10
|
+
import { executeStructured } from "./tools/structured.js";
|
|
11
|
+
import { getErrorMessage } from "./utils/errors.js";
|
|
12
|
+
const require = createRequire(import.meta.url);
|
|
13
|
+
const { version: PKG_VERSION } = require("../package.json");
|
|
14
|
+
const server = new McpServer({
|
|
15
|
+
name: "claude-mcp-bridge",
|
|
16
|
+
version: PKG_VERSION,
|
|
17
|
+
});
|
|
18
|
+
function appendMeta(base, meta) {
|
|
19
|
+
return meta.length > 0 ? `${base}\n\n---\n${meta.join("\n")}` : base;
|
|
20
|
+
}
|
|
21
|
+
server.tool("query", "Execute a prompt via Claude Code CLI with optional file context and session resume.", {
|
|
22
|
+
prompt: z.string().describe("The prompt to send to Claude"),
|
|
23
|
+
files: z
|
|
24
|
+
.array(z.string())
|
|
25
|
+
.optional()
|
|
26
|
+
.describe("File paths (text or images) relative to workingDirectory"),
|
|
27
|
+
model: z.string().optional().describe("Model alias or full Claude model name"),
|
|
28
|
+
sessionId: z
|
|
29
|
+
.string()
|
|
30
|
+
.optional()
|
|
31
|
+
.describe("Claude session ID to resume with --resume"),
|
|
32
|
+
noSessionPersistence: z
|
|
33
|
+
.boolean()
|
|
34
|
+
.optional()
|
|
35
|
+
.describe("Disable session persistence for ephemeral print calls"),
|
|
36
|
+
workingDirectory: z
|
|
37
|
+
.string()
|
|
38
|
+
.optional()
|
|
39
|
+
.describe("Working directory for file resolution and CLI execution"),
|
|
40
|
+
timeout: z
|
|
41
|
+
.number()
|
|
42
|
+
.optional()
|
|
43
|
+
.describe("Timeout in milliseconds (default: 60000, image queries: 120000)"),
|
|
44
|
+
maxResponseLength: z
|
|
45
|
+
.number()
|
|
46
|
+
.int()
|
|
47
|
+
.positive()
|
|
48
|
+
.optional()
|
|
49
|
+
.describe("Soft limit on response length in words"),
|
|
50
|
+
maxBudgetUsd: z
|
|
51
|
+
.number()
|
|
52
|
+
.positive()
|
|
53
|
+
.optional()
|
|
54
|
+
.describe("Maximum cost budget in USD for this call (passed to --max-budget-usd)"),
|
|
55
|
+
effort: z
|
|
56
|
+
.string()
|
|
57
|
+
.optional()
|
|
58
|
+
.describe("Effort level: low, medium, high, or max (passed to --effort)"),
|
|
59
|
+
}, async (input) => {
|
|
60
|
+
try {
|
|
61
|
+
const result = await executeQuery(input);
|
|
62
|
+
const meta = [];
|
|
63
|
+
if (result.filesIncluded.length > 0)
|
|
64
|
+
meta.push(`Files included: ${result.filesIncluded.join(", ")}`);
|
|
65
|
+
if (result.imagesIncluded.length > 0)
|
|
66
|
+
meta.push(`Images included: ${result.imagesIncluded.join(", ")}`);
|
|
67
|
+
if (result.filesSkipped.length > 0)
|
|
68
|
+
meta.push(`Files skipped: ${result.filesSkipped.join(", ")}`);
|
|
69
|
+
if (result.model)
|
|
70
|
+
meta.push(`Model: ${result.model}`);
|
|
71
|
+
if (result.sessionId)
|
|
72
|
+
meta.push(`Session: ${result.sessionId}`);
|
|
73
|
+
if (typeof result.totalCostUsd === "number")
|
|
74
|
+
meta.push(`Cost USD: ${result.totalCostUsd}`);
|
|
75
|
+
if (result.timedOut)
|
|
76
|
+
meta.push("(timed out)");
|
|
77
|
+
return {
|
|
78
|
+
content: [{ type: "text", text: appendMeta(result.response, meta) }],
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
catch (e) {
|
|
82
|
+
console.error("[query]", e);
|
|
83
|
+
return {
|
|
84
|
+
content: [{ type: "text", text: `Error: ${getErrorMessage(e)}` }],
|
|
85
|
+
isError: true,
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
server.tool("structured", "Generate JSON that conforms to a provided JSON Schema using Claude CLI native schema validation.", {
|
|
90
|
+
prompt: z.string().describe("What to generate or extract"),
|
|
91
|
+
schema: z.string().describe("JSON Schema as a JSON string"),
|
|
92
|
+
files: z
|
|
93
|
+
.array(z.string())
|
|
94
|
+
.optional()
|
|
95
|
+
.describe("Text file paths to include as context"),
|
|
96
|
+
model: z.string().optional().describe("Model alias or full Claude model name"),
|
|
97
|
+
sessionId: z
|
|
98
|
+
.string()
|
|
99
|
+
.optional()
|
|
100
|
+
.describe("Claude session ID to resume with --resume"),
|
|
101
|
+
noSessionPersistence: z
|
|
102
|
+
.boolean()
|
|
103
|
+
.optional()
|
|
104
|
+
.describe("Disable session persistence for ephemeral print calls"),
|
|
105
|
+
workingDirectory: z
|
|
106
|
+
.string()
|
|
107
|
+
.optional()
|
|
108
|
+
.describe("Working directory for file resolution and CLI execution"),
|
|
109
|
+
timeout: z
|
|
110
|
+
.number()
|
|
111
|
+
.optional()
|
|
112
|
+
.describe("Timeout in milliseconds (default: 60000)"),
|
|
113
|
+
maxBudgetUsd: z
|
|
114
|
+
.number()
|
|
115
|
+
.positive()
|
|
116
|
+
.optional()
|
|
117
|
+
.describe("Maximum cost budget in USD for this call (passed to --max-budget-usd)"),
|
|
118
|
+
}, async (input) => {
|
|
119
|
+
try {
|
|
120
|
+
const result = await executeStructured(input);
|
|
121
|
+
if (!result.valid) {
|
|
122
|
+
return {
|
|
123
|
+
content: [{ type: "text", text: `Error: ${result.errors ?? "Invalid response"}` }],
|
|
124
|
+
isError: true,
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
const content = [
|
|
128
|
+
{ type: "text", text: result.response },
|
|
129
|
+
];
|
|
130
|
+
const meta = [];
|
|
131
|
+
if (result.filesIncluded.length > 0)
|
|
132
|
+
meta.push(`Files: ${result.filesIncluded.join(", ")}`);
|
|
133
|
+
if (result.model)
|
|
134
|
+
meta.push(`Model: ${result.model}`);
|
|
135
|
+
if (result.sessionId)
|
|
136
|
+
meta.push(`Session: ${result.sessionId}`);
|
|
137
|
+
if (typeof result.totalCostUsd === "number")
|
|
138
|
+
meta.push(`Cost USD: ${result.totalCostUsd}`);
|
|
139
|
+
if (result.timedOut)
|
|
140
|
+
meta.push("(timed out)");
|
|
141
|
+
if (meta.length > 0) {
|
|
142
|
+
content.push({ type: "text", text: meta.join("\n") });
|
|
143
|
+
}
|
|
144
|
+
return { content };
|
|
145
|
+
}
|
|
146
|
+
catch (e) {
|
|
147
|
+
console.error("[structured]", e);
|
|
148
|
+
return {
|
|
149
|
+
content: [{ type: "text", text: `Error: ${getErrorMessage(e)}` }],
|
|
150
|
+
isError: true,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
server.tool("review", "Repo-aware code review. Quick mode reviews a precomputed diff. Agentic mode explores changed files with a narrow Claude tool allowlist.", {
|
|
155
|
+
uncommitted: z.boolean().optional().describe("Review uncommitted changes. Default: true"),
|
|
156
|
+
base: z.string().optional().describe("Base branch/ref to diff against. Overrides uncommitted."),
|
|
157
|
+
focus: z.string().optional().describe("Optional review focus area"),
|
|
158
|
+
quick: z.boolean().optional().describe("Use diff-only quick review mode"),
|
|
159
|
+
model: z.string().optional().describe("Model alias or full Claude model name"),
|
|
160
|
+
sessionId: z.string().optional().describe("Claude session ID to resume with --resume"),
|
|
161
|
+
noSessionPersistence: z.boolean().optional().describe("Disable session persistence for ephemeral print calls"),
|
|
162
|
+
workingDirectory: z.string().optional().describe("Repository directory"),
|
|
163
|
+
timeout: z.number().optional().describe("Timeout in milliseconds"),
|
|
164
|
+
maxResponseLength: z.number().int().positive().optional().describe("Soft limit on response length in words"),
|
|
165
|
+
maxBudgetUsd: z.number().positive().optional().describe("Maximum cost budget in USD for this call (passed to --max-budget-usd)"),
|
|
166
|
+
effort: z.string().optional().describe("Effort level: low, medium, high, or max (default: high for agentic)"),
|
|
167
|
+
}, async (input) => {
|
|
168
|
+
try {
|
|
169
|
+
const result = await executeReview(input);
|
|
170
|
+
const meta = [
|
|
171
|
+
`Diff source: ${result.diffSource}`,
|
|
172
|
+
`Mode: ${result.mode}`,
|
|
173
|
+
];
|
|
174
|
+
if (result.base)
|
|
175
|
+
meta.push(`Base: ${result.base}`);
|
|
176
|
+
if (result.model)
|
|
177
|
+
meta.push(`Model: ${result.model}`);
|
|
178
|
+
if (result.sessionId)
|
|
179
|
+
meta.push(`Session: ${result.sessionId}`);
|
|
180
|
+
if (typeof result.totalCostUsd === "number")
|
|
181
|
+
meta.push(`Cost USD: ${result.totalCostUsd}`);
|
|
182
|
+
if (result.timedOut)
|
|
183
|
+
meta.push("(timed out)");
|
|
184
|
+
return {
|
|
185
|
+
content: [{ type: "text", text: appendMeta(result.response, meta) }],
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
catch (e) {
|
|
189
|
+
console.error("[review]", e);
|
|
190
|
+
return {
|
|
191
|
+
content: [{ type: "text", text: `Error: ${getErrorMessage(e)}` }],
|
|
192
|
+
isError: true,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
});
|
|
196
|
+
server.tool("search", "Web search via Claude Code CLI using WebSearch and WebFetch.", {
|
|
197
|
+
query: z.string().describe("Search query or question"),
|
|
198
|
+
model: z.string().optional().describe("Model alias or full Claude model name"),
|
|
199
|
+
sessionId: z.string().optional().describe("Claude session ID to resume with --resume"),
|
|
200
|
+
noSessionPersistence: z.boolean().optional().describe("Disable session persistence for ephemeral print calls"),
|
|
201
|
+
workingDirectory: z.string().optional().describe("Working directory for the CLI"),
|
|
202
|
+
timeout: z.number().optional().describe("Timeout in milliseconds"),
|
|
203
|
+
maxResponseLength: z.number().int().positive().optional().describe("Soft limit on response length in words"),
|
|
204
|
+
maxBudgetUsd: z.number().positive().optional().describe("Maximum cost budget in USD for this call (passed to --max-budget-usd)"),
|
|
205
|
+
effort: z.string().optional().describe("Effort level: low, medium, high, or max (default: medium for search)"),
|
|
206
|
+
}, async (input) => {
|
|
207
|
+
try {
|
|
208
|
+
const result = await executeSearch(input);
|
|
209
|
+
const meta = [];
|
|
210
|
+
if (result.model)
|
|
211
|
+
meta.push(`Model: ${result.model}`);
|
|
212
|
+
if (result.sessionId)
|
|
213
|
+
meta.push(`Session: ${result.sessionId}`);
|
|
214
|
+
if (typeof result.totalCostUsd === "number")
|
|
215
|
+
meta.push(`Cost USD: ${result.totalCostUsd}`);
|
|
216
|
+
if (result.timedOut)
|
|
217
|
+
meta.push("(timed out)");
|
|
218
|
+
return {
|
|
219
|
+
content: [{ type: "text", text: appendMeta(result.response, meta) }],
|
|
220
|
+
};
|
|
221
|
+
}
|
|
222
|
+
catch (e) {
|
|
223
|
+
console.error("[search]", e);
|
|
224
|
+
return {
|
|
225
|
+
content: [{ type: "text", text: `Error: ${getErrorMessage(e)}` }],
|
|
226
|
+
isError: true,
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
});
|
|
230
|
+
server.tool("ping", "Check whether Claude CLI is installed and whether API-key auth is available for bare mode.", {}, async () => {
|
|
231
|
+
try {
|
|
232
|
+
const result = await executePing();
|
|
233
|
+
const lines = [
|
|
234
|
+
`cliFound: ${result.cliFound}`,
|
|
235
|
+
`version: ${result.version ?? "unknown"}`,
|
|
236
|
+
`authStatus: ${result.authStatus}`,
|
|
237
|
+
`defaultModel: ${result.defaultModel ?? "none"}`,
|
|
238
|
+
`fallbackModel: ${result.fallbackModel ?? "none"}`,
|
|
239
|
+
`serverVersion: ${result.serverVersion}`,
|
|
240
|
+
`nodeVersion: ${result.nodeVersion}`,
|
|
241
|
+
`maxConcurrent: ${result.maxConcurrent}`,
|
|
242
|
+
`capabilities: bareMode=${result.capabilities.bareMode}, jsonOutput=${result.capabilities.jsonOutput}, jsonSchema=${result.capabilities.jsonSchema}, sessionResume=${result.capabilities.sessionResume}`,
|
|
243
|
+
];
|
|
244
|
+
return { content: [{ type: "text", text: lines.join("\n") }] };
|
|
245
|
+
}
|
|
246
|
+
catch (e) {
|
|
247
|
+
console.error("[ping]", e);
|
|
248
|
+
return {
|
|
249
|
+
content: [{ type: "text", text: `Error: ${getErrorMessage(e)}` }],
|
|
250
|
+
isError: true,
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
});
|
|
254
|
+
const transport = new StdioServerTransport();
|
|
255
|
+
await server.connect(transport);
|
|
256
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,MAAM,OAAO,GAAG,aAAa,CAA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M,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface PingResult {
|
|
2
|
+
cliFound: boolean;
|
|
3
|
+
version: string | null;
|
|
4
|
+
authStatus: "ok" | "missing" | "error";
|
|
5
|
+
defaultModel: string | null;
|
|
6
|
+
fallbackModel: string | null;
|
|
7
|
+
serverVersion: string;
|
|
8
|
+
nodeVersion: string;
|
|
9
|
+
maxConcurrent: number;
|
|
10
|
+
capabilities: {
|
|
11
|
+
bareMode: boolean;
|
|
12
|
+
jsonOutput: boolean;
|
|
13
|
+
jsonSchema: boolean;
|
|
14
|
+
sessionResume: boolean;
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
export declare function executePing(): Promise<PingResult>;
|
|
18
|
+
//# sourceMappingURL=ping.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ping.d.ts","sourceRoot":"","sources":["../../src/tools/ping.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,EAAE,IAAI,GAAG,SAAS,GAAG,OAAO,CAAC;IACvC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAC5B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE;QACZ,QAAQ,EAAE,OAAO,CAAC;QAClB,UAAU,EAAE,OAAO,CAAC;QACpB,UAAU,EAAE,OAAO,CAAC;QACpB,aAAa,EAAE,OAAO,CAAC;KACxB,CAAC;CACH;AAOD,wBAAsB,WAAW,IAAI,OAAO,CAAC,UAAU,CAAC,CAmEvD"}
|