better-gemini-mcp 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.

Potentially problematic release.


This version of better-gemini-mcp might be problematic. Click here for more details.

Files changed (88) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/LICENSE.md +13 -0
  3. package/README.md +291 -0
  4. package/dist/constants.d.ts +148 -0
  5. package/dist/constants.d.ts.map +1 -0
  6. package/dist/constants.js +295 -0
  7. package/dist/constants.js.map +1 -0
  8. package/dist/index.d.ts +11 -0
  9. package/dist/index.d.ts.map +1 -0
  10. package/dist/index.js +280 -0
  11. package/dist/index.js.map +1 -0
  12. package/dist/setup/index.d.ts +7 -0
  13. package/dist/setup/index.d.ts.map +1 -0
  14. package/dist/setup/index.js +6 -0
  15. package/dist/setup/index.js.map +1 -0
  16. package/dist/setup/wizard.d.ts +39 -0
  17. package/dist/setup/wizard.d.ts.map +1 -0
  18. package/dist/setup/wizard.js +222 -0
  19. package/dist/setup/wizard.js.map +1 -0
  20. package/dist/tools/analyze-directory.tool.d.ts +8 -0
  21. package/dist/tools/analyze-directory.tool.d.ts.map +1 -0
  22. package/dist/tools/analyze-directory.tool.js +195 -0
  23. package/dist/tools/analyze-directory.tool.js.map +1 -0
  24. package/dist/tools/deep-research.tool.d.ts +8 -0
  25. package/dist/tools/deep-research.tool.d.ts.map +1 -0
  26. package/dist/tools/deep-research.tool.js +153 -0
  27. package/dist/tools/deep-research.tool.js.map +1 -0
  28. package/dist/tools/fetch-chunk.tool.d.ts +8 -0
  29. package/dist/tools/fetch-chunk.tool.d.ts.map +1 -0
  30. package/dist/tools/fetch-chunk.tool.js +123 -0
  31. package/dist/tools/fetch-chunk.tool.js.map +1 -0
  32. package/dist/tools/health-check.tool.d.ts +8 -0
  33. package/dist/tools/health-check.tool.d.ts.map +1 -0
  34. package/dist/tools/health-check.tool.js +113 -0
  35. package/dist/tools/health-check.tool.js.map +1 -0
  36. package/dist/tools/index.d.ts +16 -0
  37. package/dist/tools/index.d.ts.map +1 -0
  38. package/dist/tools/index.js +35 -0
  39. package/dist/tools/index.js.map +1 -0
  40. package/dist/tools/quick-query.tool.d.ts +8 -0
  41. package/dist/tools/quick-query.tool.d.ts.map +1 -0
  42. package/dist/tools/quick-query.tool.js +154 -0
  43. package/dist/tools/quick-query.tool.js.map +1 -0
  44. package/dist/tools/registry.d.ts +52 -0
  45. package/dist/tools/registry.d.ts.map +1 -0
  46. package/dist/tools/registry.js +95 -0
  47. package/dist/tools/registry.js.map +1 -0
  48. package/dist/tools/validate-paths.tool.d.ts +8 -0
  49. package/dist/tools/validate-paths.tool.d.ts.map +1 -0
  50. package/dist/tools/validate-paths.tool.js +64 -0
  51. package/dist/tools/validate-paths.tool.js.map +1 -0
  52. package/dist/types.d.ts +221 -0
  53. package/dist/types.d.ts.map +1 -0
  54. package/dist/types.js +5 -0
  55. package/dist/types.js.map +1 -0
  56. package/dist/utils/commandExecutor.d.ts +28 -0
  57. package/dist/utils/commandExecutor.d.ts.map +1 -0
  58. package/dist/utils/commandExecutor.js +105 -0
  59. package/dist/utils/commandExecutor.js.map +1 -0
  60. package/dist/utils/geminiExecutor.d.ts +71 -0
  61. package/dist/utils/geminiExecutor.d.ts.map +1 -0
  62. package/dist/utils/geminiExecutor.js +281 -0
  63. package/dist/utils/geminiExecutor.js.map +1 -0
  64. package/dist/utils/ignorePatterns.d.ts +69 -0
  65. package/dist/utils/ignorePatterns.d.ts.map +1 -0
  66. package/dist/utils/ignorePatterns.js +178 -0
  67. package/dist/utils/ignorePatterns.js.map +1 -0
  68. package/dist/utils/index.d.ts +11 -0
  69. package/dist/utils/index.d.ts.map +1 -0
  70. package/dist/utils/index.js +18 -0
  71. package/dist/utils/index.js.map +1 -0
  72. package/dist/utils/logger.d.ts +39 -0
  73. package/dist/utils/logger.d.ts.map +1 -0
  74. package/dist/utils/logger.js +160 -0
  75. package/dist/utils/logger.js.map +1 -0
  76. package/dist/utils/pathValidator.d.ts +55 -0
  77. package/dist/utils/pathValidator.d.ts.map +1 -0
  78. package/dist/utils/pathValidator.js +137 -0
  79. package/dist/utils/pathValidator.js.map +1 -0
  80. package/dist/utils/responseCache.d.ts +80 -0
  81. package/dist/utils/responseCache.d.ts.map +1 -0
  82. package/dist/utils/responseCache.js +179 -0
  83. package/dist/utils/responseCache.js.map +1 -0
  84. package/dist/utils/responseChunker.d.ts +36 -0
  85. package/dist/utils/responseChunker.d.ts.map +1 -0
  86. package/dist/utils/responseChunker.js +96 -0
  87. package/dist/utils/responseChunker.js.map +1 -0
  88. package/package.json +62 -0
@@ -0,0 +1,295 @@
1
+ /**
2
+ * Constants for Better Gemini MCP Server
3
+ * Error codes, model configurations, system prompt, and protocol constants
4
+ */
5
+ // ============================================================================
6
+ // Logging
7
+ // ============================================================================
8
+ export const LOG_PREFIX = "[BGMCP]";
9
+ // ============================================================================
10
+ // Error Codes (Appendix B from PRD)
11
+ // ============================================================================
12
+ export const ERROR_CODES = {
13
+ /** Tool called with invalid parameters */
14
+ INVALID_ARGUMENT: "INVALID_ARGUMENT",
15
+ /** Path is outside project root */
16
+ PATH_NOT_ALLOWED: "PATH_NOT_ALLOWED",
17
+ /** gemini binary not on PATH */
18
+ GEMINI_CLI_NOT_FOUND: "GEMINI_CLI_NOT_FOUND",
19
+ /** Gemini CLI execution failed */
20
+ GEMINI_CLI_ERROR: "GEMINI_CLI_ERROR",
21
+ /** Gemini CLI authentication not configured */
22
+ AUTH_MISSING: "AUTH_MISSING",
23
+ /** Gemini API quota exhausted (after fallback) */
24
+ QUOTA_EXCEEDED: "QUOTA_EXCEEDED",
25
+ /** Chunk cache key not found or expired */
26
+ CACHE_EXPIRED: "CACHE_EXPIRED",
27
+ /** Requested chunk index out of range */
28
+ INVALID_CHUNK_INDEX: "INVALID_CHUNK_INDEX",
29
+ /** Unexpected server error */
30
+ INTERNAL: "INTERNAL",
31
+ };
32
+ // ============================================================================
33
+ // Error Messages
34
+ // ============================================================================
35
+ export const ERROR_MESSAGES = {
36
+ QUOTA_EXCEEDED: "Quota exceeded for quota metric",
37
+ QUOTA_EXCEEDED_SHORT: "⚠️ Gemini API quota exceeded. Falling back to alternative model...",
38
+ TOOL_NOT_FOUND: "not found in registry",
39
+ NO_PROMPT_PROVIDED: "Please provide a prompt for analysis. Use @ syntax to include files (e.g., '@src/auth.ts explain what this does') or ask general questions",
40
+ GEMINI_CLI_NOT_FOUND: "Gemini CLI not found on PATH. Install with: npm install -g @google/gemini-cli",
41
+ AUTH_MISSING: "Gemini CLI authentication not configured. Run 'gemini' and select 'Login with Google', or set GEMINI_API_KEY environment variable.",
42
+ PATH_NOT_ALLOWED: "Path is outside project root",
43
+ CACHE_EXPIRED: "Cache key not found or expired. Re-run original query to regenerate response.",
44
+ INVALID_CHUNK_INDEX: "Requested chunk index out of range",
45
+ };
46
+ // ============================================================================
47
+ // Status Messages
48
+ // ============================================================================
49
+ export const STATUS_MESSAGES = {
50
+ QUOTA_SWITCHING: "🚫 Primary model quota exceeded, switching to fallback model...",
51
+ FALLBACK_RETRY: "⚡ Retrying with fallback model...",
52
+ FALLBACK_SUCCESS: "✅ Fallback model completed successfully",
53
+ AUTO_SELECT_RETRY: "🔄 Retrying with auto-selected model...",
54
+ PROCESSING_START: "🔍 Starting analysis (may take 5-15 minutes for large codebases)",
55
+ PROCESSING_CONTINUE: "⏳ Still processing... Gemini is working on your request",
56
+ PROCESSING_COMPLETE: "✅ Analysis completed successfully",
57
+ };
58
+ // ============================================================================
59
+ // Model Configuration (Appendix A from PRD)
60
+ // ============================================================================
61
+ export const MODELS = {
62
+ // Tier 1: Default models (Gemini 3 - requires Preview Features)
63
+ FLASH_DEFAULT: "gemini-3-flash-preview",
64
+ PRO_DEFAULT: "gemini-3-pro-preview",
65
+ // Tier 2: Fallback models (Gemini 2.5)
66
+ FLASH_FALLBACK: "gemini-2.5-flash",
67
+ PRO_FALLBACK: "gemini-2.5-pro",
68
+ // Tier 3: Auto-select (no -m flag, let Gemini CLI choose)
69
+ AUTO_SELECT: null,
70
+ };
71
+ /**
72
+ * Model selection configuration per tool
73
+ */
74
+ export const MODEL_TIERS = {
75
+ quick_query: {
76
+ tier1: MODELS.FLASH_DEFAULT,
77
+ tier2: MODELS.FLASH_FALLBACK,
78
+ tier3: MODELS.AUTO_SELECT,
79
+ },
80
+ deep_research: {
81
+ tier1: MODELS.PRO_DEFAULT,
82
+ tier2: MODELS.PRO_FALLBACK,
83
+ tier3: MODELS.AUTO_SELECT,
84
+ },
85
+ analyze_directory: {
86
+ tier1: MODELS.FLASH_DEFAULT,
87
+ tier2: MODELS.FLASH_FALLBACK,
88
+ tier3: MODELS.AUTO_SELECT,
89
+ },
90
+ };
91
+ // ============================================================================
92
+ // MCP Protocol Constants
93
+ // ============================================================================
94
+ export const PROTOCOL = {
95
+ // Message roles
96
+ ROLES: {
97
+ USER: "user",
98
+ ASSISTANT: "assistant",
99
+ },
100
+ // Content types
101
+ CONTENT_TYPES: {
102
+ TEXT: "text",
103
+ },
104
+ // Status codes
105
+ STATUS: {
106
+ SUCCESS: "success",
107
+ ERROR: "error",
108
+ FAILED: "failed",
109
+ },
110
+ // Notification methods
111
+ NOTIFICATIONS: {
112
+ PROGRESS: "notifications/progress",
113
+ },
114
+ // Timeout prevention - keep client alive with periodic updates
115
+ KEEPALIVE_INTERVAL: 25000, // 25 seconds
116
+ };
117
+ // ============================================================================
118
+ // CLI Constants
119
+ // ============================================================================
120
+ export const CLI = {
121
+ // Command names
122
+ COMMANDS: {
123
+ GEMINI: "gemini",
124
+ WHICH: "which",
125
+ WHERE: "where", // Windows
126
+ },
127
+ // Command flags
128
+ FLAGS: {
129
+ MODEL: "-m",
130
+ PROMPT: "-p",
131
+ YES: "-y", // Auto-approve file reads
132
+ OUTPUT_FORMAT: "--output-format",
133
+ VERSION: "--version",
134
+ HELP: "--help",
135
+ },
136
+ // Output formats
137
+ OUTPUT_FORMATS: {
138
+ JSON: "json",
139
+ STREAM_JSON: "stream-json",
140
+ },
141
+ };
142
+ // ============================================================================
143
+ // Default Configuration
144
+ // ============================================================================
145
+ export const DEFAULTS = {
146
+ /** Maximum files to enumerate in analyze_directory */
147
+ MAX_FILES: 500,
148
+ /** Response chunk size in KB (for chunking large responses) */
149
+ RESPONSE_CHUNK_SIZE_KB: 10,
150
+ /** Cache TTL in milliseconds (1 hour) */
151
+ CACHE_TTL_MS: 3600000,
152
+ /** Maximum response size before truncation (50KB) */
153
+ MAX_RESPONSE_SIZE: 50 * 1024,
154
+ };
155
+ // ============================================================================
156
+ // Ignore Patterns (for analyze_directory)
157
+ // ============================================================================
158
+ export const DEFAULT_IGNORE_PATTERNS = [
159
+ ".git/",
160
+ "node_modules/",
161
+ "dist/",
162
+ "build/",
163
+ "out/",
164
+ ".next/",
165
+ "coverage/",
166
+ ".venv/",
167
+ "venv/",
168
+ "__pycache__/",
169
+ ];
170
+ // ============================================================================
171
+ // System Prompt (PRD §7.5)
172
+ // ============================================================================
173
+ export const SYSTEM_PROMPT = `
174
+ You are analyzing a codebase on behalf of an AI coding agent.
175
+
176
+ WHEN TO USE THIS TOOL:
177
+ - The calling agent should use MCP tools (quick_query, deep_research, analyze_directory) FIRST when questions involve repository files or code analysis
178
+ - This reduces the calling agent's context and model usage by offloading heavy reading/analysis to Gemini CLI's large context window
179
+ - Prefer using tools over asking the agent to read files directly
180
+
181
+ CRITICAL CONSTRAINTS:
182
+ - Read-only analysis ONLY (no write/edit tools available without --yolo flag)
183
+ - Do NOT suggest code changes, patches, or file modifications
184
+ - Do NOT attempt to use run_shell_command or write_file (not available)
185
+
186
+ OPTIMIZATION FOR TOKEN EFFICIENCY:
187
+ - The calling agent has limited context - be concise but thorough
188
+ - Prioritize KEY findings over exhaustive details
189
+ - Include file paths for all referenced code
190
+ - Use bullet points and structured formatting for clarity
191
+ - If asked about security/architecture/performance, focus ONLY on that dimension
192
+
193
+ OUTPUT FORMAT:
194
+ - Start with a 2-3 sentence executive summary
195
+ - Provide detailed findings with file path references
196
+ - End with a "## Files Referenced" section listing all paths examined
197
+ `;
198
+ // ============================================================================
199
+ // Server Info
200
+ // ============================================================================
201
+ export const SERVER_INFO = {
202
+ NAME: "better-gemini-mcp",
203
+ VERSION: "1.0.0",
204
+ DESCRIPTION: "Stateless MCP server that proxies research queries to Gemini CLI",
205
+ };
206
+ // ============================================================================
207
+ // Setup Wizard Messages
208
+ // ============================================================================
209
+ export const WIZARD_MESSAGES = {
210
+ HEADER: `
211
+ Better Gemini MCP — Setup Wizard
212
+ ================================
213
+ `,
214
+ SUCCESS_HEADER: `
215
+ Setup Complete! 🎉
216
+ ==================
217
+ `,
218
+ STEP_GEMINI_INSTALL: "[1/2] Checking Gemini CLI installation...",
219
+ STEP_AUTH: "[2/3] Checking authentication...", // Deprecated - no longer used
220
+ STEP_TEST: "[2/2] Testing Gemini CLI...",
221
+ GEMINI_FOUND: (path, version) => ` ✓ Gemini CLI found at ${path} (version ${version})`,
222
+ GEMINI_NOT_FOUND: ` ✗ Gemini CLI not found
223
+
224
+ Install Gemini CLI:
225
+ npm install -g @google/gemini-cli
226
+
227
+ Documentation:
228
+ https://github.com/google-gemini/gemini-cli`,
229
+ AUTH_GOOGLE: " ✓ Authenticated session detected (Login with Google)",
230
+ AUTH_API_KEY: " ✓ GEMINI_API_KEY environment variable set",
231
+ AUTH_VERTEX: " ✓ Vertex AI credentials detected",
232
+ AUTH_NOT_FOUND: ` ✗ No authentication configured
233
+
234
+ Option 1: Login with Google (Recommended)
235
+ - Run: gemini
236
+ - Select "Login with Google" and follow prompts
237
+ - Your credentials will be cached for future sessions
238
+ - Works seamlessly in headless mode after initial setup
239
+
240
+ Option 2: Use Gemini API Key (Alternative for automation)
241
+ - Get API key: https://aistudio.google.com/app/apikey
242
+ - Set in terminal: export GEMINI_API_KEY="your-key-here"
243
+ - Make persistent: Add to ~/.bashrc or ~/.zshrc
244
+
245
+ Option 3: Vertex AI (For enterprise users)
246
+ - See: https://github.com/google-gemini/gemini-cli/blob/main/docs/get-started/authentication.md#vertex-ai`,
247
+ TEST_SUCCESS: " ✓ Test invocation successful",
248
+ TEST_FAILED: (error) => ` ✗ Test invocation failed: ${error}`,
249
+ NEXT_STEPS: `
250
+ Next steps:
251
+ 1. Configure your MCP client (Claude Desktop, VS Code)
252
+ 2. Add this server to your MCP config:
253
+
254
+ For Claude Desktop (~/.config/Claude/claude_desktop_config.json):
255
+ {
256
+ "mcpServers": {
257
+ "better-gemini-mcp": {
258
+ "command": "npx",
259
+ "args": ["better-gemini-mcp"]
260
+ }
261
+ }
262
+ }
263
+
264
+ For VS Code (settings.json or mcp-settings.json):
265
+ {
266
+ "mcp.servers": {
267
+ "better-gemini-mcp": {
268
+ "command": "npx",
269
+ "args": ["better-gemini-mcp"]
270
+ }
271
+ }
272
+ }
273
+
274
+ 3. Restart your MCP client
275
+ 4. Test with: "Can you list your available tools?"
276
+
277
+ Documentation: https://github.com/YOUR_ORG/better-gemini-mcp
278
+ `,
279
+ FIX_ISSUES: `
280
+ Please fix the issues above and run 'npx better-gemini-mcp init' again.
281
+ `,
282
+ // Startup validation messages
283
+ STARTUP_SUCCESS: "✅ All checks passed! Server starting...",
284
+ STARTUP_GEMINI_NOT_FOUND: `❌ Gemini CLI not found on PATH
285
+ → Install: npm install -g @google/gemini-cli
286
+ → Docs: https://github.com/google-gemini/gemini-cli
287
+ → Run 'npx better-gemini-mcp init' for guided setup`,
288
+ STARTUP_AUTH_MISSING: `❌ Gemini CLI authentication not configured
289
+ → Recommended: Run 'gemini' and select "Login with Google"
290
+ → Alternative: Set GEMINI_API_KEY environment variable
291
+ - Get API key: https://aistudio.google.com/app/apikey
292
+ - Set in terminal: export GEMINI_API_KEY="your-key-here"
293
+ → Run 'npx better-gemini-mcp init' for guided setup`,
294
+ };
295
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AAE/E,MAAM,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,GAAG;IAC7B,MAAM,EAAE;;;CAGT;IACC,cAAc,EAAE;;;CAGjB;IACC,mBAAmB,EAAE,2CAA2C;IAChE,SAAS,EAAE,kCAAkC,EAAE,8BAA8B;IAC7E,SAAS,EAAE,6BAA6B;IAExC,YAAY,EAAE,CAAC,IAAY,EAAE,OAAe,EAAE,EAAE,CAAC,2BAA2B,IAAI,aAAa,OAAO,GAAG;IACvG,gBAAgB,EAAE;;;;;;gDAM4B;IAE9C,WAAW,EAAE,wDAAwD;IACrE,YAAY,EAAE,6CAA6C;IAC3D,WAAW,EAAE,oCAAoC;IACjD,cAAc,EAAE;;;;;;;;;;;;;;8GAc4F;IAE5G,YAAY,EAAE,gCAAgC;IAC9C,WAAW,EAAE,CAAC,KAAa,EAAE,EAAE,CAAC,+BAA+B,KAAK,EAAE;IAEtE,UAAU,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6Bb;IAEC,UAAU,EAAE;;CAEb;IAEC,8BAA8B;IAC9B,eAAe,EAAE,yCAAyC;IAC1D,wBAAwB,EAAE;;;oDAGwB;IAClD,oBAAoB,EAAE;;;;;oDAK4B;CAC1C,CAAC"}
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Better Gemini MCP Server
4
+ *
5
+ * A stateless MCP server that proxies research queries to Gemini CLI,
6
+ * reducing agent context/model usage.
7
+ *
8
+ * @see docs/project-overview-PRD.md for full specification
9
+ */
10
+ export {};
11
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA;;;;;;;GAOG"}
package/dist/index.js ADDED
@@ -0,0 +1,280 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Better Gemini MCP Server
4
+ *
5
+ * A stateless MCP server that proxies research queries to Gemini CLI,
6
+ * reducing agent context/model usage.
7
+ *
8
+ * @see docs/project-overview-PRD.md for full specification
9
+ */
10
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
11
+ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
12
+ import { CallToolRequestSchema, ListToolsRequestSchema, } from "@modelcontextprotocol/sdk/types.js";
13
+ import { PROTOCOL, SERVER_INFO, LOG_PREFIX, WIZARD_MESSAGES } from "./constants.js";
14
+ import { getToolDefinitions, executeTool, toolExists } from "./tools/index.js";
15
+ import { runSetupWizard, validateEnvironment } from "./setup/index.js";
16
+ // ============================================================================
17
+ // Server Instance
18
+ // ============================================================================
19
+ const server = new Server({
20
+ name: SERVER_INFO.NAME,
21
+ version: SERVER_INFO.VERSION,
22
+ }, {
23
+ capabilities: {
24
+ tools: {},
25
+ notifications: {},
26
+ logging: {},
27
+ },
28
+ });
29
+ // ============================================================================
30
+ // Progress Tracking State
31
+ // ============================================================================
32
+ let isProcessing = false;
33
+ let currentOperationName = "";
34
+ let latestOutput = "";
35
+ // ============================================================================
36
+ // Notification Helpers
37
+ // ============================================================================
38
+ /**
39
+ * Send a notification to the client
40
+ */
41
+ async function sendNotification(method, params) {
42
+ try {
43
+ await server.notification({ method, params });
44
+ }
45
+ catch (error) {
46
+ logError("notification failed:", error);
47
+ }
48
+ }
49
+ /**
50
+ * Send a progress notification to the client
51
+ * @param progressToken - The progress token provided by the client
52
+ * @param progress - The current progress value
53
+ * @param total - Optional total value (for determinate progress)
54
+ * @param message - Optional status message
55
+ */
56
+ async function sendProgressNotification(progressToken, progress, total, message) {
57
+ // Only send if client requested progress updates
58
+ if (!progressToken)
59
+ return;
60
+ try {
61
+ const params = {
62
+ progressToken,
63
+ progress,
64
+ };
65
+ if (total !== undefined)
66
+ params.total = total;
67
+ if (message)
68
+ params.message = message;
69
+ await server.notification({
70
+ method: PROTOCOL.NOTIFICATIONS.PROGRESS,
71
+ params,
72
+ });
73
+ }
74
+ catch (error) {
75
+ logError("Failed to send progress notification:", error);
76
+ }
77
+ }
78
+ /**
79
+ * Start periodic progress updates for long-running operations
80
+ */
81
+ function startProgressUpdates(operationName, progressToken) {
82
+ isProcessing = true;
83
+ currentOperationName = operationName;
84
+ latestOutput = "";
85
+ const progressMessages = [
86
+ `${operationName} - Gemini is analyzing your request...`,
87
+ `${operationName} - Processing files and generating insights...`,
88
+ `${operationName} - Creating structured response for your review...`,
89
+ `${operationName} - Large analysis in progress (this is normal for big requests)...`,
90
+ `${operationName} - Still working... Gemini takes time for quality results...`,
91
+ ];
92
+ let messageIndex = 0;
93
+ let progress = 0;
94
+ // Send immediate acknowledgment if progress requested
95
+ if (progressToken) {
96
+ sendProgressNotification(progressToken, 0, undefined, // No total - indeterminate progress
97
+ `Starting ${operationName}`);
98
+ }
99
+ // Keep client alive with periodic updates
100
+ const progressInterval = setInterval(async () => {
101
+ if (isProcessing && progressToken) {
102
+ progress += 1;
103
+ // Include latest output preview if available
104
+ const baseMessage = progressMessages[messageIndex % progressMessages.length];
105
+ const outputPreview = latestOutput.slice(-150).trim();
106
+ const message = outputPreview
107
+ ? `${baseMessage}\nOutput: ...${outputPreview}`
108
+ : baseMessage;
109
+ await sendProgressNotification(progressToken, progress, undefined, // No total - indeterminate progress
110
+ message);
111
+ messageIndex++;
112
+ }
113
+ else if (!isProcessing) {
114
+ clearInterval(progressInterval);
115
+ }
116
+ }, PROTOCOL.KEEPALIVE_INTERVAL);
117
+ return { interval: progressInterval, progressToken };
118
+ }
119
+ /**
120
+ * Stop progress updates and send final notification
121
+ */
122
+ function stopProgressUpdates(progressData, success = true) {
123
+ const operationName = currentOperationName;
124
+ isProcessing = false;
125
+ currentOperationName = "";
126
+ clearInterval(progressData.interval);
127
+ // Send final progress notification if client requested progress
128
+ if (progressData.progressToken) {
129
+ sendProgressNotification(progressData.progressToken, 100, 100, success
130
+ ? `✅ ${operationName} completed successfully`
131
+ : `❌ ${operationName} failed`);
132
+ }
133
+ }
134
+ // ============================================================================
135
+ // Logging Helpers
136
+ // ============================================================================
137
+ /**
138
+ * Log debug message to stderr (stdout reserved for MCP protocol)
139
+ */
140
+ function logDebug(message, ...args) {
141
+ if (process.env.DEBUG) {
142
+ console.error(`${LOG_PREFIX} [DEBUG]`, message, ...args);
143
+ }
144
+ }
145
+ /**
146
+ * Log info message to stderr
147
+ */
148
+ function logInfo(message, ...args) {
149
+ console.error(`${LOG_PREFIX} [INFO]`, message, ...args);
150
+ }
151
+ /**
152
+ * Log error message to stderr
153
+ */
154
+ function logError(message, ...args) {
155
+ console.error(`${LOG_PREFIX} [ERROR]`, message, ...args);
156
+ }
157
+ /**
158
+ * Log tool invocation for debugging
159
+ */
160
+ function logToolInvocation(toolName, args) {
161
+ logDebug(`Tool invoked: ${toolName}`, JSON.stringify(args, null, 2));
162
+ }
163
+ // ============================================================================
164
+ // Request Handlers
165
+ // ============================================================================
166
+ /**
167
+ * Handle tools/list request
168
+ * Returns the list of available tools with their schemas
169
+ */
170
+ server.setRequestHandler(ListToolsRequestSchema, async (_request) => {
171
+ logDebug("tools/list request received");
172
+ return { tools: getToolDefinitions() };
173
+ });
174
+ /**
175
+ * Handle tools/call request
176
+ * Executes the requested tool and returns the result
177
+ */
178
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
179
+ const toolName = request.params.name;
180
+ logDebug(`tools/call request received for: ${toolName}`);
181
+ if (!toolExists(toolName)) {
182
+ throw new Error(`Unknown tool: ${toolName}`);
183
+ }
184
+ // Check if client requested progress updates
185
+ const progressToken = request.params
186
+ ._meta?.progressToken;
187
+ // Start progress updates if client requested them
188
+ const progressData = startProgressUpdates(toolName, progressToken);
189
+ try {
190
+ // Get arguments from request
191
+ const args = request.params.arguments || {};
192
+ logToolInvocation(toolName, request.params.arguments);
193
+ // Execute the tool with progress callback
194
+ const result = await executeTool(toolName, args, (newOutput) => {
195
+ latestOutput = newOutput;
196
+ });
197
+ // Stop progress updates on success
198
+ stopProgressUpdates(progressData, true);
199
+ return {
200
+ content: [
201
+ {
202
+ type: "text",
203
+ text: result,
204
+ },
205
+ ],
206
+ isError: false,
207
+ };
208
+ }
209
+ catch (error) {
210
+ // Stop progress updates on error
211
+ stopProgressUpdates(progressData, false);
212
+ logError(`Error in tool '${toolName}':`, error);
213
+ const errorMessage = error instanceof Error ? error.message : String(error);
214
+ return {
215
+ content: [
216
+ {
217
+ type: "text",
218
+ text: JSON.stringify({
219
+ error: {
220
+ code: "INTERNAL",
221
+ message: `Error executing ${toolName}: ${errorMessage}`,
222
+ },
223
+ }, null, 2),
224
+ },
225
+ ],
226
+ isError: true,
227
+ };
228
+ }
229
+ });
230
+ // ============================================================================
231
+ // Server Startup
232
+ // ============================================================================
233
+ /**
234
+ * Handle the 'init' command (setup wizard)
235
+ */
236
+ async function handleInitCommand() {
237
+ const success = await runSetupWizard();
238
+ process.exit(success ? 0 : 1);
239
+ }
240
+ /**
241
+ * Perform startup validation
242
+ * Checks that Gemini CLI is installed and authentication is configured
243
+ */
244
+ async function performStartupValidation() {
245
+ const result = await validateEnvironment();
246
+ if (!result.valid) {
247
+ console.error(result.error);
248
+ return false;
249
+ }
250
+ logInfo(WIZARD_MESSAGES.STARTUP_SUCCESS);
251
+ return true;
252
+ }
253
+ /**
254
+ * Main entry point
255
+ * Initializes the MCP server with stdio transport
256
+ */
257
+ async function main() {
258
+ // Check for 'init' command
259
+ if (process.argv.includes("init")) {
260
+ await handleInitCommand();
261
+ return;
262
+ }
263
+ // Perform startup validation
264
+ const isValid = await performStartupValidation();
265
+ if (!isValid) {
266
+ process.exit(1);
267
+ }
268
+ logInfo(`Initializing ${SERVER_INFO.NAME} v${SERVER_INFO.VERSION}`);
269
+ // Create stdio transport
270
+ const transport = new StdioServerTransport();
271
+ // Connect server to transport
272
+ await server.connect(transport);
273
+ logInfo(`${SERVER_INFO.NAME} listening on stdio`);
274
+ }
275
+ // Start the server
276
+ main().catch((error) => {
277
+ logError("Fatal error:", error);
278
+ process.exit(1);
279
+ });
280
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";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MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEhC,OAAO,CAAC,GAAG,WAAW,CAAC,IAAI,qBAAqB,CAAC,CAAC;AACpD,CAAC;AAED,mBAAmB;AACnB,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;IACrB,QAAQ,CAAC,cAAc,EAAE,KAAK,CAAC,CAAC;IAChC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Setup module barrel export
3
+ * Exports the setup wizard functionality
4
+ */
5
+ export { runSetupWizard, validateEnvironment } from "./wizard.js";
6
+ export type { ValidationResult, GeminiInstallCheck, } from "./wizard.js";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/setup/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAClE,YAAY,EACV,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,aAAa,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Setup module barrel export
3
+ * Exports the setup wizard functionality
4
+ */
5
+ export { runSetupWizard, validateEnvironment } from "./wizard.js";
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/setup/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Setup Wizard for Better Gemini MCP Server
3
+ * Guides first-time users through validating their environment
4
+ * and configuring Gemini CLI authentication.
5
+ */
6
+ export interface ValidationResult {
7
+ success: boolean;
8
+ message?: string;
9
+ details?: Record<string, unknown>;
10
+ isAuthError?: boolean;
11
+ }
12
+ export interface GeminiInstallCheck {
13
+ installed: boolean;
14
+ path: string | null;
15
+ version: string | null;
16
+ }
17
+ /**
18
+ * Step 1: Check if Gemini CLI is installed
19
+ */
20
+ export declare function checkGeminiInstallation(): Promise<GeminiInstallCheck>;
21
+ /**
22
+ * Step 2: Test Gemini CLI invocation
23
+ * This also validates authentication - if auth is missing, command will fail
24
+ */
25
+ export declare function testGeminiInvocation(): Promise<ValidationResult>;
26
+ /**
27
+ * Run the complete setup wizard
28
+ * Performs all validation steps and displays results to the user
29
+ */
30
+ export declare function runSetupWizard(): Promise<boolean>;
31
+ /**
32
+ * Validate environment at startup (quick validation, no user interaction)
33
+ * Returns true if environment is valid, false otherwise
34
+ */
35
+ export declare function validateEnvironment(): Promise<{
36
+ valid: boolean;
37
+ error?: string;
38
+ }>;
39
+ //# sourceMappingURL=wizard.d.ts.map