cat-gemini-mcp 1.2.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 +25 -0
- package/README.md +192 -0
- package/dist/constants.d.ts +74 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +73 -0
- package/dist/constants.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +188 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/ask-gemini.tool.d.ts +3 -0
- package/dist/tools/ask-gemini.tool.d.ts.map +1 -0
- package/dist/tools/ask-gemini.tool.js +36 -0
- package/dist/tools/ask-gemini.tool.js.map +1 -0
- package/dist/tools/brainstorm.tool.d.ts +3 -0
- package/dist/tools/brainstorm.tool.d.ts.map +1 -0
- package/dist/tools/brainstorm.tool.js +136 -0
- package/dist/tools/brainstorm.tool.js.map +1 -0
- package/dist/tools/fetch-chunk.tool.d.ts +3 -0
- package/dist/tools/fetch-chunk.tool.d.ts.map +1 -0
- package/dist/tools/fetch-chunk.tool.js +62 -0
- package/dist/tools/fetch-chunk.tool.js.map +1 -0
- package/dist/tools/index.d.ts +2 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +10 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/registry.d.ts +25 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +80 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/simple-tools.d.ts +4 -0
- package/dist/tools/simple-tools.d.ts.map +1 -0
- package/dist/tools/simple-tools.js +32 -0
- package/dist/tools/simple-tools.js.map +1 -0
- package/dist/tools/test-tool.example.d.ts +13 -0
- package/dist/tools/test-tool.example.d.ts.map +1 -0
- package/dist/tools/test-tool.example.js +32 -0
- package/dist/tools/test-tool.example.js.map +1 -0
- package/dist/tools/timeout-test.tool.d.ts +3 -0
- package/dist/tools/timeout-test.tool.d.ts.map +1 -0
- package/dist/tools/timeout-test.tool.js +32 -0
- package/dist/tools/timeout-test.tool.js.map +1 -0
- package/dist/utils/changeModeChunker.d.ts +11 -0
- package/dist/utils/changeModeChunker.d.ts.map +1 -0
- package/dist/utils/changeModeChunker.js +89 -0
- package/dist/utils/changeModeChunker.js.map +1 -0
- package/dist/utils/changeModeParser.d.ts +15 -0
- package/dist/utils/changeModeParser.d.ts.map +1 -0
- package/dist/utils/changeModeParser.js +67 -0
- package/dist/utils/changeModeParser.js.map +1 -0
- package/dist/utils/changeModeTranslator.d.ts +8 -0
- package/dist/utils/changeModeTranslator.d.ts.map +1 -0
- package/dist/utils/changeModeTranslator.js +70 -0
- package/dist/utils/changeModeTranslator.js.map +1 -0
- package/dist/utils/chunkCache.d.ts +22 -0
- package/dist/utils/chunkCache.d.ts.map +1 -0
- package/dist/utils/chunkCache.js +161 -0
- package/dist/utils/chunkCache.js.map +1 -0
- package/dist/utils/commandExecutor.d.ts +2 -0
- package/dist/utils/commandExecutor.d.ts.map +1 -0
- package/dist/utils/commandExecutor.js +77 -0
- package/dist/utils/commandExecutor.js.map +1 -0
- package/dist/utils/geminiExecutor.d.ts +3 -0
- package/dist/utils/geminiExecutor.d.ts.map +1 -0
- package/dist/utils/geminiExecutor.js +181 -0
- package/dist/utils/geminiExecutor.js.map +1 -0
- package/dist/utils/logger.d.ts +13 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +42 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/timeoutManager.d.ts +2 -0
- package/dist/utils/timeoutManager.d.ts.map +1 -0
- package/dist/utils/timeoutManager.js +2 -0
- package/dist/utils/timeoutManager.js.map +1 -0
- package/package.json +71 -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,192 @@
|
|
|
1
|
+
|
|
2
|
+
# Gemini MCP Tool
|
|
3
|
+
|
|
4
|
+
<div align="center">
|
|
5
|
+
|
|
6
|
+
[](https://github.com/jamubc/gemini-mcp-tool/releases)
|
|
7
|
+
[](https://www.npmjs.com/package/gemini-mcp-tool)
|
|
8
|
+
[](https://www.npmjs.com/package/gemini-mcp-tool)
|
|
9
|
+
[](https://opensource.org/licenses/MIT)
|
|
10
|
+
[](https://github.com/jamubc/gemini-mcp-tool)
|
|
11
|
+
|
|
12
|
+
</div>
|
|
13
|
+
|
|
14
|
+
> 📚 **[View Full Documentation](https://jamubc.github.io/gemini-mcp-tool/)** - Search me!, Examples, FAQ, Troubleshooting, Best Practices
|
|
15
|
+
|
|
16
|
+
This is a simple Model Context Protocol (MCP) server that allows AI assistants to interact with the [Gemini CLI](https://github.com/google-gemini/gemini-cli). It enables the AI to leverage the power of Gemini's massive token window for large analysis, especially with large files and codebases using the `@` syntax for direction.
|
|
17
|
+
|
|
18
|
+
- Ask gemini natural questions, through claude or Brainstorm new ideas in a party of 3!
|
|
19
|
+
|
|
20
|
+
<a href="https://glama.ai/mcp/servers/@jamubc/gemini-mcp-tool">
|
|
21
|
+
<img width="380" height="200" src="https://glama.ai/mcp/servers/@jamubc/gemini-mcp-tool/badge" alt="Gemini Tool MCP server" />
|
|
22
|
+
</a>
|
|
23
|
+
|
|
24
|
+
## TLDR: [](#) + [](#)
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
**Goal**: Use Gemini's powerful analysis capabilities directly in Claude Code to save tokens and analyze large files.
|
|
28
|
+
|
|
29
|
+
## Prerequisites
|
|
30
|
+
|
|
31
|
+
Before using this tool, ensure you have:
|
|
32
|
+
|
|
33
|
+
1. **[Node.js](https://nodejs.org/)** (v16.0.0 or higher)
|
|
34
|
+
2. **[Google Gemini CLI](https://github.com/google-gemini/gemini-cli)** installed and configured
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
### One-Line Setup
|
|
38
|
+
|
|
39
|
+
```bash
|
|
40
|
+
claude mcp add gemini-cli -- npx -y gemini-mcp-tool
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
### Verify Installation
|
|
44
|
+
|
|
45
|
+
Type `/mcp` inside Claude Code to verify the gemini-cli MCP is active.
|
|
46
|
+
|
|
47
|
+
---
|
|
48
|
+
|
|
49
|
+
### Alternative: Import from Claude Desktop
|
|
50
|
+
|
|
51
|
+
If you already have it configured in Claude Desktop:
|
|
52
|
+
|
|
53
|
+
1. Add to your Claude Desktop config:
|
|
54
|
+
```json
|
|
55
|
+
"gemini-cli": {
|
|
56
|
+
"command": "npx",
|
|
57
|
+
"args": ["-y", "gemini-mcp-tool"]
|
|
58
|
+
}
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
2. Import to Claude Code:
|
|
62
|
+
```bash
|
|
63
|
+
claude mcp add-from-claude-desktop
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Configuration
|
|
67
|
+
|
|
68
|
+
Register the MCP server with your MCP client:
|
|
69
|
+
|
|
70
|
+
### For NPX Usage (Recommended)
|
|
71
|
+
|
|
72
|
+
Add this configuration to your Claude Desktop config file:
|
|
73
|
+
|
|
74
|
+
```json
|
|
75
|
+
{
|
|
76
|
+
"mcpServers": {
|
|
77
|
+
"gemini-cli": {
|
|
78
|
+
"command": "npx",
|
|
79
|
+
"args": ["-y", "gemini-mcp-tool"]
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### With Custom Default Model
|
|
86
|
+
|
|
87
|
+
You can set a default model via environment variable to avoid specifying it in every request:
|
|
88
|
+
|
|
89
|
+
```json
|
|
90
|
+
{
|
|
91
|
+
"mcpServers": {
|
|
92
|
+
"gemini-cli": {
|
|
93
|
+
"command": "npx",
|
|
94
|
+
"args": ["-y", "gemini-mcp-tool"],
|
|
95
|
+
"env": {
|
|
96
|
+
"GEMINI_DEFAULT_MODEL": "gemini-3-flash"
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
Supported environment variables:
|
|
104
|
+
- `GEMINI_DEFAULT_MODEL` - Sets the default Gemini model (e.g., `gemini-3-pro`, `gemini-3-flash`)
|
|
105
|
+
- `DEFAULT_MODEL` - Alternative name for the same setting
|
|
106
|
+
|
|
107
|
+
### For Global Installation
|
|
108
|
+
|
|
109
|
+
If you installed globally, use this configuration instead:
|
|
110
|
+
|
|
111
|
+
```json
|
|
112
|
+
{
|
|
113
|
+
"mcpServers": {
|
|
114
|
+
"gemini-cli": {
|
|
115
|
+
"command": "gemini-mcp"
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
**Configuration File Locations:**
|
|
122
|
+
|
|
123
|
+
- **Claude Desktop**:
|
|
124
|
+
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
|
|
125
|
+
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
|
|
126
|
+
- **Linux**: `~/.config/claude/claude_desktop_config.json`
|
|
127
|
+
|
|
128
|
+
After updating the configuration, restart your terminal session.
|
|
129
|
+
|
|
130
|
+
## Example Workflow
|
|
131
|
+
|
|
132
|
+
- **Natural language**: "use gemini to explain index.html", "understand the massive project using gemini", "ask gemini to search for latest news"
|
|
133
|
+
- **Claude Code**: Type `/gemini-cli` and commands will populate in Claude Code's interface.
|
|
134
|
+
|
|
135
|
+
## Usage Examples
|
|
136
|
+
|
|
137
|
+
### With File References (using @ syntax)
|
|
138
|
+
|
|
139
|
+
- `ask gemini to analyze @src/main.js and explain what it does`
|
|
140
|
+
- `use gemini to summarize @. the current directory`
|
|
141
|
+
- `analyze @package.json and tell me about dependencies`
|
|
142
|
+
|
|
143
|
+
### General Questions (without files)
|
|
144
|
+
|
|
145
|
+
- `ask gemini to search for the latest tech news`
|
|
146
|
+
- `use gemini to explain div centering`
|
|
147
|
+
- `ask gemini about best practices for React development related to @file_im_confused_about`
|
|
148
|
+
|
|
149
|
+
### Using Gemini CLI's Sandbox Mode (-s)
|
|
150
|
+
|
|
151
|
+
The sandbox mode allows you to safely test code changes, run scripts, or execute potentially risky operations in an isolated environment.
|
|
152
|
+
|
|
153
|
+
- `use gemini sandbox to create and run a Python script that processes data`
|
|
154
|
+
- `ask gemini to safely test @script.py and explain what it does`
|
|
155
|
+
- `use gemini sandbox to install numpy and create a data visualization`
|
|
156
|
+
- `test this code safely: Create a script that makes HTTP requests to an API`
|
|
157
|
+
|
|
158
|
+
### Tools (for the AI)
|
|
159
|
+
|
|
160
|
+
These tools are designed to be used by the AI assistant.
|
|
161
|
+
|
|
162
|
+
- **`ask-gemini`**: Asks Google Gemini for its perspective. Can be used for general questions or complex analysis of files.
|
|
163
|
+
- **`prompt`** (required): The analysis request. Use the `@` syntax to include file or directory references (e.g., `@src/main.js explain this code`) or ask general questions (e.g., `Please use a web search to find the latest news stories`).
|
|
164
|
+
- **`model`** (optional): The Gemini model to use. Defaults to `gemini-3-pro`. You can specify alternative models like `gemini-3-flash` for faster responses.
|
|
165
|
+
- **`sandbox`** (optional): Set to `true` to run in sandbox mode for safe code execution.
|
|
166
|
+
- **`sandbox-test`**: Safely executes code or commands in Gemini's sandbox environment. Always runs in sandbox mode.
|
|
167
|
+
- **`prompt`** (required): Code testing request (e.g., `Create and run a Python script that...` or `@script.py Run this safely`).
|
|
168
|
+
- **`model`** (optional): The Gemini model to use.
|
|
169
|
+
- **`Ping`**: A simple test tool that echoes back a message.
|
|
170
|
+
- **`Help`**: Shows the Gemini CLI help text.
|
|
171
|
+
|
|
172
|
+
### Slash Commands (for the User)
|
|
173
|
+
|
|
174
|
+
You can use these commands directly in Claude Code's interface (compatibility with other clients has not been tested).
|
|
175
|
+
|
|
176
|
+
- **/analyze**: Analyzes files or directories using Gemini, or asks general questions.
|
|
177
|
+
- **`prompt`** (required): The analysis prompt. Use `@` syntax to include files (e.g., `/analyze prompt:@src/ summarize this directory`) or ask general questions (e.g., `/analyze prompt:Please use a web search to find the latest news stories`).
|
|
178
|
+
- **/sandbox**: Safely tests code or scripts in Gemini's sandbox environment.
|
|
179
|
+
- **`prompt`** (required): Code testing request (e.g., `/sandbox prompt:Create and run a Python script that processes CSV data` or `/sandbox prompt:@script.py Test this script safely`).
|
|
180
|
+
- **/help**: Displays the Gemini CLI help information.
|
|
181
|
+
- **/ping**: Tests the connection to the server.
|
|
182
|
+
- **`message`** (optional): A message to echo back.
|
|
183
|
+
|
|
184
|
+
## Contributing
|
|
185
|
+
|
|
186
|
+
Contributions are welcome! Please see our [Contributing Guidelines](CONTRIBUTING.md) for details on how to submit pull requests, report issues, and contribute to the project.
|
|
187
|
+
|
|
188
|
+
## License
|
|
189
|
+
|
|
190
|
+
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
|
|
191
|
+
|
|
192
|
+
**Disclaimer:** This is an unofficial, third-party tool and is not affiliated with, endorsed, or sponsored by Google.
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
export declare const LOG_PREFIX = "[GMCPT]";
|
|
2
|
+
export declare const ERROR_MESSAGES: {
|
|
3
|
+
readonly QUOTA_EXCEEDED: "Quota exceeded for quota metric 'Gemini 3 Pro Requests'";
|
|
4
|
+
readonly QUOTA_EXCEEDED_SHORT: "⚠️ Gemini 3 Pro daily quota exceeded. Please retry with model: 'gemini-3-flash'";
|
|
5
|
+
readonly TOOL_NOT_FOUND: "not found in registry";
|
|
6
|
+
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";
|
|
7
|
+
};
|
|
8
|
+
export declare const STATUS_MESSAGES: {
|
|
9
|
+
readonly QUOTA_SWITCHING: "🚫 Gemini 3 Pro quota exceeded, switching to Flash model...";
|
|
10
|
+
readonly FLASH_RETRY: "⚡ Retrying with Gemini 3 Flash...";
|
|
11
|
+
readonly FLASH_SUCCESS: "✅ Flash model completed successfully";
|
|
12
|
+
readonly SANDBOX_EXECUTING: "🔒 Executing Gemini CLI command in sandbox mode...";
|
|
13
|
+
readonly GEMINI_RESPONSE: "Gemini response:";
|
|
14
|
+
readonly PROCESSING_START: "🔍 Starting analysis (may take 5-15 minutes for large codebases)";
|
|
15
|
+
readonly PROCESSING_CONTINUE: "⏳ Still processing... Gemini is working on your request";
|
|
16
|
+
readonly PROCESSING_COMPLETE: "✅ Analysis completed successfully";
|
|
17
|
+
};
|
|
18
|
+
export declare const MODELS: {
|
|
19
|
+
readonly PRO: "gemini-3-pro";
|
|
20
|
+
readonly FLASH: "gemini-3-flash";
|
|
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
|
+
export interface ToolArguments {
|
|
59
|
+
prompt?: string;
|
|
60
|
+
model?: string;
|
|
61
|
+
sandbox?: boolean | string;
|
|
62
|
+
changeMode?: boolean | string;
|
|
63
|
+
chunkIndex?: number | string;
|
|
64
|
+
chunkCacheKey?: string;
|
|
65
|
+
message?: string;
|
|
66
|
+
methodology?: string;
|
|
67
|
+
domain?: string;
|
|
68
|
+
constraints?: string;
|
|
69
|
+
existingContext?: string;
|
|
70
|
+
ideaCount?: number;
|
|
71
|
+
includeAnalysis?: boolean;
|
|
72
|
+
[key: string]: string | boolean | number | undefined;
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,UAAU,YAAY,CAAC;AAGpC,eAAO,MAAM,cAAc;;;;;CAKjB,CAAC;AAGX,eAAO,MAAM,eAAe;;;;;;;;;CAUlB,CAAC;AAGX,eAAO,MAAM,MAAM;;;CAGT,CAAC;AAGX,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;CAuBX,CAAC;AAIX,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;CAmBN,CAAC;AAIX,MAAM,WAAW,aAAa;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC9B,UAAU,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,OAAO,CAAC;IAE1B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,MAAM,GAAG,SAAS,CAAC;CACtD"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Logging
|
|
2
|
+
export const LOG_PREFIX = "[GMCPT]";
|
|
3
|
+
// Error messages
|
|
4
|
+
export const ERROR_MESSAGES = {
|
|
5
|
+
QUOTA_EXCEEDED: "Quota exceeded for quota metric 'Gemini 3 Pro Requests'",
|
|
6
|
+
QUOTA_EXCEEDED_SHORT: "⚠️ Gemini 3 Pro daily quota exceeded. Please retry with model: 'gemini-3-flash'",
|
|
7
|
+
TOOL_NOT_FOUND: "not found in registry",
|
|
8
|
+
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",
|
|
9
|
+
};
|
|
10
|
+
// Status messages
|
|
11
|
+
export const STATUS_MESSAGES = {
|
|
12
|
+
QUOTA_SWITCHING: "🚫 Gemini 3 Pro quota exceeded, switching to Flash model...",
|
|
13
|
+
FLASH_RETRY: "⚡ Retrying with Gemini 3 Flash...",
|
|
14
|
+
FLASH_SUCCESS: "✅ Flash model completed successfully",
|
|
15
|
+
SANDBOX_EXECUTING: "🔒 Executing Gemini CLI command in sandbox mode...",
|
|
16
|
+
GEMINI_RESPONSE: "Gemini response:",
|
|
17
|
+
// Timeout prevention messages
|
|
18
|
+
PROCESSING_START: "🔍 Starting analysis (may take 5-15 minutes for large codebases)",
|
|
19
|
+
PROCESSING_CONTINUE: "⏳ Still processing... Gemini is working on your request",
|
|
20
|
+
PROCESSING_COMPLETE: "✅ Analysis completed successfully",
|
|
21
|
+
};
|
|
22
|
+
// Models
|
|
23
|
+
export const MODELS = {
|
|
24
|
+
PRO: "gemini-3-pro",
|
|
25
|
+
FLASH: "gemini-3-flash",
|
|
26
|
+
};
|
|
27
|
+
// MCP Protocol Constants
|
|
28
|
+
export const PROTOCOL = {
|
|
29
|
+
// Message roles
|
|
30
|
+
ROLES: {
|
|
31
|
+
USER: "user",
|
|
32
|
+
ASSISTANT: "assistant",
|
|
33
|
+
},
|
|
34
|
+
// Content types
|
|
35
|
+
CONTENT_TYPES: {
|
|
36
|
+
TEXT: "text",
|
|
37
|
+
},
|
|
38
|
+
// Status codes
|
|
39
|
+
STATUS: {
|
|
40
|
+
SUCCESS: "success",
|
|
41
|
+
ERROR: "error",
|
|
42
|
+
FAILED: "failed",
|
|
43
|
+
REPORT: "report",
|
|
44
|
+
},
|
|
45
|
+
// Notification methods
|
|
46
|
+
NOTIFICATIONS: {
|
|
47
|
+
PROGRESS: "notifications/progress",
|
|
48
|
+
},
|
|
49
|
+
// Timeout prevention
|
|
50
|
+
KEEPALIVE_INTERVAL: 25000, // 25 seconds
|
|
51
|
+
};
|
|
52
|
+
// CLI Constants
|
|
53
|
+
export const CLI = {
|
|
54
|
+
// Command names
|
|
55
|
+
COMMANDS: {
|
|
56
|
+
GEMINI: "gemini",
|
|
57
|
+
ECHO: "echo",
|
|
58
|
+
},
|
|
59
|
+
// Command flags
|
|
60
|
+
FLAGS: {
|
|
61
|
+
MODEL: "-m",
|
|
62
|
+
SANDBOX: "-s",
|
|
63
|
+
PROMPT: "-p",
|
|
64
|
+
HELP: "-help",
|
|
65
|
+
},
|
|
66
|
+
// Default values
|
|
67
|
+
DEFAULTS: {
|
|
68
|
+
MODEL: "default", // Fallback model used when no specific model is provided
|
|
69
|
+
BOOLEAN_TRUE: "true",
|
|
70
|
+
BOOLEAN_FALSE: "false",
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,UAAU;AACV,MAAM,CAAC,MAAM,UAAU,GAAG,SAAS,CAAC;AAEpC,iBAAiB;AACjB,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,cAAc,EAAE,yDAAyD;IACzE,oBAAoB,EAAE,iFAAiF;IACvG,cAAc,EAAE,uBAAuB;IACvC,kBAAkB,EAAE,6IAA6I;CACzJ,CAAC;AAEX,kBAAkB;AAClB,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,eAAe,EAAE,6DA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1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Server } from "@modelcontextprotocol/sdk/server/index.js";
|
|
3
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
4
|
+
import { CallToolRequestSchema, ListToolsRequestSchema, ListPromptsRequestSchema, GetPromptRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
|
|
5
|
+
import { Logger } from "./utils/logger.js";
|
|
6
|
+
import { PROTOCOL } from "./constants.js";
|
|
7
|
+
import { getToolDefinitions, getPromptDefinitions, executeTool, toolExists, getPromptMessage } from "./tools/index.js";
|
|
8
|
+
const server = new Server({
|
|
9
|
+
name: "gemini-cli-mcp",
|
|
10
|
+
version: "1.1.4",
|
|
11
|
+
}, {
|
|
12
|
+
capabilities: {
|
|
13
|
+
tools: {},
|
|
14
|
+
prompts: {},
|
|
15
|
+
notifications: {},
|
|
16
|
+
logging: {},
|
|
17
|
+
},
|
|
18
|
+
});
|
|
19
|
+
let isProcessing = false;
|
|
20
|
+
let currentOperationName = "";
|
|
21
|
+
let latestOutput = "";
|
|
22
|
+
async function sendNotification(method, params) {
|
|
23
|
+
try {
|
|
24
|
+
await server.notification({ method, params });
|
|
25
|
+
}
|
|
26
|
+
catch (error) {
|
|
27
|
+
Logger.error("notification failed: ", error);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* @param progressToken The progress token provided by the client
|
|
32
|
+
* @param progress The current progress value
|
|
33
|
+
* @param total Optional total value
|
|
34
|
+
* @param message Optional status message
|
|
35
|
+
*/
|
|
36
|
+
async function sendProgressNotification(progressToken, progress, total, message) {
|
|
37
|
+
if (!progressToken)
|
|
38
|
+
return; // Only send if client requested progress
|
|
39
|
+
try {
|
|
40
|
+
const params = {
|
|
41
|
+
progressToken,
|
|
42
|
+
progress
|
|
43
|
+
};
|
|
44
|
+
if (total !== undefined)
|
|
45
|
+
params.total = total; // future cache progress
|
|
46
|
+
if (message)
|
|
47
|
+
params.message = message;
|
|
48
|
+
await server.notification({
|
|
49
|
+
method: PROTOCOL.NOTIFICATIONS.PROGRESS,
|
|
50
|
+
params
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
Logger.error("Failed to send progress notification:", error);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
function startProgressUpdates(operationName, progressToken) {
|
|
58
|
+
isProcessing = true;
|
|
59
|
+
currentOperationName = operationName;
|
|
60
|
+
latestOutput = ""; // Reset latest output
|
|
61
|
+
const progressMessages = [
|
|
62
|
+
`🧠 ${operationName} - Gemini is analyzing your request...`,
|
|
63
|
+
`📊 ${operationName} - Processing files and generating insights...`,
|
|
64
|
+
`✨ ${operationName} - Creating structured response for your review...`,
|
|
65
|
+
`⏱️ ${operationName} - Large analysis in progress (this is normal for big requests)...`,
|
|
66
|
+
`🔍 ${operationName} - Still working... Gemini takes time for quality results...`,
|
|
67
|
+
];
|
|
68
|
+
let messageIndex = 0;
|
|
69
|
+
let progress = 0;
|
|
70
|
+
// Send immediate acknowledgment if progress requested
|
|
71
|
+
if (progressToken) {
|
|
72
|
+
sendProgressNotification(progressToken, 0, undefined, // No total - indeterminate progress
|
|
73
|
+
`🔍 Starting ${operationName}`);
|
|
74
|
+
}
|
|
75
|
+
// Keep client alive with periodic updates
|
|
76
|
+
const progressInterval = setInterval(async () => {
|
|
77
|
+
if (isProcessing && progressToken) {
|
|
78
|
+
// Simply increment progress value
|
|
79
|
+
progress += 1;
|
|
80
|
+
// Include latest output if available
|
|
81
|
+
const baseMessage = progressMessages[messageIndex % progressMessages.length];
|
|
82
|
+
const outputPreview = latestOutput.slice(-150).trim(); // Last 150 chars
|
|
83
|
+
const message = outputPreview
|
|
84
|
+
? `${baseMessage}\n📝 Output: ...${outputPreview}`
|
|
85
|
+
: baseMessage;
|
|
86
|
+
await sendProgressNotification(progressToken, progress, undefined, // No total - indeterminate progress
|
|
87
|
+
message);
|
|
88
|
+
messageIndex++;
|
|
89
|
+
}
|
|
90
|
+
else if (!isProcessing) {
|
|
91
|
+
clearInterval(progressInterval);
|
|
92
|
+
}
|
|
93
|
+
}, PROTOCOL.KEEPALIVE_INTERVAL); // Every 25 seconds
|
|
94
|
+
return { interval: progressInterval, progressToken };
|
|
95
|
+
}
|
|
96
|
+
function stopProgressUpdates(progressData, success = true) {
|
|
97
|
+
const operationName = currentOperationName; // Store before clearing
|
|
98
|
+
isProcessing = false;
|
|
99
|
+
currentOperationName = "";
|
|
100
|
+
clearInterval(progressData.interval);
|
|
101
|
+
// Send final progress notification if client requested progress
|
|
102
|
+
if (progressData.progressToken) {
|
|
103
|
+
sendProgressNotification(progressData.progressToken, 100, 100, success ? `✅ ${operationName} completed successfully` : `❌ ${operationName} failed`);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
// tools/list
|
|
107
|
+
server.setRequestHandler(ListToolsRequestSchema, async (request) => {
|
|
108
|
+
return { tools: getToolDefinitions() };
|
|
109
|
+
});
|
|
110
|
+
// tools/get
|
|
111
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
112
|
+
const toolName = request.params.name;
|
|
113
|
+
if (toolExists(toolName)) {
|
|
114
|
+
// Check if client requested progress updates
|
|
115
|
+
const progressToken = request.params._meta?.progressToken;
|
|
116
|
+
// Start progress updates if client requested them
|
|
117
|
+
const progressData = startProgressUpdates(toolName, progressToken);
|
|
118
|
+
try {
|
|
119
|
+
// Get prompt and other parameters from arguments with proper typing
|
|
120
|
+
const args = request.params.arguments || {};
|
|
121
|
+
Logger.toolInvocation(toolName, request.params.arguments);
|
|
122
|
+
// Execute the tool using the unified registry with progress callback
|
|
123
|
+
const result = await executeTool(toolName, args, (newOutput) => {
|
|
124
|
+
latestOutput = newOutput;
|
|
125
|
+
});
|
|
126
|
+
// Stop progress updates
|
|
127
|
+
stopProgressUpdates(progressData, true);
|
|
128
|
+
return {
|
|
129
|
+
content: [
|
|
130
|
+
{
|
|
131
|
+
type: "text",
|
|
132
|
+
text: result,
|
|
133
|
+
},
|
|
134
|
+
],
|
|
135
|
+
isError: false,
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
// Stop progress updates on error
|
|
140
|
+
stopProgressUpdates(progressData, false);
|
|
141
|
+
Logger.error(`Error in tool '${toolName}':`, error);
|
|
142
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
143
|
+
return {
|
|
144
|
+
content: [
|
|
145
|
+
{
|
|
146
|
+
type: "text",
|
|
147
|
+
text: `Error executing ${toolName}: ${errorMessage}`,
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
isError: true,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
else {
|
|
155
|
+
throw new Error(`Unknown tool: ${request.params.name}`);
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
// prompts/list
|
|
159
|
+
server.setRequestHandler(ListPromptsRequestSchema, async (request) => {
|
|
160
|
+
return { prompts: getPromptDefinitions() };
|
|
161
|
+
});
|
|
162
|
+
// prompts/get
|
|
163
|
+
server.setRequestHandler(GetPromptRequestSchema, async (request) => {
|
|
164
|
+
const promptName = request.params.name;
|
|
165
|
+
const args = request.params.arguments || {};
|
|
166
|
+
const promptMessage = getPromptMessage(promptName, args);
|
|
167
|
+
if (!promptMessage) {
|
|
168
|
+
throw new Error(`Unknown prompt: ${promptName}`);
|
|
169
|
+
}
|
|
170
|
+
return {
|
|
171
|
+
messages: [{
|
|
172
|
+
role: "user",
|
|
173
|
+
content: {
|
|
174
|
+
type: "text",
|
|
175
|
+
text: promptMessage
|
|
176
|
+
}
|
|
177
|
+
}]
|
|
178
|
+
};
|
|
179
|
+
});
|
|
180
|
+
// Start the server
|
|
181
|
+
async function main() {
|
|
182
|
+
Logger.debug("init gemini-mcp-tool");
|
|
183
|
+
const transport = new StdioServerTransport();
|
|
184
|
+
await server.connect(transport);
|
|
185
|
+
Logger.debug("gemini-mcp-tool listening on stdio");
|
|
186
|
+
}
|
|
187
|
+
main().catch((error) => { Logger.error("Fatal error:", error); process.exit(1); });
|
|
188
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,wBAAwB,EACxB,sBAAsB,GASvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAC3C,OAAO,EAAE,QAAQ,EAAiB,MAAM,gBAAgB,CAAC;AAEzD,OAAO,EACL,kBAAkB,EAClB,oBAAoB,EACpB,WAAW,EACX,UAAU,EACV,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAE1B,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB;IACE,IAAI,EAAE,gBAAgB;IACtB,OAAO,EAAE,OAAO;CACjB,EAAC;IACA,YAAY,EAAE;QACZ,KAAK,EAAE,EAAE;QACT,OAAO,EAAE,EAAE;QACX,aAAa,EAAE,EAAE;QACjB,OAAO,EAAE,EAAE;KACZ;CACF,CACF,CAAC;AAEF,IAAI,YAAY,GAAG,KAAK,CAAC;AAAC,IAAI,oBAAoB,GAAG,EAAE,CAAC;AAAC,IAAI,YAAY,GAAG,EAAE,CAAC;AAE/E,KAAK,UAAU,gBAAgB,CAAC,MAAc,EAAE,MAAW;IACzD,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,YAAY,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAChD,CAAC;IA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AAC;gBACT,IAAI,EAAE,MAAe;gBACrB,OAAO,EAAE;oBACP,IAAI,EAAE,MAAe;oBACrB,IAAI,EAAE,aAAa;iBACpB;aACF,CAAC;KACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,mBAAmB;AACnB,KAAK,UAAU,IAAI;IACjB,MAAM,CAAC,KAAK,CAAC,sBAAsB,CAAC,CAAC;IACrC,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAAC,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAC9E,MAAM,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;AACrD,CAAC;AAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE,GAAE,MAAM,CAAC,KAAK,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ask-gemini.tool.d.ts","sourceRoot":"","sources":["../../src/tools/ask-gemini.tool.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAgB5C,eAAO,MAAM,aAAa,EAAE,WAsC3B,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { executeGeminiCLI, processChangeModeOutput } from '../utils/geminiExecutor.js';
|
|
3
|
+
import { ERROR_MESSAGES, STATUS_MESSAGES } from '../constants.js';
|
|
4
|
+
const askGeminiArgsSchema = z.object({
|
|
5
|
+
prompt: z.string().min(1).describe("Analysis request. Use @ syntax to include files (e.g., '@largefile.js explain what this does') or ask general questions"),
|
|
6
|
+
model: z.string().optional().describe("Optional model to use (e.g., 'gemini-3-flash'). If not specified, uses the default model (gemini-3-pro)."),
|
|
7
|
+
sandbox: z.boolean().default(false).describe("Use sandbox mode (-s flag) to safely test code changes, execute scripts, or run potentially risky operations in an isolated environment"),
|
|
8
|
+
changeMode: z.boolean().default(false).describe("Enable structured change mode - formats prompts to prevent tool errors and returns structured edit suggestions that Claude can apply directly"),
|
|
9
|
+
chunkIndex: z.union([z.number(), z.string()]).optional().describe("Which chunk to return (1-based)"),
|
|
10
|
+
chunkCacheKey: z.string().optional().describe("Optional cache key for continuation"),
|
|
11
|
+
});
|
|
12
|
+
export const askGeminiTool = {
|
|
13
|
+
name: "ask-gemini",
|
|
14
|
+
description: "model selection [-m], sandbox [-s], and changeMode:boolean for providing edits",
|
|
15
|
+
zodSchema: askGeminiArgsSchema,
|
|
16
|
+
prompt: {
|
|
17
|
+
description: "Execute 'gemini <prompt>' to get Gemini AI's response. Supports enhanced change mode for structured edit suggestions.",
|
|
18
|
+
},
|
|
19
|
+
category: 'gemini',
|
|
20
|
+
execute: async (args, onProgress) => {
|
|
21
|
+
const { prompt, model, sandbox, changeMode, chunkIndex, chunkCacheKey } = args;
|
|
22
|
+
if (!prompt?.trim()) {
|
|
23
|
+
throw new Error(ERROR_MESSAGES.NO_PROMPT_PROVIDED);
|
|
24
|
+
}
|
|
25
|
+
if (changeMode && chunkIndex && chunkCacheKey) {
|
|
26
|
+
return processChangeModeOutput('', // empty for cache...
|
|
27
|
+
chunkIndex, chunkCacheKey, prompt);
|
|
28
|
+
}
|
|
29
|
+
const result = await executeGeminiCLI(prompt, model, !!sandbox, !!changeMode, onProgress);
|
|
30
|
+
if (changeMode) {
|
|
31
|
+
return processChangeModeOutput(result, args.chunkIndex, undefined, prompt);
|
|
32
|
+
}
|
|
33
|
+
return `${STATUS_MESSAGES.GEMINI_RESPONSE}\n${result}`; // changeMode false
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
//# sourceMappingURL=ask-gemini.tool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ask-gemini.tool.js","sourceRoot":"","sources":["../../src/tools/ask-gemini.tool.ts"],"names":[],"m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