@tuannvm/gemini-mcp-server 1.0.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.
Files changed (99) hide show
  1. package/LICENSE +25 -0
  2. package/README.md +381 -0
  3. package/dist/constants.d.ts +58 -0
  4. package/dist/constants.d.ts.map +1 -0
  5. package/dist/constants.js +64 -0
  6. package/dist/constants.js.map +1 -0
  7. package/dist/errors.d.ts +24 -0
  8. package/dist/errors.d.ts.map +1 -0
  9. package/dist/errors.js +57 -0
  10. package/dist/errors.js.map +1 -0
  11. package/dist/index.d.ts +8 -0
  12. package/dist/index.d.ts.map +1 -0
  13. package/dist/index.js +24 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/server.d.ts +19 -0
  16. package/dist/server.d.ts.map +1 -0
  17. package/dist/server.js +166 -0
  18. package/dist/server.js.map +1 -0
  19. package/dist/tools/analyze-media.tool.d.ts +3 -0
  20. package/dist/tools/analyze-media.tool.d.ts.map +1 -0
  21. package/dist/tools/analyze-media.tool.js +102 -0
  22. package/dist/tools/analyze-media.tool.js.map +1 -0
  23. package/dist/tools/ask-gemini.tool.d.ts +3 -0
  24. package/dist/tools/ask-gemini.tool.d.ts.map +1 -0
  25. package/dist/tools/ask-gemini.tool.js +86 -0
  26. package/dist/tools/ask-gemini.tool.js.map +1 -0
  27. package/dist/tools/brainstorm.tool.d.ts +3 -0
  28. package/dist/tools/brainstorm.tool.d.ts.map +1 -0
  29. package/dist/tools/brainstorm.tool.js +220 -0
  30. package/dist/tools/brainstorm.tool.js.map +1 -0
  31. package/dist/tools/fetch-chunk.tool.d.ts +3 -0
  32. package/dist/tools/fetch-chunk.tool.d.ts.map +1 -0
  33. package/dist/tools/fetch-chunk.tool.js +85 -0
  34. package/dist/tools/fetch-chunk.tool.js.map +1 -0
  35. package/dist/tools/index.d.ts +2 -0
  36. package/dist/tools/index.d.ts.map +1 -0
  37. package/dist/tools/index.js +19 -0
  38. package/dist/tools/index.js.map +1 -0
  39. package/dist/tools/registry.d.ts +26 -0
  40. package/dist/tools/registry.d.ts.map +1 -0
  41. package/dist/tools/registry.js +74 -0
  42. package/dist/tools/registry.js.map +1 -0
  43. package/dist/tools/search.tool.d.ts +3 -0
  44. package/dist/tools/search.tool.d.ts.map +1 -0
  45. package/dist/tools/search.tool.js +86 -0
  46. package/dist/tools/search.tool.js.map +1 -0
  47. package/dist/tools/shell.tool.d.ts +3 -0
  48. package/dist/tools/shell.tool.d.ts.map +1 -0
  49. package/dist/tools/shell.tool.js +106 -0
  50. package/dist/tools/shell.tool.js.map +1 -0
  51. package/dist/tools/simple-tools.d.ts +4 -0
  52. package/dist/tools/simple-tools.d.ts.map +1 -0
  53. package/dist/tools/simple-tools.js +48 -0
  54. package/dist/tools/simple-tools.js.map +1 -0
  55. package/dist/tools/test-tool.example.d.ts +13 -0
  56. package/dist/tools/test-tool.example.d.ts.map +1 -0
  57. package/dist/tools/test-tool.example.js +44 -0
  58. package/dist/tools/test-tool.example.js.map +1 -0
  59. package/dist/tools/timeout-test.tool.d.ts +3 -0
  60. package/dist/tools/timeout-test.tool.d.ts.map +1 -0
  61. package/dist/tools/timeout-test.tool.js +45 -0
  62. package/dist/tools/timeout-test.tool.js.map +1 -0
  63. package/dist/types.d.ts +43 -0
  64. package/dist/types.d.ts.map +1 -0
  65. package/dist/types.js +22 -0
  66. package/dist/types.js.map +1 -0
  67. package/dist/utils/changeModeChunker.d.ts +11 -0
  68. package/dist/utils/changeModeChunker.d.ts.map +1 -0
  69. package/dist/utils/changeModeChunker.js +95 -0
  70. package/dist/utils/changeModeChunker.js.map +1 -0
  71. package/dist/utils/changeModeParser.d.ts +15 -0
  72. package/dist/utils/changeModeParser.d.ts.map +1 -0
  73. package/dist/utils/changeModeParser.js +67 -0
  74. package/dist/utils/changeModeParser.js.map +1 -0
  75. package/dist/utils/changeModeTranslator.d.ts +8 -0
  76. package/dist/utils/changeModeTranslator.d.ts.map +1 -0
  77. package/dist/utils/changeModeTranslator.js +73 -0
  78. package/dist/utils/changeModeTranslator.js.map +1 -0
  79. package/dist/utils/chunkCache.d.ts +22 -0
  80. package/dist/utils/chunkCache.d.ts.map +1 -0
  81. package/dist/utils/chunkCache.js +163 -0
  82. package/dist/utils/chunkCache.js.map +1 -0
  83. package/dist/utils/commandExecutor.d.ts +2 -0
  84. package/dist/utils/commandExecutor.d.ts.map +1 -0
  85. package/dist/utils/commandExecutor.js +74 -0
  86. package/dist/utils/commandExecutor.js.map +1 -0
  87. package/dist/utils/geminiExecutor.d.ts +3 -0
  88. package/dist/utils/geminiExecutor.d.ts.map +1 -0
  89. package/dist/utils/geminiExecutor.js +182 -0
  90. package/dist/utils/geminiExecutor.js.map +1 -0
  91. package/dist/utils/logger.d.ts +13 -0
  92. package/dist/utils/logger.d.ts.map +1 -0
  93. package/dist/utils/logger.js +42 -0
  94. package/dist/utils/logger.js.map +1 -0
  95. package/dist/utils/timeoutManager.d.ts +1 -0
  96. package/dist/utils/timeoutManager.d.ts.map +1 -0
  97. package/dist/utils/timeoutManager.js +2 -0
  98. package/dist/utils/timeoutManager.js.map +1 -0
  99. package/package.json +68 -0
package/LICENSE ADDED
@@ -0,0 +1,25 @@
1
+ MIT License (Non-Commercial)
2
+
3
+ Copyright (c) 2025 jamubc
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 for non-commercial purposes only, including without limitation
8
+ the rights to use, copy, modify, merge, publish, and distribute copies of the
9
+ Software, and to permit persons to whom the Software is furnished to do so,
10
+ 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
+ Commercial use of this software is prohibited without prior written permission
16
+ from the copyright holder. For commercial licensing, please contact the
17
+ copyright holder directly.
18
+
19
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,381 @@
1
+ # Gemini MCP Server
2
+
3
+ [![npm version](https://img.shields.io/npm/v/@tuannvm/gemini-mcp-server.svg)](https://www.npmjs.com/package/@tuannvm/gemini-mcp-server)
4
+ [![npm downloads](https://img.shields.io/npm/dm/@tuannvm/gemini-mcp-server.svg)](https://www.npmjs.com/package/@tuannvm/gemini-mcp-server)
5
+ [![license](https://img.shields.io/npm/l/@tuannvm/gemini-mcp-server.svg)](https://www.npmjs.com/package/@tuannvm/gemini-mcp-server)
6
+
7
+ MCP server for Google Gemini CLI integration with large file analysis, web search, multimodal analysis, shell commands, and brainstorming support.
8
+
9
+ ```mermaid
10
+ graph LR
11
+ A[Claude Code] --> B[Gemini MCP Server]
12
+
13
+ B --> C[ask-gemini]
14
+ B --> S[search]
15
+ B --> M[analyze-media]
16
+ B --> SH[shell]
17
+ B --> D[brainstorm]
18
+ B --> E[fetch-chunk]
19
+ B --> F[ping]
20
+ B --> G[help]
21
+
22
+ C --> H[Gemini CLI]
23
+ S --> H
24
+ M --> H
25
+ SH --> H
26
+ D --> H
27
+ C --> I[Chunk Cache]
28
+ E --> I
29
+
30
+ style A fill:#FF6B35
31
+ style B fill:#4A90E2
32
+ style C fill:#00D4AA
33
+ style S fill:#00D4AA
34
+ style M fill:#00D4AA
35
+ style SH fill:#00D4AA
36
+ style D fill:#00D4AA
37
+ style E fill:#00D4AA
38
+ style F fill:#00D4AA
39
+ style G fill:#00D4AA
40
+ style H fill:#4285F4
41
+ style I fill:#9B59B6
42
+ ```
43
+
44
+ ## Prerequisites
45
+
46
+ - **Google Gemini CLI v0.22.2+** must be pre-installed and configured
47
+ - Install: `npm install -g @google/gemini-cli`
48
+ - Authenticate: Run `gemini` and login with Google (free tier: 60 req/min, 1000 req/day)
49
+ - Or set API key: `export GEMINI_API_KEY="YOUR_API_KEY"`
50
+ - **Recommended**: Set default model to Gemini 3 Pro (see [Model Configuration](#model-configuration))
51
+ - **Node.js v18+** installed
52
+ - **Claude Code** or compatible MCP client
53
+
54
+ ## Installation
55
+
56
+ ### One-Click Installation
57
+
58
+ #### VS Code
59
+ [![Install in VS Code](https://img.shields.io/badge/VS_Code-Install_Gemini_MCP_Server-0098FF?style=flat-square&logo=visualstudiocode&logoColor=white)](https://vscode.dev/redirect/mcp/install?name=gemini-cli&config=%7B%22type%22%3A%22stdio%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40tuannvm%2Fgemini-mcp-server%22%5D%7D)
60
+
61
+ #### VS Code Insiders
62
+ [![Install in VS Code Insiders](https://img.shields.io/badge/VS_Code_Insiders-Install_Gemini_MCP_Server-24bfa5?style=flat-square&logo=visualstudiocode&logoColor=white)](https://insiders.vscode.dev/redirect/mcp/install?name=gemini-cli&config=%7B%22type%22%3A%22stdio%22%2C%22command%22%3A%22npx%22%2C%22args%22%3A%5B%22-y%22%2C%22%40tuannvm%2Fgemini-mcp-server%22%5D%7D)
63
+
64
+ #### Cursor
65
+ [![Install in Cursor](https://img.shields.io/badge/Cursor-Install_Gemini_MCP_Server-00D8FF?style=flat-square&logo=cursor&logoColor=white)](https://cursor.com/en/install-mcp?name=gemini-cli&config=eyJ0eXBlIjoic3RkaW8iLCJjb21tYW5kIjoibnB4IC15IEB0dWFubnZtL2dlbWluaS1tY3Atc2VydmVyIiwiZW52Ijp7fX0=)
66
+
67
+ ### Manual Installation
68
+
69
+ #### Claude Code
70
+ ```bash
71
+ claude mcp add gemini-cli -- npx -y @tuannvm/gemini-mcp-server
72
+ ```
73
+
74
+ #### Claude Desktop
75
+ Add to your Claude Desktop configuration file:
76
+
77
+ **macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
78
+
79
+ **Windows:** `%APPDATA%/Claude/claude_desktop_config.json`
80
+
81
+ ```json
82
+ {
83
+ "mcpServers": {
84
+ "gemini-cli": {
85
+ "command": "npx",
86
+ "args": ["-y", "@tuannvm/gemini-mcp-server"]
87
+ }
88
+ }
89
+ }
90
+ ```
91
+
92
+ ## Usage in Claude Code
93
+
94
+ Once installed, Claude Code can use these tools:
95
+
96
+ ### `ask-gemini` - File Analysis & Questions
97
+ Analyze files and codebases using Gemini's large context window with the `@` syntax.
98
+
99
+ **Basic Usage:**
100
+ ```
101
+ Use ask-gemini to analyze @src/main.js and explain what it does
102
+ ```
103
+
104
+ **Advanced Usage:**
105
+ ```
106
+ # Model selection (defaults to gemini-3-pro-preview)
107
+ Use ask-gemini with model "gemini-3-flash-preview" to quickly summarize @package.json
108
+
109
+ # Sandbox mode for safe code execution
110
+ Use ask-gemini with sandbox true to test @script.py safely
111
+
112
+ # Change mode for structured edits
113
+ Use ask-gemini with changeMode true to refactor @src/utils.ts
114
+ ```
115
+
116
+ **Parameters:**
117
+ - `prompt` (required): Your question or analysis request. Use `@` syntax for file references
118
+ - `model` (optional): Model to use (`gemini-3-pro-preview` or `gemini-3-flash-preview`)
119
+ - `sandbox` (optional): Enable sandbox mode for safe execution
120
+ - `changeMode` (optional): Enable structured edit mode for code changes
121
+
122
+ ### `search` - Web Search with Google Grounding
123
+ Search the web using Gemini with Google Search grounding for real-time information.
124
+
125
+ **Basic Usage:**
126
+ ```
127
+ Use search to find the latest React 19 features
128
+ ```
129
+
130
+ **Advanced Usage:**
131
+ ```
132
+ # Get raw results without summarization
133
+ Use search with query "kubernetes security best practices 2025" and summarize false
134
+
135
+ # Use specific model
136
+ Use search with query "latest AI news" and model "gemini-3-pro-preview"
137
+ ```
138
+
139
+ **Parameters:**
140
+ - `query` (required): Search query
141
+ - `summarize` (optional): Summarize results (default: true)
142
+ - `model` (optional): Model to use (default: gemini-3-flash-preview for speed)
143
+
144
+ ### `analyze-media` - Multimodal Analysis
145
+ Analyze images, PDFs, screenshots, and diagrams using Gemini's multimodal capabilities.
146
+
147
+ **Basic Usage:**
148
+ ```
149
+ Use analyze-media with filePath "@screenshot.png" and prompt "describe this UI"
150
+ ```
151
+
152
+ **Advanced Usage:**
153
+ ```
154
+ # Detailed analysis
155
+ Use analyze-media with filePath "@architecture.pdf" and prompt "explain the system design" and detailed true
156
+
157
+ # Quick analysis with Flash model
158
+ Use analyze-media with filePath "@error.png" and prompt "what's the error?" and model "gemini-3-flash-preview"
159
+ ```
160
+
161
+ **Parameters:**
162
+ - `filePath` (required): Path to media file (use `@` syntax)
163
+ - `prompt` (required): What to analyze or extract
164
+ - `model` (optional): Model to use (default: gemini-3-pro-preview for multimodal)
165
+ - `detailed` (optional): Provide detailed analysis
166
+
167
+ ### `shell` - Shell Command Generation
168
+ Generate and optionally execute shell commands using Gemini.
169
+
170
+ **Basic Usage:**
171
+ ```
172
+ Use shell with task "find all TypeScript files larger than 100KB"
173
+ ```
174
+
175
+ **Advanced Usage:**
176
+ ```
177
+ # Dry run (default) - explains commands without executing
178
+ Use shell with task "clean up node_modules and rebuild" and dryRun true
179
+
180
+ # Execute in sandbox (safe)
181
+ Use shell with task "run the test suite" and dryRun false
182
+
183
+ # With working directory
184
+ Use shell with task "list all TODO comments" and workingDirectory "@src/"
185
+ ```
186
+
187
+ **Parameters:**
188
+ - `task` (required): Description of the shell task
189
+ - `dryRun` (optional): If true, explains commands without executing (default: true)
190
+ - `workingDirectory` (optional): Working directory for execution
191
+ - `model` (optional): Model to use (default: gemini-3-flash-preview)
192
+
193
+ ### `brainstorm` - Creative Ideation
194
+ Generate ideas using various brainstorming methodologies.
195
+
196
+ **Basic Usage:**
197
+ ```
198
+ Use brainstorm to generate ideas for improving user onboarding
199
+ ```
200
+
201
+ **Advanced Usage:**
202
+ ```
203
+ # Specific methodology
204
+ Use brainstorm with methodology "SCAMPER" to improve the checkout flow
205
+
206
+ # Domain-specific brainstorming
207
+ Use brainstorm with domain "mobile" and ideaCount 10 for app features
208
+
209
+ # With analysis
210
+ Use brainstorm with includeAnalysis true to evaluate idea feasibility
211
+ ```
212
+
213
+ **Parameters:**
214
+ - `prompt` (required): The brainstorming topic
215
+ - `methodology` (optional): Framework to use (`divergent`, `convergent`, `SCAMPER`, `design-thinking`, `lateral`, `auto`)
216
+ - `domain` (optional): Domain context for specialized ideas
217
+ - `constraints` (optional): Known limitations or requirements
218
+ - `ideaCount` (optional): Target number of ideas to generate
219
+ - `includeAnalysis` (optional): Include feasibility and impact analysis
220
+
221
+ ### `fetch-chunk` - Retrieve Cached Chunks
222
+ Retrieve cached chunks from large changeMode responses.
223
+
224
+ **Parameters:**
225
+ - `cacheKey` (required): Cache key from previous response
226
+ - `chunkIndex` (required): Chunk index to retrieve (1-based)
227
+
228
+ ### `ping` - Connection Test
229
+ Test if the MCP server is working properly.
230
+
231
+ ### `help` - Gemini CLI Help
232
+ Get information about Gemini CLI capabilities and commands.
233
+
234
+ ## Example Workflows
235
+
236
+ **Large Codebase Analysis:**
237
+ ```
238
+ Use ask-gemini to analyze @. and provide an architecture overview
239
+ ```
240
+
241
+ **File Comparison:**
242
+ ```
243
+ Use ask-gemini to compare @src/old.ts and @src/new.ts and explain the differences
244
+ ```
245
+
246
+ **Code Refactoring with Structured Edits:**
247
+ ```
248
+ Use ask-gemini with changeMode true to refactor @src/utils.ts for better error handling
249
+ ```
250
+
251
+ **Creative Brainstorming:**
252
+ ```
253
+ Use brainstorm with methodology "design-thinking" to improve the user dashboard experience
254
+ ```
255
+
256
+ **Web Research:**
257
+ ```
258
+ Use search to find the latest security vulnerabilities in npm packages
259
+ ```
260
+
261
+ **Screenshot Analysis:**
262
+ ```
263
+ Use analyze-media with filePath "@error-screenshot.png" and prompt "explain this error and suggest a fix"
264
+ ```
265
+
266
+ **Shell Task Automation:**
267
+ ```
268
+ Use shell with task "find all files modified in the last 24 hours" and dryRun false
269
+ ```
270
+
271
+ ## Advanced Features
272
+
273
+ ### Large File Handling
274
+ - Gemini's massive context window handles large files that would exceed other models' limits
275
+ - Use `@` syntax to reference files: `@src/main.js`, `@.` (current directory)
276
+ - Automatic chunking for very large responses with cache retrieval
277
+
278
+ ### Change Mode (Structured Edits)
279
+ When `changeMode` is enabled, responses are formatted as structured edits that can be automatically applied:
280
+ - Parses `**FILE: path:line**` format with `OLD/NEW` blocks
281
+ - Chunks large edit responses for manageable processing
282
+ - 10-minute cache TTL for chunk retrieval
283
+
284
+ ### Model Fallback
285
+ - Automatically falls back from `gemini-3-pro-preview` to `gemini-3-flash-preview` when quota is exceeded
286
+ - Transparent retry with status notification
287
+
288
+ ### Progress Notifications
289
+ For long-running operations, the server sends `notifications/progress` messages when the client provides a `progressToken`.
290
+
291
+ ## Model Configuration
292
+
293
+ ### Setting the Default Model
294
+
295
+ You can configure the default Gemini model using three methods (in order of precedence):
296
+
297
+ **1. Environment Variable (Recommended)**
298
+ ```bash
299
+ export GEMINI_MODEL="gemini-3-pro-preview"
300
+ ```
301
+
302
+ **2. Settings File**
303
+
304
+ Create `~/.gemini/settings.json` (user-level) or `.gemini/settings.json` (project-level):
305
+ ```json
306
+ {
307
+ "model": {
308
+ "name": "gemini-3-pro-preview"
309
+ }
310
+ }
311
+ ```
312
+
313
+ **3. Command-Line Flag**
314
+ ```bash
315
+ gemini -m gemini-3-pro-preview
316
+ ```
317
+
318
+ ### Available Models
319
+
320
+ | Model | ID | Best For |
321
+ |-------|-----|----------|
322
+ | **Gemini 3 Pro** (default) | `gemini-3-pro-preview` | Most capable, complex reasoning |
323
+ | **Gemini 3 Flash** | `gemini-3-flash-preview` | Fast responses, good quality |
324
+ | Gemini 2.5 Flash-Lite | `gemini-2.5-flash-lite` | Fastest, lightweight |
325
+
326
+ ### Configuration Precedence
327
+
328
+ Settings are applied in order (highest priority last):
329
+ 1. Default values
330
+ 2. User settings file (`~/.gemini/settings.json`)
331
+ 3. Project settings file (`.gemini/settings.json`)
332
+ 4. Environment variables (`GEMINI_MODEL`)
333
+ 5. Command-line arguments (`-m`)
334
+ 6. MCP tool `model` parameter (overrides all)
335
+
336
+ ### Recommended Setup
337
+
338
+ For best results, set Gemini 3 Pro as your default:
339
+
340
+ ```bash
341
+ # Add to your shell profile (~/.bashrc, ~/.zshrc, etc.)
342
+ export GEMINI_MODEL="gemini-3-pro-preview"
343
+ ```
344
+
345
+ Or create a user settings file:
346
+ ```bash
347
+ mkdir -p ~/.gemini
348
+ echo '{"model": {"name": "gemini-3-pro-preview"}}' > ~/.gemini/settings.json
349
+ ```
350
+
351
+ ## Development
352
+
353
+ ```bash
354
+ # Install dependencies
355
+ npm install
356
+
357
+ # Development mode
358
+ npm run dev
359
+
360
+ # Build
361
+ npm run build
362
+
363
+ # Run tests
364
+ npm test
365
+
366
+ # Lint and format
367
+ npm run lint
368
+ npm run format
369
+ ```
370
+
371
+ ## Documentation
372
+
373
+ - [API Reference](docs/api-reference.md)
374
+ - [Gemini CLI Integration](docs/gemini-cli-integration.md)
375
+ - [Full Documentation Site](https://tuannvm.github.io/gemini-mcp-server/)
376
+
377
+ ## License
378
+
379
+ MIT
380
+
381
+ **Disclaimer:** This is an unofficial, third-party tool and is not affiliated with, endorsed, or sponsored by Google.
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Constants for the Gemini MCP Server
3
+ */
4
+ export { ToolArguments, MODELS } from './types.js';
5
+ export declare const LOG_PREFIX = "[GMCP]";
6
+ export declare const ERROR_MESSAGES: {
7
+ readonly QUOTA_EXCEEDED: "Quota exceeded for quota metric 'Gemini 3 Pro Requests'";
8
+ readonly QUOTA_EXCEEDED_SHORT: "Gemini 3 Pro daily quota exceeded. Please retry with model: 'gemini-3-flash-preview'";
9
+ readonly TOOL_NOT_FOUND: "not found in registry";
10
+ readonly NO_PROMPT_PROVIDED: "Please provide a prompt for analysis. Use @ syntax to include files (e.g., '@largefile.js explain what this does') or ask general questions";
11
+ };
12
+ export declare const STATUS_MESSAGES: {
13
+ readonly QUOTA_SWITCHING: "Gemini 3 Pro quota exceeded, switching to Flash model...";
14
+ readonly FLASH_RETRY: "Retrying with Gemini 3 Flash...";
15
+ readonly FLASH_SUCCESS: "Flash model completed successfully";
16
+ readonly SANDBOX_EXECUTING: "Executing Gemini CLI command in sandbox mode...";
17
+ readonly GEMINI_RESPONSE: "Gemini response:";
18
+ readonly PROCESSING_START: "Starting analysis (may take 5-15 minutes for large codebases)";
19
+ readonly PROCESSING_CONTINUE: "Still processing... Gemini is working on your request";
20
+ readonly PROCESSING_COMPLETE: "Analysis completed successfully";
21
+ };
22
+ export declare const PROTOCOL: {
23
+ readonly ROLES: {
24
+ readonly USER: "user";
25
+ readonly ASSISTANT: "assistant";
26
+ };
27
+ readonly CONTENT_TYPES: {
28
+ readonly TEXT: "text";
29
+ };
30
+ readonly STATUS: {
31
+ readonly SUCCESS: "success";
32
+ readonly ERROR: "error";
33
+ readonly FAILED: "failed";
34
+ readonly REPORT: "report";
35
+ };
36
+ readonly NOTIFICATIONS: {
37
+ readonly PROGRESS: "notifications/progress";
38
+ };
39
+ readonly KEEPALIVE_INTERVAL: 25000;
40
+ };
41
+ export declare const CLI: {
42
+ readonly COMMANDS: {
43
+ readonly GEMINI: "gemini";
44
+ readonly ECHO: "echo";
45
+ };
46
+ readonly FLAGS: {
47
+ readonly MODEL: "-m";
48
+ readonly SANDBOX: "-s";
49
+ readonly PROMPT: "-p";
50
+ readonly HELP: "-help";
51
+ };
52
+ readonly DEFAULTS: {
53
+ readonly MODEL: "default";
54
+ readonly BOOLEAN_TRUE: "true";
55
+ readonly BOOLEAN_FALSE: "false";
56
+ };
57
+ };
58
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAGnD,eAAO,MAAM,UAAU,WAAW,CAAC;AAGnC,eAAO,MAAM,cAAc;;;;;CAOjB,CAAC;AAGX,eAAO,MAAM,eAAe;;;;;;;;;CAUlB,CAAC;AAGX,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;CAkBX,CAAC;AAGX,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;CAgBN,CAAC"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Constants for the Gemini MCP Server
3
+ */
4
+ // Re-export types for backward compatibility
5
+ export { MODELS } from './types.js';
6
+ // Logging
7
+ export const LOG_PREFIX = '[GMCP]';
8
+ // Error messages
9
+ export const ERROR_MESSAGES = {
10
+ QUOTA_EXCEEDED: "Quota exceeded for quota metric 'Gemini 3 Pro Requests'",
11
+ QUOTA_EXCEEDED_SHORT: "Gemini 3 Pro daily quota exceeded. Please retry with model: 'gemini-3-flash-preview'",
12
+ TOOL_NOT_FOUND: 'not found in registry',
13
+ NO_PROMPT_PROVIDED: "Please provide a prompt for analysis. Use @ syntax to include files (e.g., '@largefile.js explain what this does') or ask general questions",
14
+ };
15
+ // Status messages
16
+ export const STATUS_MESSAGES = {
17
+ QUOTA_SWITCHING: 'Gemini 3 Pro quota exceeded, switching to Flash model...',
18
+ FLASH_RETRY: 'Retrying with Gemini 3 Flash...',
19
+ FLASH_SUCCESS: 'Flash model completed successfully',
20
+ SANDBOX_EXECUTING: 'Executing Gemini CLI command in sandbox mode...',
21
+ GEMINI_RESPONSE: 'Gemini response:',
22
+ PROCESSING_START: 'Starting analysis (may take 5-15 minutes for large codebases)',
23
+ PROCESSING_CONTINUE: 'Still processing... Gemini is working on your request',
24
+ PROCESSING_COMPLETE: 'Analysis completed successfully',
25
+ };
26
+ // MCP Protocol Constants
27
+ export const PROTOCOL = {
28
+ ROLES: {
29
+ USER: 'user',
30
+ ASSISTANT: 'assistant',
31
+ },
32
+ CONTENT_TYPES: {
33
+ TEXT: 'text',
34
+ },
35
+ STATUS: {
36
+ SUCCESS: 'success',
37
+ ERROR: 'error',
38
+ FAILED: 'failed',
39
+ REPORT: 'report',
40
+ },
41
+ NOTIFICATIONS: {
42
+ PROGRESS: 'notifications/progress',
43
+ },
44
+ KEEPALIVE_INTERVAL: 25000,
45
+ };
46
+ // CLI Constants
47
+ export const CLI = {
48
+ COMMANDS: {
49
+ GEMINI: 'gemini',
50
+ ECHO: 'echo',
51
+ },
52
+ FLAGS: {
53
+ MODEL: '-m',
54
+ SANDBOX: '-s',
55
+ PROMPT: '-p',
56
+ HELP: '-help',
57
+ },
58
+ DEFAULTS: {
59
+ MODEL: 'default',
60
+ BOOLEAN_TRUE: 'true',
61
+ BOOLEAN_FALSE: 'false',
62
+ },
63
+ };
64
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,6CAA6C;AAC7C,OAAO,EAAiB,MAAM,EAAE,MAAM,YAAY,CAAC;AAEnD,UAAU;AACV,MAAM,CAAC,MAAM,UAAU,GAAG,QAAQ,CAAC;AAEnC,iBAAiB;AACjB,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,cAAc,EAAE,yDAAyD;IACzE,oBAAoB,EAClB,sFAAsF;IACxF,cAAc,EAAE,uBAAuB;IACvC,kBAAkB,EAChB,6IAA6I;CACvI,CAAC;AAEX,kBAAkB;AAClB,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,eAAe,EAAE,0DAA0D;IAC3E,WAAW,EAAE,iCAAiC;IAC9C,aAAa,EAAE,oCAAoC;IACnD,iBAAiB,EAAE,iDAAiD;IACpE,eAAe,EAAE,kBAAkB;IACnC,gBAAgB,EACd,+DAA+D;IACjE,mBAAmB,EAAE,uDAAuD;IAC5E,mBAAmB,EAAE,iCAAiC;CAC9C,CAAC;AAEX,yBAAyB;AACzB,MAAM,CAAC,MAAM,QAAQ,GAAG;IACtB,KAAK,EAAE;QACL,IAAI,EAAE,MAAM;QACZ,SAAS,EAAE,WAAW;KACvB;IACD,aAAa,EAAE;QACb,IAAI,EAAE,MAAM;KACb;IACD,MAAM,EAAE;QACN,OAAO,EAAE,SAAS;QAClB,KAAK,EAAE,OAAO;QACd,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE,QAAQ;KACjB;IACD,aAAa,EAAE;QACb,QAAQ,EAAE,wBAAwB;KACnC;IACD,kBAAkB,EAAE,KAAK;CACjB,CAAC;AAEX,gBAAgB;AAChB,MAAM,CAAC,MAAM,GAAG,GAAG;IACjB,QAAQ,EAAE;QACR,MAAM,EAAE,QAAQ;QAChB,IAAI,EAAE,MAAM;KACb;IACD,KAAK,EAAE;QACL,KAAK,EAAE,IAAI;QACX,OAAO,EAAE,IAAI;QACb,MAAM,EAAE,IAAI;QACZ,IAAI,EAAE,OAAO;KACd;IACD,QAAQ,EAAE;QACR,KAAK,EAAE,SAAS;QAChB,YAAY,EAAE,MAAM;QACpB,aAAa,EAAE,OAAO;KACvB;CACO,CAAC"}
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Custom error classes for the Gemini MCP Server
3
+ */
4
+ export declare class ToolExecutionError extends Error {
5
+ readonly toolName: string;
6
+ readonly cause?: Error | undefined;
7
+ constructor(toolName: string, message: string, cause?: Error | undefined);
8
+ }
9
+ export declare class CommandExecutionError extends Error {
10
+ readonly command: string;
11
+ readonly exitCode?: number | undefined;
12
+ constructor(command: string, message: string, exitCode?: number | undefined);
13
+ }
14
+ export declare class ValidationError extends Error {
15
+ constructor(message: string);
16
+ }
17
+ export declare class QuotaExceededError extends Error {
18
+ constructor(model: string);
19
+ }
20
+ /**
21
+ * Handle errors and return a user-friendly message
22
+ */
23
+ export declare function handleError(error: unknown, context: string): string;
24
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qBAAa,kBAAmB,SAAQ,KAAK;aAEzB,QAAQ,EAAE,MAAM;aAEhB,KAAK,CAAC,EAAE,KAAK;gBAFb,QAAQ,EAAE,MAAM,EAChC,OAAO,EAAE,MAAM,EACC,KAAK,CAAC,EAAE,KAAK,YAAA;CAKhC;AAED,qBAAa,qBAAsB,SAAQ,KAAK;aAE5B,OAAO,EAAE,MAAM;aAEf,QAAQ,CAAC,EAAE,MAAM;gBAFjB,OAAO,EAAE,MAAM,EAC/B,OAAO,EAAE,MAAM,EACC,QAAQ,CAAC,EAAE,MAAM,YAAA;CAKpC;AAED,qBAAa,eAAgB,SAAQ,KAAK;gBAC5B,OAAO,EAAE,MAAM;CAI5B;AAED,qBAAa,kBAAmB,SAAQ,KAAK;gBAC/B,KAAK,EAAE,MAAM;CAI1B;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,GAAG,MAAM,CAsBnE"}
package/dist/errors.js ADDED
@@ -0,0 +1,57 @@
1
+ /**
2
+ * Custom error classes for the Gemini MCP Server
3
+ */
4
+ export class ToolExecutionError extends Error {
5
+ toolName;
6
+ cause;
7
+ constructor(toolName, message, cause) {
8
+ super(`Error executing tool '${toolName}': ${message}`);
9
+ this.toolName = toolName;
10
+ this.cause = cause;
11
+ this.name = 'ToolExecutionError';
12
+ }
13
+ }
14
+ export class CommandExecutionError extends Error {
15
+ command;
16
+ exitCode;
17
+ constructor(command, message, exitCode) {
18
+ super(`Command '${command}' failed: ${message}`);
19
+ this.command = command;
20
+ this.exitCode = exitCode;
21
+ this.name = 'CommandExecutionError';
22
+ }
23
+ }
24
+ export class ValidationError extends Error {
25
+ constructor(message) {
26
+ super(message);
27
+ this.name = 'ValidationError';
28
+ }
29
+ }
30
+ export class QuotaExceededError extends Error {
31
+ constructor(model) {
32
+ super(`Quota exceeded for model: ${model}`);
33
+ this.name = 'QuotaExceededError';
34
+ }
35
+ }
36
+ /**
37
+ * Handle errors and return a user-friendly message
38
+ */
39
+ export function handleError(error, context) {
40
+ if (error instanceof ToolExecutionError) {
41
+ return `${context}: ${error.message}`;
42
+ }
43
+ if (error instanceof CommandExecutionError) {
44
+ return `${context}: ${error.message}`;
45
+ }
46
+ if (error instanceof ValidationError) {
47
+ return `Validation error in ${context}: ${error.message}`;
48
+ }
49
+ if (error instanceof QuotaExceededError) {
50
+ return `${context}: ${error.message}`;
51
+ }
52
+ if (error instanceof Error) {
53
+ return `${context}: ${error.message}`;
54
+ }
55
+ return `${context}: An unknown error occurred`;
56
+ }
57
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAEzB;IAEA;IAHlB,YACkB,QAAgB,EAChC,OAAe,EACC,KAAa;QAE7B,KAAK,CAAC,yBAAyB,QAAQ,MAAM,OAAO,EAAE,CAAC,CAAC;QAJxC,aAAQ,GAAR,QAAQ,CAAQ;QAEhB,UAAK,GAAL,KAAK,CAAQ;QAG7B,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IAE5B;IAEA;IAHlB,YACkB,OAAe,EAC/B,OAAe,EACC,QAAiB;QAEjC,KAAK,CAAC,YAAY,OAAO,aAAa,OAAO,EAAE,CAAC,CAAC;QAJjC,YAAO,GAAP,OAAO,CAAQ;QAEf,aAAQ,GAAR,QAAQ,CAAS;QAGjC,IAAI,CAAC,IAAI,GAAG,uBAAuB,CAAC;IACtC,CAAC;CACF;AAED,MAAM,OAAO,eAAgB,SAAQ,KAAK;IACxC,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AAED,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAC3C,YAAY,KAAa;QACvB,KAAK,CAAC,6BAA6B,KAAK,EAAE,CAAC,CAAC;QAC5C,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;IACnC,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAC,KAAc,EAAE,OAAe;IACzD,IAAI,KAAK,YAAY,kBAAkB,EAAE,CAAC;QACxC,OAAO,GAAG,OAAO,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;IACxC,CAAC;IAED,IAAI,KAAK,YAAY,qBAAqB,EAAE,CAAC;QAC3C,OAAO,GAAG,OAAO,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;IACxC,CAAC;IAED,IAAI,KAAK,YAAY,eAAe,EAAE,CAAC;QACrC,OAAO,uBAAuB,OAAO,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;IAC5D,CAAC;IAED,IAAI,KAAK,YAAY,kBAAkB,EAAE,CAAC;QACxC,OAAO,GAAG,OAAO,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;IACxC,CAAC;IAED,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;QAC3B,OAAO,GAAG,OAAO,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;IACxC,CAAC;IAED,OAAO,GAAG,OAAO,6BAA6B,CAAC;AACjD,CAAC"}
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Gemini MCP Server - Entry Point
4
+ *
5
+ * MCP server for Gemini CLI integration
6
+ */
7
+ export {};
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;GAIG"}
package/dist/index.js ADDED
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Gemini MCP Server - Entry Point
4
+ *
5
+ * MCP server for Gemini CLI integration
6
+ */
7
+ import chalk from 'chalk';
8
+ import { GeminiMcpServer } from './server.js';
9
+ const SERVER_CONFIG = {
10
+ name: 'gemini-mcp-server',
11
+ version: '1.0.0',
12
+ };
13
+ async function main() {
14
+ try {
15
+ const server = new GeminiMcpServer(SERVER_CONFIG);
16
+ await server.start();
17
+ }
18
+ catch (error) {
19
+ console.error(chalk.red('Failed to start server:'), error);
20
+ process.exit(1);
21
+ }
22
+ }
23
+ main();
24
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;GAIG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,MAAM,aAAa,GAAG;IACpB,IAAI,EAAE,mBAAmB;IACzB,OAAO,EAAE,OAAO;CACjB,CAAC;AAEF,KAAK,UAAU,IAAI;IACjB,IAAI,CAAC;QACH,MAAM,MAAM,GAAG,IAAI,eAAe,CAAC,aAAa,CAAC,CAAC;QAClD,MAAM,MAAM,CAAC,KAAK,EAAE,CAAC;IACvB,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,yBAAyB,CAAC,EAAE,KAAK,CAAC,CAAC;QAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC;AAED,IAAI,EAAE,CAAC"}