gemini-mcp-bridge 0.1.1 → 0.2.3
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 +115 -9
- package/dist/index.js +139 -6
- package/dist/index.js.map +1 -1
- package/dist/tools/ping.d.ts +2 -0
- package/dist/tools/ping.d.ts.map +1 -1
- package/dist/tools/ping.js +7 -0
- package/dist/tools/ping.js.map +1 -1
- package/dist/tools/query.d.ts +7 -0
- package/dist/tools/query.d.ts.map +1 -1
- package/dist/tools/query.js +123 -31
- package/dist/tools/query.js.map +1 -1
- package/dist/tools/review.d.ts +24 -2
- package/dist/tools/review.d.ts.map +1 -1
- package/dist/tools/review.js +151 -38
- package/dist/tools/review.js.map +1 -1
- package/dist/tools/search.d.ts +22 -0
- package/dist/tools/search.d.ts.map +1 -0
- package/dist/tools/search.js +51 -0
- package/dist/tools/search.js.map +1 -0
- package/dist/tools/structured.d.ts +26 -0
- package/dist/tools/structured.d.ts.map +1 -0
- package/dist/tools/structured.js +140 -0
- package/dist/tools/structured.js.map +1 -0
- package/dist/utils/errors.d.ts +12 -0
- package/dist/utils/errors.d.ts.map +1 -0
- package/dist/utils/errors.js +44 -0
- package/dist/utils/errors.js.map +1 -0
- package/dist/utils/files.d.ts +8 -1
- package/dist/utils/files.d.ts.map +1 -1
- package/dist/utils/files.js +18 -9
- package/dist/utils/files.js.map +1 -1
- package/dist/utils/model.d.ts +19 -0
- package/dist/utils/model.d.ts.map +1 -0
- package/dist/utils/model.js +30 -0
- package/dist/utils/model.js.map +1 -0
- package/dist/utils/parse.d.ts +21 -2
- package/dist/utils/parse.d.ts.map +1 -1
- package/dist/utils/parse.js +89 -14
- package/dist/utils/parse.js.map +1 -1
- package/dist/utils/policy.d.ts +6 -0
- package/dist/utils/policy.d.ts.map +1 -0
- package/dist/utils/policy.js +18 -0
- package/dist/utils/policy.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 +17 -0
- package/dist/utils/retry.d.ts.map +1 -0
- package/dist/utils/retry.js +42 -0
- package/dist/utils/retry.js.map +1 -0
- package/package.json +5 -2
- package/policies/review.toml +14 -0
- package/prompts/review-agentic.md +37 -0
- package/prompts/review-quick.md +25 -0
- package/prompts/search.md +13 -0
- package/prompts/structured.md +18 -0
package/README.md
CHANGED
|
@@ -1,15 +1,65 @@
|
|
|
1
1
|
# gemini-mcp-bridge
|
|
2
2
|
|
|
3
|
+
[](https://www.npmjs.com/package/gemini-mcp-bridge)
|
|
4
|
+
[](https://www.npmjs.com/package/gemini-mcp-bridge)
|
|
5
|
+
[](https://github.com/hampsterx/gemini-mcp-bridge/actions/workflows/ci.yml)
|
|
6
|
+
[](https://opensource.org/licenses/MIT)
|
|
7
|
+
[](https://nodejs.org/)
|
|
8
|
+
[](https://www.typescriptlang.org/)
|
|
9
|
+
[](https://modelcontextprotocol.io/)
|
|
10
|
+
|
|
3
11
|
MCP server that wraps [Gemini CLI](https://github.com/google-gemini/gemini-cli) as a subprocess, exposing its best features as [Model Context Protocol](https://modelcontextprotocol.io/) tools.
|
|
4
12
|
|
|
5
13
|
Works with any MCP client: Claude Code, Codex CLI, Cursor, Windsurf, VS Code, or any tool that speaks MCP.
|
|
6
14
|
|
|
15
|
+
## How does this compare to other Gemini MCP servers?
|
|
16
|
+
|
|
17
|
+
There are several Gemini MCP servers available. They split into two camps: **CLI wrappers** that spawn the Gemini CLI as a subprocess, and **API servers** that call the Gemini API directly. CLI wrappers get agentic capabilities (repo exploration, web search) for free; API servers avoid the CLI dependency.
|
|
18
|
+
|
|
19
|
+
### CLI-based (wraps Gemini CLI)
|
|
20
|
+
|
|
21
|
+
| | gemini-mcp-bridge | [@tuannvm/gemini-mcp-server](https://github.com/tuannvm/gemini-mcp-server) | [gemini-mcp-tool](https://github.com/jamubc/gemini-mcp-tool) |
|
|
22
|
+
|---|---|---|---|
|
|
23
|
+
| **CLI mode** | Agentic (CLI explores repo, runs tools) | One-shot (prompt in, response out) | One-shot |
|
|
24
|
+
| **Tools** | 5 (query, search, review, structured, ping) | 5 (gemini, web-search, analyze-media, shell, brainstorm) | 4 (ask-gemini, sandbox-test, ping, help) |
|
|
25
|
+
| **Agentic code review** | Yes (CLI diffs, reads files, follows imports) | No | No |
|
|
26
|
+
| **Web search** | Yes (via CLI's `google_web_search`) | Yes (via CLI) | Yes (via CLI) |
|
|
27
|
+
| **Structured output** | Yes (JSON Schema validated) | No | No |
|
|
28
|
+
| **Image support** | Yes (query attachments) | Yes (analyze-media tool) | No |
|
|
29
|
+
| **Shell command gen** | No | Yes (generate + execute) | No |
|
|
30
|
+
| **Google Workspace** | No | Yes (via CLI extensions) | No |
|
|
31
|
+
| **Security model** | Env allowlist, path sandboxing, shell:false | Basic | Basic |
|
|
32
|
+
|
|
33
|
+
**When to pick gemini-mcp-bridge**: You want agentic code review where Gemini explores the repo itself, web search via the CLI, or structured output with schema validation.
|
|
34
|
+
|
|
35
|
+
**When to pick @tuannvm/gemini-mcp-server**: You want one-shot Gemini queries, shell command generation, brainstorming, or Google Workspace integration via CLI extensions.
|
|
36
|
+
|
|
37
|
+
**When to pick gemini-mcp-tool**: You want a lightweight CLI wrapper focused on large-context codebase analysis.
|
|
38
|
+
|
|
39
|
+
### API-based (calls Gemini API directly)
|
|
40
|
+
|
|
41
|
+
| | [@rlabs-inc/gemini-mcp](https://github.com/RLabs-Inc/gemini-mcp) | [mcp-server-gemini](https://github.com/aliargun/mcp-server-gemini) |
|
|
42
|
+
|---|---|---|
|
|
43
|
+
| **Tools** | 37 (query, search, research, code exec, media gen, TTS, ...) | 6 (generate, analyze image, count tokens, embed, ...) |
|
|
44
|
+
| **Web search** | Yes (API-level) | Yes (API-level) |
|
|
45
|
+
| **Structured output** | Yes | JSON mode |
|
|
46
|
+
| **Image support** | Yes (analysis + generation) | Yes (analysis) |
|
|
47
|
+
| **Code execution** | Yes (Python sandbox) | No |
|
|
48
|
+
| **Media generation** | Yes (image, video, TTS) | No |
|
|
49
|
+
| **Requires Gemini CLI** | No (API key only) | No (API key only) |
|
|
50
|
+
|
|
51
|
+
**When to pick RLabs**: You want the broadest feature set (media generation, deep research, code execution, caching) and prefer API-key-only setup with no CLI dependency.
|
|
52
|
+
|
|
53
|
+
**When to pick mcp-server-gemini**: You want a simple API wrapper with good docs and broad MCP client support.
|
|
54
|
+
|
|
7
55
|
## Tools
|
|
8
56
|
|
|
9
57
|
| Tool | Description |
|
|
10
58
|
|------|-------------|
|
|
11
|
-
| **query** | Send a prompt to Gemini with optional file context. The CLI reads your GEMINI.md for project context automatically. |
|
|
12
|
-
| **
|
|
59
|
+
| **query** | Send a prompt to Gemini with optional file context (text and images). The CLI reads your GEMINI.md for project context automatically. |
|
|
60
|
+
| **search** | Google Search grounded query. Gemini searches the web and synthesizes an answer with source URLs. |
|
|
61
|
+
| **review** | Agentic code review. Gemini CLI runs inside the repo, diffs the code, reads files, follows imports, and checks tests before reviewing. Supports focused reviews (security, performance, etc.) and quick diff-only mode. |
|
|
62
|
+
| **structured** | Generate JSON conforming to a provided JSON Schema. Data extraction, classification, or any task needing machine-parseable output. |
|
|
13
63
|
| **ping** | Health check. Verifies CLI is installed and authenticated, reports versions and capabilities. |
|
|
14
64
|
|
|
15
65
|
## Prerequisites
|
|
@@ -57,26 +107,64 @@ Add to your MCP settings:
|
|
|
57
107
|
|
|
58
108
|
### query
|
|
59
109
|
|
|
60
|
-
Send a prompt to Gemini, optionally including file contents.
|
|
110
|
+
Send a prompt to Gemini, optionally including file contents and images.
|
|
111
|
+
|
|
112
|
+
Text files are read and inlined in the prompt. Image files (png, jpg, jpeg, gif, webp, bmp) trigger agentic mode so the CLI can read them natively via its `read_file` tool.
|
|
61
113
|
|
|
62
114
|
| Parameter | Type | Default | Description |
|
|
63
115
|
|-----------|------|---------|-------------|
|
|
64
116
|
| `prompt` | string | *required* | The prompt to send |
|
|
65
|
-
| `files` | string[] | `[]` | File paths (
|
|
117
|
+
| `files` | string[] | `[]` | File paths (text or images) relative to workingDirectory |
|
|
66
118
|
| `model` | string | CLI default | Model to use (e.g. `gemini-2.5-flash`) |
|
|
67
119
|
| `workingDirectory` | string | cwd | Working directory (CLI reads GEMINI.md from here) |
|
|
68
|
-
| `timeout` | number | 60000 | Timeout in ms (max 600000) |
|
|
120
|
+
| `timeout` | number | 60000 (text) / 120000 (images) | Timeout in ms (max 600000) |
|
|
121
|
+
|
|
122
|
+
### search
|
|
123
|
+
|
|
124
|
+
Google Search grounded query. Spawns Gemini CLI in agentic mode with access to `google_web_search`, then synthesizes an answer with source URLs.
|
|
125
|
+
|
|
126
|
+
| Parameter | Type | Default | Description |
|
|
127
|
+
|-----------|------|---------|-------------|
|
|
128
|
+
| `query` | string | *required* | Search query or question to research |
|
|
129
|
+
| `model` | string | CLI default | Model to use (e.g. `gemini-2.5-flash`) |
|
|
130
|
+
| `workingDirectory` | string | cwd | Working directory for the CLI |
|
|
131
|
+
| `timeout` | number | 120000 | Timeout in ms (max 600000) |
|
|
69
132
|
|
|
70
133
|
### review
|
|
71
134
|
|
|
72
|
-
|
|
135
|
+
Agentic code review. Spawns Gemini CLI inside the repository where it runs `git diff`, reads full files, follows imports, checks for tests, and reads project instruction files (CLAUDE.md, GEMINI.md, AGENTS.md, etc.) for context-aware reviews.
|
|
73
136
|
|
|
74
137
|
| Parameter | Type | Default | Description |
|
|
75
138
|
|-----------|------|---------|-------------|
|
|
76
139
|
| `uncommitted` | boolean | `true` | Review uncommitted changes (staged + unstaged) |
|
|
77
140
|
| `base` | string | — | Base branch to diff against (e.g. `main`) |
|
|
141
|
+
| `focus` | string | — | Focus area for the review (e.g. `security`, `performance`) |
|
|
142
|
+
| `quick` | boolean | `false` | Skip repo exploration, just review the diff text (faster but less context) |
|
|
78
143
|
| `workingDirectory` | string | cwd | Repository directory (auto-resolves to git root) |
|
|
79
|
-
| `timeout` | number | 120000 | Timeout in ms (max 600000) |
|
|
144
|
+
| `timeout` | number | 300000 (agentic) / 120000 (quick) | Timeout in ms (max 600000) |
|
|
145
|
+
|
|
146
|
+
The Gemini CLI has no native code review feature. Google offers a [separate extension](https://github.com/gemini-cli-extensions/code-review) that requires the GitHub MCP server and CI environment variables (`REPOSITORY`, `PULL_REQUEST_NUMBER`). This tool takes a different approach: it computes the diff locally via `git diff`, loads a prompt template (`prompts/review-agentic.md`), and spawns the CLI in agentic mode so it can read files, follow imports, and check tests itself.
|
|
147
|
+
|
|
148
|
+
### structured
|
|
149
|
+
|
|
150
|
+
Generate a JSON response conforming to a provided JSON Schema. The schema is embedded in the prompt, and the response is validated with [Ajv](https://ajv.js.org/). Returns `isError: true` with validation details if the response doesn't match.
|
|
151
|
+
|
|
152
|
+
| Parameter | Type | Default | Description |
|
|
153
|
+
|-----------|------|---------|-------------|
|
|
154
|
+
| `prompt` | string | *required* | What to generate or extract |
|
|
155
|
+
| `schema` | string | *required* | JSON Schema as a JSON string |
|
|
156
|
+
| `files` | string[] | `[]` | Text file paths to include as context (no images) |
|
|
157
|
+
| `model` | string | CLI default | Model to use (e.g. `gemini-2.5-flash`) |
|
|
158
|
+
| `workingDirectory` | string | cwd | Working directory for file paths |
|
|
159
|
+
| `timeout` | number | 60000 | Timeout in ms |
|
|
160
|
+
|
|
161
|
+
**Example:**
|
|
162
|
+
```json
|
|
163
|
+
{
|
|
164
|
+
"prompt": "Extract the person's name and age from: 'John is 30 years old'",
|
|
165
|
+
"schema": "{\"type\":\"object\",\"properties\":{\"name\":{\"type\":\"string\"},\"age\":{\"type\":\"number\"}},\"required\":[\"name\",\"age\"]}"
|
|
166
|
+
}
|
|
167
|
+
```
|
|
80
168
|
|
|
81
169
|
### ping
|
|
82
170
|
|
|
@@ -88,15 +176,33 @@ Environment variables:
|
|
|
88
176
|
|
|
89
177
|
| Variable | Default | Description |
|
|
90
178
|
|----------|---------|-------------|
|
|
179
|
+
| `GEMINI_DEFAULT_MODEL` | *(CLI default)* | Default model for all tools (e.g. `gemini-2.5-flash`). Overridden by explicit `model` parameter on individual tool calls. |
|
|
180
|
+
| `GEMINI_FALLBACK_MODEL` | `gemini-2.5-flash` | Fallback model used when the primary model returns a quota/rate-limit error. Set to `none` to disable automatic fallback. |
|
|
91
181
|
| `GEMINI_CLI_PATH` | `gemini` | Path to gemini CLI binary |
|
|
92
182
|
| `GEMINI_MAX_CONCURRENT` | `3` | Max concurrent subprocess spawns |
|
|
93
183
|
|
|
184
|
+
### Prompt Templates
|
|
185
|
+
|
|
186
|
+
The `review`, `search`, and `structured` tools use prompt templates from the `prompts/` directory:
|
|
187
|
+
|
|
188
|
+
```text
|
|
189
|
+
prompts/
|
|
190
|
+
├── review-agentic.md # Full agentic review (default)
|
|
191
|
+
├── review-quick.md # Quick diff-only review
|
|
192
|
+
├── search.md # Web search synthesis
|
|
193
|
+
└── structured.md # JSON Schema output
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
If you're running from a local clone, you can edit these to adjust review style, search instructions, or output formatting. When running via `npx`, the bundled templates are used.
|
|
197
|
+
|
|
94
198
|
## Security
|
|
95
199
|
|
|
200
|
+
> **Note on agentic mode**: The `review` (default mode), `search`, and `query` (with images) tools use `--yolo` to give Gemini CLI shell access. This means the model can execute arbitrary shell commands within the repository. A bundled policy file (`policies/review.toml`) restricts shell to read-only git commands, but the upstream CLI has a bug that prevents policy enforcement in headless mode ([google-gemini/gemini-cli#20469](https://github.com/google-gemini/gemini-cli/issues/20469)). Once the fix ships, we'll switch to policy-based filtering. The `query` tool (text-only) and `review` with `quick: true` do not use agentic mode.
|
|
201
|
+
|
|
96
202
|
- **Environment isolation**: Subprocess receives a minimal env allowlist (HOME, PATH, GOOGLE_*, GEMINI_*). Your API keys, tokens, and credentials are not leaked.
|
|
97
203
|
- **Path sandboxing**: All file paths are resolved via `realpath` and verified within the working directory. No path traversal via `..` or symlinks.
|
|
98
|
-
- **No shell
|
|
99
|
-
- **Resource limits**: Max 3 concurrent spawns (configurable), 600s hard timeout cap, 1MB per
|
|
204
|
+
- **No shell injection**: Subprocess spawned with `shell: false` and args as an array. No command injection from the bridge itself. (The CLI may execute shell commands internally in agentic mode — see note above.)
|
|
205
|
+
- **Resource limits**: Max 3 concurrent spawns (configurable), 600s hard timeout cap, 1MB per text file / 5MB per image file, 20 files max.
|
|
100
206
|
|
|
101
207
|
## License
|
|
102
208
|
|
package/dist/index.js
CHANGED
|
@@ -5,7 +5,9 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
|
|
|
5
5
|
import { z } from "zod";
|
|
6
6
|
import { executeQuery } from "./tools/query.js";
|
|
7
7
|
import { executeReview } from "./tools/review.js";
|
|
8
|
+
import { executeSearch } from "./tools/search.js";
|
|
8
9
|
import { executePing } from "./tools/ping.js";
|
|
10
|
+
import { executeStructured } from "./tools/structured.js";
|
|
9
11
|
const require = createRequire(import.meta.url);
|
|
10
12
|
const { version: PKG_VERSION } = require("../package.json");
|
|
11
13
|
const server = new McpServer({
|
|
@@ -13,12 +15,12 @@ const server = new McpServer({
|
|
|
13
15
|
version: PKG_VERSION,
|
|
14
16
|
});
|
|
15
17
|
// --- query tool ---
|
|
16
|
-
server.tool("query", "Send a prompt to Gemini CLI with optional file context. The CLI reads GEMINI.md for project context automatically.", {
|
|
18
|
+
server.tool("query", "Send a prompt to Gemini CLI with optional file context (text and images). Text files are inlined; image files (png, jpg, etc.) trigger agentic mode for native image reading. The CLI reads GEMINI.md for project context automatically.", {
|
|
17
19
|
prompt: z.string().describe("The prompt to send to Gemini"),
|
|
18
20
|
files: z
|
|
19
21
|
.array(z.string())
|
|
20
22
|
.optional()
|
|
21
|
-
.describe("File paths (relative to workingDirectory
|
|
23
|
+
.describe("File paths (text or images) relative to workingDirectory. Images: png, jpg, jpeg, gif, webp, bmp"),
|
|
22
24
|
model: z.string().optional().describe("Gemini model to use (e.g. gemini-2.5-flash, gemini-2.5-pro)"),
|
|
23
25
|
workingDirectory: z
|
|
24
26
|
.string()
|
|
@@ -27,7 +29,13 @@ server.tool("query", "Send a prompt to Gemini CLI with optional file context. Th
|
|
|
27
29
|
timeout: z
|
|
28
30
|
.number()
|
|
29
31
|
.optional()
|
|
30
|
-
.describe("Timeout in milliseconds (default: 60000, max: 600000)"),
|
|
32
|
+
.describe("Timeout in milliseconds (default: 60000 for text, 120000 for images, max: 600000)"),
|
|
33
|
+
maxResponseLength: z
|
|
34
|
+
.number()
|
|
35
|
+
.int()
|
|
36
|
+
.positive()
|
|
37
|
+
.optional()
|
|
38
|
+
.describe("Soft limit on response length in words. Appends a length instruction to the prompt."),
|
|
31
39
|
}, async (input) => {
|
|
32
40
|
try {
|
|
33
41
|
const result = await executeQuery(input);
|
|
@@ -35,13 +43,19 @@ server.tool("query", "Send a prompt to Gemini CLI with optional file context. Th
|
|
|
35
43
|
if (result.filesIncluded.length > 0) {
|
|
36
44
|
meta.push(`Files included: ${result.filesIncluded.join(", ")}`);
|
|
37
45
|
}
|
|
46
|
+
if (result.imagesIncluded.length > 0) {
|
|
47
|
+
meta.push(`Images included: ${result.imagesIncluded.join(", ")}`);
|
|
48
|
+
}
|
|
38
49
|
if (result.filesSkipped.length > 0) {
|
|
39
50
|
meta.push(`Files skipped: ${result.filesSkipped.join(", ")}`);
|
|
40
51
|
}
|
|
41
52
|
if (result.timedOut) {
|
|
42
53
|
meta.push("(timed out)");
|
|
43
54
|
}
|
|
44
|
-
if (result.
|
|
55
|
+
if (result.fallbackUsed) {
|
|
56
|
+
meta.push(`Note: ${result.model ?? "primary model"} used after quota exhaustion on original model`);
|
|
57
|
+
}
|
|
58
|
+
else if (result.model) {
|
|
45
59
|
meta.push(`Model: ${result.model}`);
|
|
46
60
|
}
|
|
47
61
|
const text = meta.length > 0
|
|
@@ -57,7 +71,7 @@ server.tool("query", "Send a prompt to Gemini CLI with optional file context. Th
|
|
|
57
71
|
}
|
|
58
72
|
});
|
|
59
73
|
// --- review tool ---
|
|
60
|
-
server.tool("review", "
|
|
74
|
+
server.tool("review", "Repo-aware code review. Computes diff locally, then Gemini explores the repo with its built-in tools (read_file, grep, etc.) for full context before reviewing. Use quick: true for fast diff-only review.", {
|
|
61
75
|
uncommitted: z
|
|
62
76
|
.boolean()
|
|
63
77
|
.optional()
|
|
@@ -66,6 +80,15 @@ server.tool("review", "Code review via git diff sent to Gemini. Computes diff lo
|
|
|
66
80
|
.string()
|
|
67
81
|
.optional()
|
|
68
82
|
.describe("Base branch/ref to diff against (e.g. 'main'). Overrides uncommitted."),
|
|
83
|
+
focus: z
|
|
84
|
+
.string()
|
|
85
|
+
.optional()
|
|
86
|
+
.describe("Optional focus area for the review (e.g. 'security', 'performance', 'error handling')"),
|
|
87
|
+
quick: z
|
|
88
|
+
.boolean()
|
|
89
|
+
.optional()
|
|
90
|
+
.describe("Skip repo exploration, just review the diff text. Faster but less context. Default: false"),
|
|
91
|
+
model: z.string().optional().describe("Gemini model to use (e.g. gemini-2.5-flash, gemini-2.5-pro)"),
|
|
69
92
|
workingDirectory: z
|
|
70
93
|
.string()
|
|
71
94
|
.optional()
|
|
@@ -73,15 +96,24 @@ server.tool("review", "Code review via git diff sent to Gemini. Computes diff lo
|
|
|
73
96
|
timeout: z
|
|
74
97
|
.number()
|
|
75
98
|
.optional()
|
|
76
|
-
.describe("Timeout in milliseconds (default: 120000, max: 600000)"),
|
|
99
|
+
.describe("Timeout in milliseconds (default: 300000 agentic / 120000 quick, max: 600000)"),
|
|
100
|
+
maxResponseLength: z
|
|
101
|
+
.number()
|
|
102
|
+
.int()
|
|
103
|
+
.positive()
|
|
104
|
+
.optional()
|
|
105
|
+
.describe("Soft limit on response length in words. Appends a length instruction to the prompt."),
|
|
77
106
|
}, async (input) => {
|
|
78
107
|
try {
|
|
79
108
|
const result = await executeReview(input);
|
|
80
109
|
const meta = [
|
|
81
110
|
`Diff source: ${result.diffSource}`,
|
|
111
|
+
`Mode: ${result.mode}`,
|
|
82
112
|
];
|
|
83
113
|
if (result.base)
|
|
84
114
|
meta.push(`Base: ${result.base}`);
|
|
115
|
+
if (result.fallbackUsed)
|
|
116
|
+
meta.push("Note: fallback model used after quota exhaustion on original model");
|
|
85
117
|
if (result.timedOut)
|
|
86
118
|
meta.push("(timed out)");
|
|
87
119
|
return {
|
|
@@ -98,6 +130,105 @@ server.tool("review", "Code review via git diff sent to Gemini. Computes diff lo
|
|
|
98
130
|
};
|
|
99
131
|
}
|
|
100
132
|
});
|
|
133
|
+
// --- search tool ---
|
|
134
|
+
server.tool("search", "Google Search grounded query. Gemini searches the web via google_web_search and synthesizes an answer with source URLs. Uses agentic mode.", {
|
|
135
|
+
query: z.string().describe("Search query or question to research using Google Search"),
|
|
136
|
+
model: z.string().optional().describe("Gemini model to use (e.g. gemini-2.5-flash, gemini-2.5-pro)"),
|
|
137
|
+
workingDirectory: z
|
|
138
|
+
.string()
|
|
139
|
+
.optional()
|
|
140
|
+
.describe("Working directory for the CLI"),
|
|
141
|
+
timeout: z
|
|
142
|
+
.number()
|
|
143
|
+
.optional()
|
|
144
|
+
.describe("Timeout in milliseconds (default: 120000, max: 600000)"),
|
|
145
|
+
maxResponseLength: z
|
|
146
|
+
.number()
|
|
147
|
+
.int()
|
|
148
|
+
.positive()
|
|
149
|
+
.optional()
|
|
150
|
+
.describe("Soft limit on response length in words. Appends a length instruction to the prompt."),
|
|
151
|
+
}, async (input) => {
|
|
152
|
+
try {
|
|
153
|
+
const result = await executeSearch(input);
|
|
154
|
+
const meta = [];
|
|
155
|
+
if (result.timedOut)
|
|
156
|
+
meta.push("(timed out)");
|
|
157
|
+
if (result.fallbackUsed) {
|
|
158
|
+
meta.push(`Note: ${result.model ?? "fallback model"} used after quota exhaustion on original model`);
|
|
159
|
+
}
|
|
160
|
+
else if (result.model) {
|
|
161
|
+
meta.push(`Model: ${result.model}`);
|
|
162
|
+
}
|
|
163
|
+
const text = meta.length > 0
|
|
164
|
+
? `${result.response}\n\n---\n${meta.join("\n")}`
|
|
165
|
+
: result.response;
|
|
166
|
+
return { content: [{ type: "text", text }] };
|
|
167
|
+
}
|
|
168
|
+
catch (e) {
|
|
169
|
+
return {
|
|
170
|
+
content: [{ type: "text", text: `Error: ${e.message}` }],
|
|
171
|
+
isError: true,
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
// --- structured tool ---
|
|
176
|
+
server.tool("structured", "Generate a JSON response conforming to a provided JSON Schema. Use for data extraction, classification, or any task needing machine-parseable output.", {
|
|
177
|
+
prompt: z.string().describe("What to generate or extract"),
|
|
178
|
+
schema: z
|
|
179
|
+
.string()
|
|
180
|
+
.describe("JSON Schema the response must conform to (as a JSON string)"),
|
|
181
|
+
files: z
|
|
182
|
+
.array(z.string())
|
|
183
|
+
.optional()
|
|
184
|
+
.describe("File paths to include as context (text only, no images)"),
|
|
185
|
+
model: z
|
|
186
|
+
.string()
|
|
187
|
+
.optional()
|
|
188
|
+
.describe("Gemini model to use (e.g. gemini-2.5-flash, gemini-2.5-pro)"),
|
|
189
|
+
workingDirectory: z
|
|
190
|
+
.string()
|
|
191
|
+
.optional()
|
|
192
|
+
.describe("Working directory for file paths"),
|
|
193
|
+
timeout: z
|
|
194
|
+
.number()
|
|
195
|
+
.optional()
|
|
196
|
+
.describe("Timeout in milliseconds (default: 60000)"),
|
|
197
|
+
}, async (input) => {
|
|
198
|
+
try {
|
|
199
|
+
const result = await executeStructured(input);
|
|
200
|
+
const meta = [];
|
|
201
|
+
if (result.errors)
|
|
202
|
+
meta.push(`Errors: ${result.errors}`);
|
|
203
|
+
if (result.filesIncluded.length > 0) {
|
|
204
|
+
meta.push(`Files: ${result.filesIncluded.join(", ")}`);
|
|
205
|
+
}
|
|
206
|
+
if (result.timedOut)
|
|
207
|
+
meta.push("(timed out)");
|
|
208
|
+
if (result.fallbackUsed) {
|
|
209
|
+
meta.push(`Note: ${result.model ?? "fallback model"} used after quota exhaustion on original model`);
|
|
210
|
+
}
|
|
211
|
+
else if (result.model) {
|
|
212
|
+
meta.push(`Model: ${result.model}`);
|
|
213
|
+
}
|
|
214
|
+
const metaSuffix = meta.length > 0 ? `\n\n---\n${meta.join("\n")}` : "";
|
|
215
|
+
return {
|
|
216
|
+
content: [{
|
|
217
|
+
type: "text",
|
|
218
|
+
text: result.valid
|
|
219
|
+
? `${result.response}${metaSuffix}`
|
|
220
|
+
: `${result.response}\n\n---\nSchema validation failed. ${meta.join("\n")}`,
|
|
221
|
+
}],
|
|
222
|
+
isError: !result.valid,
|
|
223
|
+
};
|
|
224
|
+
}
|
|
225
|
+
catch (e) {
|
|
226
|
+
return {
|
|
227
|
+
content: [{ type: "text", text: `Error: ${e.message}` }],
|
|
228
|
+
isError: true,
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
});
|
|
101
232
|
// --- ping tool ---
|
|
102
233
|
server.tool("ping", "Health check: verifies gemini CLI is installed and authenticated, reports versions and capabilities.", {}, async () => {
|
|
103
234
|
try {
|
|
@@ -106,6 +237,8 @@ server.tool("ping", "Health check: verifies gemini CLI is installed and authenti
|
|
|
106
237
|
`CLI found: ${result.cliFound ? "yes" : "NO — install with: npm i -g @google/gemini-cli"}`,
|
|
107
238
|
`CLI version: ${result.version ?? "unknown"}`,
|
|
108
239
|
`Auth status: ${result.authStatus}`,
|
|
240
|
+
`Default model: ${result.defaultModel ?? "(CLI default)"}`,
|
|
241
|
+
`Fallback model: ${result.fallbackModel ?? "disabled"}`,
|
|
109
242
|
`Server version: ${result.serverVersion}`,
|
|
110
243
|
`Node version: ${result.nodeVersion}`,
|
|
111
244
|
`Max concurrent: ${result.maxConcurrent}`,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +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,EA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AAE,EAAE;IACjB,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAC3B,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/tools/ping.d.ts
CHANGED
|
@@ -2,6 +2,8 @@ export interface PingResult {
|
|
|
2
2
|
cliFound: boolean;
|
|
3
3
|
version: string | null;
|
|
4
4
|
authStatus: "ok" | "expired" | "missing" | "unknown";
|
|
5
|
+
defaultModel: string | null;
|
|
6
|
+
fallbackModel: string | null;
|
|
5
7
|
serverVersion: string;
|
|
6
8
|
nodeVersion: string;
|
|
7
9
|
maxConcurrent: number;
|
package/dist/tools/ping.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ping.d.ts","sourceRoot":"","sources":["../../src/tools/ping.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ping.d.ts","sourceRoot":"","sources":["../../src/tools/ping.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,UAAU;IACzB,QAAQ,EAAE,OAAO,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;IACvB,UAAU,EAAE,IAAI,GAAG,SAAS,GAAG,SAAS,GAAG,SAAS,CAAC;IACrD,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;CACvB;AA+CD;;;;GAIG;AACH,wBAAsB,WAAW,IAAI,OAAO,CAAC,UAAU,CAAC,CAkDvD"}
|
package/dist/tools/ping.js
CHANGED
|
@@ -5,6 +5,7 @@ import { join } from "node:path";
|
|
|
5
5
|
import { homedir } from "node:os";
|
|
6
6
|
import { findGeminiBinary } from "../utils/spawn.js";
|
|
7
7
|
import { buildSubprocessEnv } from "../utils/env.js";
|
|
8
|
+
import { getDefaultModel, getFallbackModel } from "../utils/model.js";
|
|
8
9
|
const require = createRequire(import.meta.url);
|
|
9
10
|
const PKG_VERSION = require("../../package.json").version;
|
|
10
11
|
/**
|
|
@@ -70,6 +71,8 @@ export async function executePing() {
|
|
|
70
71
|
cliFound: false,
|
|
71
72
|
version: null,
|
|
72
73
|
authStatus: "missing",
|
|
74
|
+
defaultModel: getDefaultModel() ?? null,
|
|
75
|
+
fallbackModel: getFallbackModel() ?? null,
|
|
73
76
|
serverVersion: PKG_VERSION,
|
|
74
77
|
nodeVersion: process.version,
|
|
75
78
|
maxConcurrent,
|
|
@@ -79,10 +82,14 @@ export async function executePing() {
|
|
|
79
82
|
cliFound = true;
|
|
80
83
|
}
|
|
81
84
|
const authStatus = detectAuthStatus();
|
|
85
|
+
const defaultModel = getDefaultModel() ?? null;
|
|
86
|
+
const fallbackModel = getFallbackModel() ?? null;
|
|
82
87
|
return {
|
|
83
88
|
cliFound,
|
|
84
89
|
version,
|
|
85
90
|
authStatus,
|
|
91
|
+
defaultModel,
|
|
92
|
+
fallbackModel,
|
|
86
93
|
serverVersion: PKG_VERSION,
|
|
87
94
|
nodeVersion: process.version,
|
|
88
95
|
maxConcurrent,
|
package/dist/tools/ping.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ping.js","sourceRoot":"","sources":["../../src/tools/ping.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;
|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ACvC,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC1B,OAAO;gBACL,QAAQ,EAAE,KAAK;gBACf,OAAO,EAAE,IAAI;gBACb,UAAU,EAAE,SAAS;gBACrB,YAAY,EAAE,eAAe,EAAE,IAAI,IAAI;gBACvC,aAAa,EAAE,gBAAgB,EAAE,IAAI,IAAI;gBACzC,aAAa,EAAE,WAAW;gBAC1B,WAAW,EAAE,OAAO,CAAC,OAAO;gBAC5B,aAAa;aACd,CAAC;QACJ,CAAC;QACD,uDAAuD;QACvD,QAAQ,GAAG,IAAI,CAAC;IAClB,CAAC;IAED,MAAM,UAAU,GAAG,gBAAgB,EAAE,CAAC;IACtC,MAAM,YAAY,GAAG,eAAe,EAAE,IAAI,IAAI,CAAC;IAC/C,MAAM,aAAa,GAAG,gBAAgB,EAAE,IAAI,IAAI,CAAC;IAEjD,OAAO;QACL,QAAQ;QACR,OAAO;QACP,UAAU;QACV,YAAY;QACZ,aAAa;QACb,aAAa,EAAE,WAAW;QAC1B,WAAW,EAAE,OAAO,CAAC,OAAO;QAC5B,aAAa;KACd,CAAC;AACJ,CAAC"}
|
package/dist/tools/query.d.ts
CHANGED
|
@@ -4,17 +4,24 @@ export interface QueryInput {
|
|
|
4
4
|
model?: string;
|
|
5
5
|
workingDirectory?: string;
|
|
6
6
|
timeout?: number;
|
|
7
|
+
maxResponseLength?: number;
|
|
7
8
|
}
|
|
8
9
|
export interface QueryResult {
|
|
9
10
|
response: string;
|
|
10
11
|
model?: string;
|
|
12
|
+
fallbackUsed?: boolean;
|
|
11
13
|
filesIncluded: string[];
|
|
12
14
|
filesSkipped: string[];
|
|
15
|
+
imagesIncluded: string[];
|
|
13
16
|
timedOut: boolean;
|
|
14
17
|
}
|
|
15
18
|
/**
|
|
16
19
|
* Execute a one-shot query against Gemini CLI.
|
|
17
20
|
* Optionally includes file contents in the prompt.
|
|
21
|
+
*
|
|
22
|
+
* When image files are included, switches to agentic mode (--yolo) so the CLI
|
|
23
|
+
* can read them natively via its read_file tool. Text files are still inlined
|
|
24
|
+
* in the prompt as before.
|
|
18
25
|
*/
|
|
19
26
|
export declare function executeQuery(input: QueryInput): Promise<QueryResult>;
|
|
20
27
|
//# sourceMappingURL=query.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/tools/query.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"query.d.ts","sourceRoot":"","sources":["../../src/tools/query.ts"],"names":[],"mappings":"AAcA,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,QAAQ,EAAE,OAAO,CAAC;CACnB;AAWD;;;;;;;GAOG;AACH,wBAAsB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,WAAW,CAAC,CAsB1E"}
|