gemini-bridge 1.0.3__py3-none-any.whl → 1.0.5__py3-none-any.whl
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.
- {gemini_bridge-1.0.3.dist-info → gemini_bridge-1.0.5.dist-info}/METADATA +2 -75
- gemini_bridge-1.0.5.dist-info/RECORD +9 -0
- src/__init__.py +1 -1
- src/mcp_server.py +16 -181
- gemini_bridge-1.0.3.dist-info/RECORD +0 -9
- {gemini_bridge-1.0.3.dist-info → gemini_bridge-1.0.5.dist-info}/WHEEL +0 -0
- {gemini_bridge-1.0.3.dist-info → gemini_bridge-1.0.5.dist-info}/entry_points.txt +0 -0
- {gemini_bridge-1.0.3.dist-info → gemini_bridge-1.0.5.dist-info}/licenses/LICENSE +0 -0
- {gemini_bridge-1.0.3.dist-info → gemini_bridge-1.0.5.dist-info}/top_level.txt +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: gemini-bridge
|
3
|
-
Version: 1.0.
|
3
|
+
Version: 1.0.5
|
4
4
|
Summary: Lightweight MCP server bridging Claude Code to Google's Gemini AI via official CLI
|
5
5
|
Author-email: Shelakh <info@shelakh.com>
|
6
6
|
License-Expression: MIT
|
@@ -537,83 +537,10 @@ gemini --version
|
|
537
537
|
- Ensure Claude Code MCP configuration is correct
|
538
538
|
- Check that the `gemini` command is in your PATH
|
539
539
|
|
540
|
-
### Timeout Issues 🔥
|
541
|
-
|
542
|
-
Gemini Bridge now includes comprehensive timeout debugging. If you're experiencing timeout issues:
|
543
|
-
|
544
|
-
**1. Use the Debug Tool**
|
545
|
-
```python
|
546
|
-
# Get detailed diagnostics about your configuration
|
547
|
-
get_debug_info()
|
548
|
-
```
|
549
|
-
|
550
|
-
This will show:
|
551
|
-
- Current timeout configuration
|
552
|
-
- Gemini CLI status and version
|
553
|
-
- Authentication status
|
554
|
-
- Environment variables
|
555
|
-
- System information
|
556
|
-
|
557
|
-
**2. Configure Appropriate Timeout**
|
558
|
-
|
559
|
-
For different operation types, recommended timeouts:
|
560
|
-
|
561
|
-
- **Default operations**: 60 seconds (default)
|
562
|
-
- **Large file analysis**: 240 seconds
|
563
|
-
- **Complex multi-file operations**: 300+ seconds
|
564
|
-
|
565
|
-
**Configuration Examples:**
|
566
|
-
|
567
|
-
```bash
|
568
|
-
# Claude Code with 4-minute timeout for large operations
|
569
|
-
claude mcp add gemini-bridge -s user --env GEMINI_BRIDGE_TIMEOUT=240 -- uvx gemini-bridge
|
570
|
-
|
571
|
-
# Environment variable (if running manually)
|
572
|
-
export GEMINI_BRIDGE_TIMEOUT=240
|
573
|
-
```
|
574
|
-
|
575
|
-
**3. Common Timeout Scenarios**
|
576
|
-
|
577
|
-
| Scenario | Recommended Timeout | Reason |
|
578
|
-
|----------|-------------------|---------|
|
579
|
-
| Single file < 10KB | 60s (default) | Fast processing |
|
580
|
-
| Multiple files or large files | 240s | More content to process |
|
581
|
-
| Complex code analysis | 300s | Deep reasoning required |
|
582
|
-
| Very large files (>100KB) | 300-600s | Processing overhead |
|
583
|
-
|
584
|
-
**4. Debugging Steps**
|
585
|
-
|
586
|
-
1. **Check your configuration**:
|
587
|
-
```bash
|
588
|
-
# Run the debug tool to see current timeout
|
589
|
-
# Look for "Actual timeout used" in the output
|
590
|
-
```
|
591
|
-
|
592
|
-
2. **Monitor logs**: The server now logs detailed timing information
|
593
|
-
|
594
|
-
3. **Test with smaller queries**: If large queries timeout, break them into smaller parts
|
595
|
-
|
596
|
-
4. **Verify Gemini CLI performance**: Test `gemini` directly with similar queries
|
597
|
-
|
598
|
-
**5. Advanced Troubleshooting**
|
599
|
-
|
600
|
-
If timeouts persist even with high timeout values:
|
601
|
-
|
602
|
-
- **Network issues**: Check your internet connection
|
603
|
-
- **Gemini CLI version**: Update with `npm install -g @google/gemini-cli@latest`
|
604
|
-
- **Authentication**: Re-authenticate with `gemini auth login`
|
605
|
-
- **System resources**: Check if your system is under high load
|
606
|
-
- **File encoding**: Ensure files are UTF-8 encoded
|
607
|
-
- **MCP client timeout**: Some clients have their own timeout settings
|
608
|
-
|
609
540
|
### Common Error Messages
|
610
541
|
- **"CLI not available"**: Gemini CLI is not installed or not in PATH
|
611
542
|
- **"Authentication required"**: Run `gemini auth login`
|
612
|
-
- **"Timeout after
|
613
|
-
- Solution: Increase `GEMINI_BRIDGE_TIMEOUT` environment variable
|
614
|
-
- For immediate testing: Use smaller files or simpler queries
|
615
|
-
- **"Large content size warning"**: Files total >100KB, may need longer timeout
|
616
|
-
- **"Very high timeout configured"**: Timeout >300s, failed operations will wait long
|
543
|
+
- **"Timeout after 60 seconds"**: Query took too long, try breaking it into smaller parts
|
617
544
|
|
618
545
|
## 🤝 Contributing
|
619
546
|
|
@@ -0,0 +1,9 @@
|
|
1
|
+
gemini_bridge-1.0.5.dist-info/licenses/LICENSE,sha256=yTz_R8ocWu64Eubxr6vdZCKRS0dB_Pi3RbjUNn4qPxQ,1063
|
2
|
+
src/__init__.py,sha256=cCvBdB-1IK7X9UQlDvCsRrY7C2DliZ0Gft4uWPi6Ra4,190
|
3
|
+
src/__main__.py,sha256=12FoIYCXYYKu2_BYX1GS_h9E9qO41Q26B8zedRIDPBs,149
|
4
|
+
src/mcp_server.py,sha256=hNjXel5iDt4mB59Rc5PJST8wVwRlrsOFzjOGtuLk8eU,7722
|
5
|
+
gemini_bridge-1.0.5.dist-info/METADATA,sha256=G2m4QUARNzgTjz2wUjSjFcv-X3eSvGTc3bwCDxHgOFk,13798
|
6
|
+
gemini_bridge-1.0.5.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
7
|
+
gemini_bridge-1.0.5.dist-info/entry_points.txt,sha256=ygWf0B23Gygq8mW_GzPx8rxIA19RR_RH4RG2I15lU3E,43
|
8
|
+
gemini_bridge-1.0.5.dist-info/top_level.txt,sha256=74rtVfumQlgAPzR5_2CgYN24MB0XARCg0t-gzk6gTrM,4
|
9
|
+
gemini_bridge-1.0.5.dist-info/RECORD,,
|
src/__init__.py
CHANGED
src/mcp_server.py
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
#!/usr/bin/env python3
|
2
2
|
"""
|
3
3
|
Gemini MCP Server - Simple CLI Bridge
|
4
|
-
Version 1.0.
|
4
|
+
Version 1.0.5
|
5
5
|
A minimal MCP server to interface with Gemini AI via the gemini CLI.
|
6
6
|
Created by @shelakh/elyin
|
7
7
|
"""
|
@@ -10,15 +10,10 @@ import logging
|
|
10
10
|
import os
|
11
11
|
import shutil
|
12
12
|
import subprocess
|
13
|
-
import sys
|
14
13
|
from typing import List, Optional
|
15
14
|
|
16
15
|
from mcp.server.fastmcp import FastMCP
|
17
16
|
|
18
|
-
# Configure logging for debugging timeout issues
|
19
|
-
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
|
20
|
-
logger = logging.getLogger(__name__)
|
21
|
-
|
22
17
|
mcp = FastMCP("gemini-assistant")
|
23
18
|
|
24
19
|
|
@@ -55,37 +50,19 @@ def _get_timeout() -> int:
|
|
55
50
|
Timeout value in seconds (positive integer)
|
56
51
|
"""
|
57
52
|
timeout_str = os.getenv("GEMINI_BRIDGE_TIMEOUT")
|
58
|
-
logger.debug(
|
59
|
-
"Reading timeout from environment: GEMINI_BRIDGE_TIMEOUT=%s", timeout_str
|
60
|
-
)
|
61
|
-
|
62
53
|
if not timeout_str:
|
63
|
-
logger.info("GEMINI_BRIDGE_TIMEOUT not set, using default 60 seconds")
|
64
54
|
return 60
|
65
|
-
|
55
|
+
|
66
56
|
try:
|
67
57
|
timeout = int(timeout_str)
|
58
|
+
if timeout <= 0:
|
59
|
+
logging.warning("Invalid GEMINI_BRIDGE_TIMEOUT value '%s' (must be positive). Using default 60 seconds.", timeout_str)
|
60
|
+
return 60
|
61
|
+
return timeout
|
68
62
|
except ValueError:
|
69
|
-
|
70
|
-
"Invalid GEMINI_BRIDGE_TIMEOUT value '%s' (must be integer). Using default 60 seconds.",
|
71
|
-
timeout_str,
|
72
|
-
)
|
73
|
-
return 60
|
74
|
-
|
75
|
-
if timeout <= 0:
|
76
|
-
logger.warning(
|
77
|
-
"Invalid GEMINI_BRIDGE_TIMEOUT value '%s' (must be positive). Using default 60 seconds.",
|
78
|
-
timeout_str,
|
79
|
-
)
|
63
|
+
logging.warning("Invalid GEMINI_BRIDGE_TIMEOUT value '%s' (must be integer). Using default 60 seconds.", timeout_str)
|
80
64
|
return 60
|
81
65
|
|
82
|
-
logger.info("Using configured timeout: %s seconds", timeout)
|
83
|
-
if timeout > 300:
|
84
|
-
logger.warning(
|
85
|
-
"Large timeout configured (%ss). This may cause long waits for failed operations.",
|
86
|
-
timeout,
|
87
|
-
)
|
88
|
-
return timeout
|
89
66
|
|
90
67
|
def execute_gemini_simple(query: str, directory: str = ".", model: Optional[str] = None) -> str:
|
91
68
|
"""
|
@@ -113,9 +90,6 @@ def execute_gemini_simple(query: str, directory: str = ".", model: Optional[str]
|
|
113
90
|
|
114
91
|
# Execute CLI command - simple timeout, no retries
|
115
92
|
timeout = _get_timeout()
|
116
|
-
logger.info(f"Executing Gemini CLI with timeout: {timeout}s, model: {selected_model}, directory: {directory}")
|
117
|
-
logger.debug(f"Query length: {len(query)} characters")
|
118
|
-
|
119
93
|
try:
|
120
94
|
result = subprocess.run(
|
121
95
|
cmd,
|
@@ -126,25 +100,15 @@ def execute_gemini_simple(query: str, directory: str = ".", model: Optional[str]
|
|
126
100
|
input=query
|
127
101
|
)
|
128
102
|
|
129
|
-
logger.debug(f"Gemini CLI completed with return code: {result.returncode}")
|
130
|
-
|
131
103
|
if result.returncode == 0:
|
132
|
-
|
133
|
-
logger.info(f"Gemini CLI successful, output length: {len(output)} characters")
|
134
|
-
return output
|
104
|
+
return result.stdout.strip() if result.stdout.strip() else "No output from Gemini CLI"
|
135
105
|
else:
|
136
|
-
|
137
|
-
logger.error(error_msg)
|
138
|
-
return error_msg
|
106
|
+
return f"Gemini CLI Error: {result.stderr.strip()}"
|
139
107
|
|
140
108
|
except subprocess.TimeoutExpired:
|
141
|
-
|
142
|
-
logger.error(timeout_msg)
|
143
|
-
return timeout_msg
|
109
|
+
return f"Error: Gemini CLI command timed out after {timeout} seconds"
|
144
110
|
except Exception as e:
|
145
|
-
|
146
|
-
logger.error(error_msg)
|
147
|
-
return error_msg
|
111
|
+
return f"Error executing Gemini CLI: {str(e)}"
|
148
112
|
|
149
113
|
|
150
114
|
def execute_gemini_with_files(query: str, directory: str = ".", files: Optional[List[str]] = None, model: Optional[str] = None) -> str:
|
@@ -198,14 +162,6 @@ def execute_gemini_with_files(query: str, directory: str = ".", files: Optional[
|
|
198
162
|
|
199
163
|
# Execute CLI command - simple timeout, no retries
|
200
164
|
timeout = _get_timeout()
|
201
|
-
total_content_size = len(stdin_content)
|
202
|
-
logger.info(f"Executing Gemini CLI with files, timeout: {timeout}s, model: {selected_model}, directory: {directory}")
|
203
|
-
logger.info(f"File count: {len(files)}, total content size: {total_content_size} characters")
|
204
|
-
|
205
|
-
# Warn about large content that might timeout
|
206
|
-
if total_content_size > 100000: # 100KB threshold
|
207
|
-
logger.warning(f"Large content size ({total_content_size} chars). Consider increasing timeout if you experience timeouts.")
|
208
|
-
|
209
165
|
try:
|
210
166
|
result = subprocess.run(
|
211
167
|
cmd,
|
@@ -216,25 +172,15 @@ def execute_gemini_with_files(query: str, directory: str = ".", files: Optional[
|
|
216
172
|
input=stdin_content
|
217
173
|
)
|
218
174
|
|
219
|
-
logger.debug(f"Gemini CLI completed with return code: {result.returncode}")
|
220
|
-
|
221
175
|
if result.returncode == 0:
|
222
|
-
|
223
|
-
logger.info(f"Gemini CLI successful, output length: {len(output)} characters")
|
224
|
-
return output
|
176
|
+
return result.stdout.strip() if result.stdout.strip() else "No output from Gemini CLI"
|
225
177
|
else:
|
226
|
-
|
227
|
-
logger.error(error_msg)
|
228
|
-
return error_msg
|
178
|
+
return f"Gemini CLI Error: {result.stderr.strip()}"
|
229
179
|
|
230
180
|
except subprocess.TimeoutExpired:
|
231
|
-
|
232
|
-
logger.error(timeout_msg)
|
233
|
-
return timeout_msg
|
181
|
+
return f"Error: Gemini CLI command timed out after {timeout} seconds"
|
234
182
|
except Exception as e:
|
235
|
-
|
236
|
-
logger.error(error_msg)
|
237
|
-
return error_msg
|
183
|
+
return f"Error executing Gemini CLI: {str(e)}"
|
238
184
|
|
239
185
|
|
240
186
|
@mcp.tool()
|
@@ -286,120 +232,9 @@ def consult_gemini_with_files(
|
|
286
232
|
return execute_gemini_with_files(query, directory, files, model)
|
287
233
|
|
288
234
|
|
289
|
-
@mcp.tool()
|
290
|
-
def get_debug_info() -> str:
|
291
|
-
"""
|
292
|
-
Get diagnostic information about the Gemini Bridge configuration.
|
293
|
-
|
294
|
-
Useful for troubleshooting timeout issues and verifying setup.
|
295
|
-
|
296
|
-
Returns:
|
297
|
-
Formatted debug information including timeout configuration,
|
298
|
-
environment variables, and system status
|
299
|
-
"""
|
300
|
-
debug_info = []
|
301
|
-
debug_info.append("=== Gemini Bridge Debug Information ===\n")
|
302
|
-
|
303
|
-
# Timeout configuration
|
304
|
-
timeout_env = os.getenv("GEMINI_BRIDGE_TIMEOUT")
|
305
|
-
actual_timeout = _get_timeout()
|
306
|
-
debug_info.append("Timeout Configuration:")
|
307
|
-
debug_info.append(f" GEMINI_BRIDGE_TIMEOUT env var: {timeout_env or 'not set'}")
|
308
|
-
debug_info.append(f" Actual timeout used: {actual_timeout} seconds")
|
309
|
-
|
310
|
-
if actual_timeout == 60 and not timeout_env:
|
311
|
-
debug_info.append(" ⚠️ Using default timeout. Set GEMINI_BRIDGE_TIMEOUT=240 for large operations.")
|
312
|
-
elif actual_timeout < 120:
|
313
|
-
debug_info.append(" ⚠️ Timeout may be too low for large files or complex queries.")
|
314
|
-
elif actual_timeout > 300:
|
315
|
-
debug_info.append(f" ⚠️ Very high timeout configured. Failed operations will wait {actual_timeout}s.")
|
316
|
-
else:
|
317
|
-
debug_info.append(" ✓ Timeout looks reasonable for most operations.")
|
318
|
-
|
319
|
-
debug_info.append("")
|
320
|
-
|
321
|
-
# Gemini CLI status
|
322
|
-
gemini_path = shutil.which("gemini")
|
323
|
-
debug_info.append("Gemini CLI Status:")
|
324
|
-
debug_info.append(f" CLI available: {'✓ Yes' if gemini_path else '✗ No'}")
|
325
|
-
if gemini_path:
|
326
|
-
debug_info.append(f" CLI path: {gemini_path}")
|
327
|
-
try:
|
328
|
-
# Try to get version
|
329
|
-
result = subprocess.run(
|
330
|
-
["gemini", "--version"],
|
331
|
-
capture_output=True,
|
332
|
-
text=True,
|
333
|
-
timeout=5
|
334
|
-
)
|
335
|
-
if result.returncode == 0:
|
336
|
-
version = result.stdout.strip()
|
337
|
-
debug_info.append(f" CLI version: {version}")
|
338
|
-
else:
|
339
|
-
debug_info.append(f" CLI version check failed: {result.stderr.strip()}")
|
340
|
-
except Exception as e:
|
341
|
-
debug_info.append(f" CLI version check error: {str(e)}")
|
342
|
-
else:
|
343
|
-
debug_info.append(" ✗ Install with: npm install -g @google/gemini-cli")
|
344
|
-
|
345
|
-
debug_info.append("")
|
346
|
-
# Environment details
|
347
|
-
debug_info.append("Environment:")
|
348
|
-
debug_info.append(f" Python version: {sys.version.split()[0]}")
|
349
|
-
debug_info.append(f" Current working directory: {os.getcwd()}")
|
350
|
-
debug_info.append(f" PORT: {os.getenv('PORT', '8080')}")
|
351
|
-
|
352
|
-
# Check authentication status
|
353
|
-
try:
|
354
|
-
result = subprocess.run(
|
355
|
-
["gemini", "auth", "status"],
|
356
|
-
capture_output=True,
|
357
|
-
text=True,
|
358
|
-
timeout=10,
|
359
|
-
cwd="."
|
360
|
-
)
|
361
|
-
if result.returncode == 0:
|
362
|
-
debug_info.append(" Authentication: ✓ Logged in")
|
363
|
-
else:
|
364
|
-
debug_info.append(" Authentication: ✗ Not logged in - run 'gemini auth login'")
|
365
|
-
except Exception as e:
|
366
|
-
debug_info.append(f" Authentication status check failed: {str(e)}")
|
367
|
-
|
368
|
-
debug_info.append("")
|
369
|
-
|
370
|
-
# Recent environment variables that might affect operation
|
371
|
-
relevant_env_vars = [
|
372
|
-
"GEMINI_BRIDGE_TIMEOUT", "NODE_PATH", "PATH", "HOME",
|
373
|
-
"GOOGLE_APPLICATION_CREDENTIALS", "GOOGLE_CLOUD_PROJECT"
|
374
|
-
]
|
375
|
-
|
376
|
-
debug_info.append("Relevant Environment Variables:")
|
377
|
-
for var in relevant_env_vars:
|
378
|
-
value = os.getenv(var)
|
379
|
-
if value:
|
380
|
-
# Truncate very long values
|
381
|
-
display_value = value[:100] + "..." if len(value) > 100 else value
|
382
|
-
debug_info.append(f" {var}: {display_value}")
|
383
|
-
else:
|
384
|
-
debug_info.append(f" {var}: not set")
|
385
|
-
|
386
|
-
debug_info.append("")
|
387
|
-
debug_info.append("=== End Debug Information ===")
|
388
|
-
|
389
|
-
return "\n".join(debug_info)
|
390
|
-
|
391
|
-
|
392
235
|
def main():
|
393
236
|
"""Entry point for the MCP server."""
|
394
|
-
|
395
|
-
timeout = _get_timeout() # Log timeout configuration at startup
|
396
|
-
|
397
|
-
logger.info(f"Starting Gemini Bridge MCP Server on port {port}")
|
398
|
-
logger.info(f"Configured timeout: {timeout} seconds")
|
399
|
-
logger.info(f"Gemini CLI available: {shutil.which('gemini') is not None}")
|
400
|
-
|
401
|
-
# Run the MCP server with SSE transport (port is managed by the library)
|
402
|
-
mcp.run(transport="sse")
|
237
|
+
mcp.run()
|
403
238
|
|
404
239
|
|
405
240
|
if __name__ == "__main__":
|
@@ -1,9 +0,0 @@
|
|
1
|
-
gemini_bridge-1.0.3.dist-info/licenses/LICENSE,sha256=yTz_R8ocWu64Eubxr6vdZCKRS0dB_Pi3RbjUNn4qPxQ,1063
|
2
|
-
src/__init__.py,sha256=w8kaouHPnS_Oe6HQHbGRn6lVKRAYJXG8C4GxqPktK0E,190
|
3
|
-
src/__main__.py,sha256=12FoIYCXYYKu2_BYX1GS_h9E9qO41Q26B8zedRIDPBs,149
|
4
|
-
src/mcp_server.py,sha256=T9GS8pvpCjn6csLdjUbsTPVrqs3Q9LATotIF4_Xkin8,14469
|
5
|
-
gemini_bridge-1.0.3.dist-info/METADATA,sha256=vaefL-Mc6YXwVO9-tQJQ8s4DYhqyN0DIMbz0_DOq6UY,16223
|
6
|
-
gemini_bridge-1.0.3.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
7
|
-
gemini_bridge-1.0.3.dist-info/entry_points.txt,sha256=ygWf0B23Gygq8mW_GzPx8rxIA19RR_RH4RG2I15lU3E,43
|
8
|
-
gemini_bridge-1.0.3.dist-info/top_level.txt,sha256=74rtVfumQlgAPzR5_2CgYN24MB0XARCg0t-gzk6gTrM,4
|
9
|
-
gemini_bridge-1.0.3.dist-info/RECORD,,
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|