@houtini/gemini-mcp 1.3.2 → 1.4.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 (40) hide show
  1. package/README.md +784 -941
  2. package/dist/cli.js +5 -10
  3. package/dist/cli.js.map +1 -1
  4. package/dist/config/index.d.ts +1 -1
  5. package/dist/config/index.d.ts.map +1 -1
  6. package/dist/config/index.js +5 -42
  7. package/dist/config/index.js.map +1 -1
  8. package/dist/config/types.js +1 -2
  9. package/dist/index.d.ts +1 -3
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +182 -90
  12. package/dist/index.js.map +1 -1
  13. package/dist/services/base-service.js +3 -10
  14. package/dist/services/base-service.js.map +1 -1
  15. package/dist/services/gemini/index.d.ts +3 -3
  16. package/dist/services/gemini/index.d.ts.map +1 -1
  17. package/dist/services/gemini/index.js +20 -24
  18. package/dist/services/gemini/index.js.map +1 -1
  19. package/dist/services/gemini/types.js +1 -2
  20. package/dist/tools/gemini-chat.d.ts +1 -1
  21. package/dist/tools/gemini-chat.d.ts.map +1 -1
  22. package/dist/tools/gemini-chat.js +10 -17
  23. package/dist/tools/gemini-chat.js.map +1 -1
  24. package/dist/tools/gemini-deep-research.d.ts +1 -1
  25. package/dist/tools/gemini-deep-research.d.ts.map +1 -1
  26. package/dist/tools/gemini-deep-research.js +24 -31
  27. package/dist/tools/gemini-deep-research.js.map +1 -1
  28. package/dist/tools/gemini-list-models.d.ts +1 -1
  29. package/dist/tools/gemini-list-models.d.ts.map +1 -1
  30. package/dist/tools/gemini-list-models.js +7 -14
  31. package/dist/tools/gemini-list-models.js.map +1 -1
  32. package/dist/utils/error-handler.js +7 -18
  33. package/dist/utils/error-handler.js.map +1 -1
  34. package/dist/utils/logger.js +4 -39
  35. package/dist/utils/logger.js.map +1 -1
  36. package/package.json +7 -5
  37. package/dist/tools/gemini-describe-video.d.ts +0 -38
  38. package/dist/tools/gemini-describe-video.d.ts.map +0 -1
  39. package/dist/tools/gemini-describe-video.js +0 -196
  40. package/dist/tools/gemini-describe-video.js.map +0 -1
package/README.md CHANGED
@@ -1,941 +1,784 @@
1
- # Gemini MCP Server
2
-
3
- [![Smithery MCP Server](https://smithery.ai/badge/@houtini/gemini-mcp)](https://smithery.ai/server/@houtini/gemini-mcp)
4
- [![npm version](https://img.shields.io/npm/v/@houtini/gemini-mcp.svg?style=flat-square)](https://www.npmjs.com/package/@houtini/gemini-mcp)
5
- [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=flat-square)](https://opensource.org/licenses/Apache-2.0)
6
- [![TypeScript](https://img.shields.io/badge/TypeScript-5.3-blue?style=flat-square&logo=typescript)](https://www.typescriptlang.org/)
7
- [![MCP](https://img.shields.io/badge/MCP-Compatible-green?style=flat-square)](https://modelcontextprotocol.io)
8
-
9
- A professional, production-ready Model Context Protocol (MCP) server that provides seamless integration with Google's Gemini AI models. Built with TypeScript and designed for enterprise use, this package offers robust error handling, comprehensive logging, and easy deployment.
10
-
11
- ## Quick Start
12
-
13
- The easiest way to get started is using `npx` - no installation required:
14
-
15
- ```bash
16
- # Get your API key from Google AI Studio
17
- # https://makersuite.google.com/app/apikey
18
-
19
- # Test the server (optional)
20
- npx @houtini/gemini-mcp
21
-
22
- # Add to Claude Desktop (see configuration below)
23
- ```
24
-
25
- ## Table of Contents
26
-
27
- - [Features](#features)
28
- - [Installation](#installation)
29
- - [Configuration](#configuration)
30
- - [Dynamic Model Discovery](#dynamic-model-discovery)
31
- - [Experimental Models](#experimental-models)
32
- - [Usage Examples](#usage-examples)
33
- - [Prompting Guide](PROMPTING_GUIDE.md)
34
- - [Google Search Grounding](#google-search-grounding)
35
- - [Deep Research](#deep-research)
36
- - [API Reference](#api-reference)
37
- - [Development](#development)
38
- - [Troubleshooting](#troubleshooting)
39
- - [Contributing](#contributing)
40
-
41
- ## Features
42
-
43
- ### Core Functionality
44
- - **Dynamic Model Discovery** - Automatically discovers and uses the latest Gemini models (transparent, zero configuration)
45
- - **Chat Interface** - Advanced chat functionality with customisable parameters
46
- - **Google Search Grounding** - Real-time web search integration enabled by default for current information
47
- - **Deep Research** - Iterative multi-step research with comprehensive synthesis
48
- - **Model Information** - Detailed model capabilities with accurate context window sizes directly from Google
49
- - **Fine-Grained Control** - Temperature, token limits, and system prompts
50
-
51
- ### Enterprise Features
52
- - **Professional Architecture** - Modular services-based design
53
- - **Robust Error Handling** - Comprehensive error handling with detailed logging
54
- - **Winston Logging** - Production-ready logging with file rotation
55
- - **Security Focused** - No hardcoded credentials, environment-based configuration
56
- - **Full TypeScript** - Complete type safety and IntelliSense support
57
- - **High Performance** - Optimised for minimal latency and resource usage
58
- - **Graceful Fallback** - Automatic fallback to proven models if discovery fails
59
-
60
- ## Installation
61
-
62
- ### Prerequisites
63
-
64
- - **Node.js** v24.0.0 or higher
65
- - **Google AI Studio API Key** ([Get your key here](https://makersuite.google.com/app/apikey))
66
-
67
- ### Recommended: No Installation Required
68
-
69
- The simplest approach uses `npx` to run the latest version automatically:
70
-
71
- ```bash
72
- # No installation needed - npx handles everything
73
- npx @houtini/gemini-mcp
74
- ```
75
-
76
- ### Alternative Installation Methods
77
-
78
- #### Global Installation
79
- ```bash
80
- # Install once, use anywhere
81
- npm install -g @houtini/gemini-mcp
82
- gemini-mcp
83
- ```
84
-
85
- #### Local Project Installation
86
- ```bash
87
- # Install in your project
88
- npm install @houtini/gemini-mcp
89
-
90
- # Run with npx
91
- npx @houtini/gemini-mcp
92
- ```
93
-
94
- #### From Source (Developers)
95
- ```bash
96
- git clone https://github.com/houtini-ai/gemini-mcp.git
97
- cd gemini-mcp
98
- npm install
99
- npm run build
100
- npm start
101
- ```
102
-
103
- ## Configuration
104
-
105
- ### Step 1: Get Your API Key
106
-
107
- Visit [Google AI Studio](https://makersuite.google.com/app/apikey) to create your free API key.
108
-
109
- ### Step 2: Configure Claude Desktop
110
-
111
- Add this configuration to your Claude Desktop config file:
112
-
113
- **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
114
- **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
115
-
116
- #### Recommended Configuration (using npx)
117
-
118
- ```json
119
- {
120
- "mcpServers": {
121
- "gemini": {
122
- "command": "npx",
123
- "args": ["@houtini/gemini-mcp"],
124
- "env": {
125
- "GEMINI_API_KEY": "your-api-key-here"
126
- }
127
- }
128
- }
129
- }
130
- ```
131
-
132
- **Benefits of this approach:**
133
- - No global installation required
134
- - Always uses the latest version
135
- - Cleaner system (no global packages)
136
- - Works out of the box
137
-
138
- #### Alternative: Global Installation
139
-
140
- ```json
141
- {
142
- "mcpServers": {
143
- "gemini": {
144
- "command": "gemini-mcp",
145
- "env": {
146
- "GEMINI_API_KEY": "your-api-key-here"
147
- }
148
- }
149
- }
150
- }
151
- ```
152
-
153
- *Note: Requires `npm install -g @houtini/gemini-mcp` first*
154
-
155
- #### Alternative: Local Installation
156
-
157
- ```json
158
- {
159
- "mcpServers": {
160
- "gemini": {
161
- "command": "node",
162
- "args": ["./node_modules/@houtini/gemini-mcp/dist/index.js"],
163
- "env": {
164
- "GEMINI_API_KEY": "your-api-key-here"
165
- }
166
- }
167
- }
168
- }
169
- ```
170
-
171
- *Note: Only works if installed locally in the current directory*
172
-
173
- ### Step 3: Restart Claude Desktop
174
-
175
- After updating the configuration file, restart Claude Desktop to load the new MCP server.
176
-
177
- ### Optional Configuration
178
-
179
- You can add additional environment variables for more control:
180
-
181
- ```json
182
- {
183
- "mcpServers": {
184
- "gemini": {
185
- "command": "npx",
186
- "args": ["@houtini/gemini-mcp"],
187
- "env": {
188
- "GEMINI_API_KEY": "your-api-key-here",
189
- "LOG_LEVEL": "info"
190
- }
191
- }
192
- }
193
- }
194
- ```
195
-
196
- **Available Environment Variables:**
197
-
198
- | Variable | Default | Description |
199
- |----------|---------|-------------|
200
- | `GEMINI_API_KEY` | *required* | Your Google AI Studio API key |
201
- | `LOG_LEVEL` | `info` | Logging level: `debug`, `info`, `warn`, `error` |
202
- | `GEMINI_ALLOW_EXPERIMENTAL` | `false` | Allow experimental/preview models as defaults (set to `true` to enable) |
203
-
204
- ## Dynamic Model Discovery
205
-
206
- This server features **intelligent, transparent model discovery** that automatically keeps you up to date with the latest Gemini models—without any configuration needed.
207
-
208
- ### How It Works
209
-
210
- The server uses **lazy initialisation** to discover models on your first request:
211
-
212
- 1. **Server Starts** - Instant startup with proven fallback models
213
- 2. **First Request** - Automatically queries Google's API for latest models
214
- 3. **Discovery Completes** - Updates to use the newest available models
215
- 4. **Subsequent Requests** - Use the discovered models (no delay)
216
- 5. **Graceful Fallback** - If API discovery fails, continues with reliable fallback models
217
-
218
- ### Key Benefits
219
-
220
- - **Zero Configuration** - Works automatically, no setup required
221
- - **Always Current** - New models available as soon as Google releases them
222
- - **Transparent** - You don't need to know it exists
223
- - **Instant Startup** - No delay in server initialisation
224
- - **Smart Selection** - Automatically chooses the best default model
225
- - **Fail-Safe** - Gracefully handles API failures
226
-
227
- ### What Models Are Discovered?
228
-
229
- The system discovers all available Gemini models including:
230
- - Latest stable releases
231
- - Context window sizes - Accurate limits directly from Google
232
- - Model capabilities - What each model supports
233
- - Specialised models - Vision, audio, and other variants
234
-
235
- By default, the server **filters to stable production models only**, ensuring reliable performance and avoiding quota limits on experimental models.
236
-
237
- ### Default Model Selection
238
-
239
- The server intelligently selects the default model using these priorities:
240
-
241
- 1. **Stable models only** (filters out experimental/preview by default)
242
- 2. **Newest version** (2.5 > 2.0 > 1.5)
243
- 3. **Flash preference** (faster models prioritised)
244
- 4. **Capability matching** (must support text generation)
245
-
246
- **Current expected default**: Latest stable Flash model (typically `gemini-2.5-flash`)
247
-
248
- ### Performance Impact
249
-
250
- - **Startup Time**: 0ms - Server starts instantly
251
- - **First Request**: +1-2 seconds (one-time model discovery)
252
- - **Subsequent Requests**: 0ms overhead
253
- - **Discovery Failure**: 0ms - Uses fallback models immediately
254
-
255
- ### For Advanced Users
256
-
257
- If you want to see which models were discovered, check the server logs after your first request:
258
-
259
- ```
260
- Models discovered from API (count: 38, defaultModel: gemini-2.5-flash)
261
- ```
262
-
263
- ## Experimental Models
264
-
265
- By default, the server uses **stable production models** to ensure reliable performance and avoid rate limiting issues. However, you can optionally enable experimental and preview models if you want access to cutting-edge features.
266
-
267
- ### Stable vs Experimental Models
268
-
269
- **Stable Models** (default):
270
- - Production-ready and reliable
271
- - Better rate limits and quotas
272
- - Consistent performance
273
- - Fully tested and supported
274
- - Examples: `gemini-2.5-flash`, `gemini-2.5-pro`, `gemini-2.0-flash`
275
-
276
- **Experimental Models** (opt-in):
277
- - Latest features and capabilities
278
- - Stricter rate limits
279
- - May have unexpected behaviour
280
- - Can be deprecated quickly
281
- - Examples: `gemini-exp-1206`, `gemini-2.0-flash-thinking-exp`, preview releases
282
-
283
- ### Enabling Experimental Models
284
-
285
- To include experimental and preview models in discovery and selection:
286
-
287
- **In Claude Desktop Config:**
288
- ```json
289
- {
290
- "mcpServers": {
291
- "gemini": {
292
- "command": "npx",
293
- "args": ["@houtini/gemini-mcp"],
294
- "env": {
295
- "GEMINI_API_KEY": "your-api-key-here",
296
- "GEMINI_ALLOW_EXPERIMENTAL": "true"
297
- }
298
- }
299
- }
300
- }
301
- ```
302
-
303
- **Using .env file:**
304
- ```env
305
- GEMINI_API_KEY=your-api-key-here
306
- GEMINI_ALLOW_EXPERIMENTAL=true
307
- ```
308
-
309
- ### What Changes When Enabled?
310
-
311
- With `GEMINI_ALLOW_EXPERIMENTAL=true`:
312
- - Experimental models become available for selection
313
- - Experimental models can be chosen as the default
314
- - Preview and thinking models are included in model lists
315
- - You gain access to latest features before stable release
316
-
317
- **Note**: You can always explicitly specify any model (experimental or stable) in your requests, regardless of this setting. This flag only affects which models are used as defaults.
318
-
319
- ### Recommended Use Cases
320
-
321
- **Keep Experimental Disabled (default) if:**
322
- - You need reliable, consistent performance
323
- - You're building production applications
324
- - You want to avoid rate limit issues
325
- - You prefer tested, stable features
326
-
327
- **Enable Experimental if:**
328
- - You want to test cutting-edge features
329
- - You're doing research or experimentation
330
- - You understand the trade-offs
331
- - You can handle potential rate limits
332
-
333
- ### Using .env File (Development)
334
-
335
- For development or testing, create a `.env` file:
336
-
337
- ```env
338
- # Google Gemini Configuration
339
- GEMINI_API_KEY=your-api-key-here
340
-
341
- # Optional: Enable experimental models
342
- GEMINI_ALLOW_EXPERIMENTAL=false
343
-
344
- # Logging Configuration (optional)
345
- LOG_LEVEL=info
346
- ```
347
-
348
- ## Usage Examples
349
-
350
- ### Basic Chat
351
-
352
- Ask Claude to use Gemini:
353
-
354
- ```
355
- Can you help me understand quantum computing using Gemini?
356
- ```
357
-
358
- Claude will automatically use the `gemini_chat` tool to get a response from Gemini.
359
-
360
- ### Creative Writing
361
-
362
- ```
363
- Use Gemini to write a short story about artificial intelligence discovering creativity.
364
- ```
365
-
366
- ### Technical Analysis
367
-
368
- ```
369
- Can you use Gemini Pro to explain the differences between various machine learning algorithms?
370
- ```
371
-
372
- ### Model Selection
373
-
374
- ```
375
- Use Gemini 1.5 Pro to analyse this code and suggest improvements.
376
- ```
377
-
378
- ### Getting Model Information
379
-
380
- ```
381
- Show me all available Gemini models and their capabilities.
382
- ```
383
-
384
- ---
385
-
386
- ## Complete Prompting Guide
387
-
388
- Want to get the most out of Gemini MCP? Check out our **[Comprehensive Prompting Guide](PROMPTING_GUIDE.md)** for:
389
-
390
- - Advanced prompting techniques
391
- - Model selection strategies
392
- - Parameter tuning (temperature, tokens, system prompts)
393
- - Leveraging Google Search grounding
394
- - Creative workflows and use cases
395
- - Best practices and tips
396
- - Troubleshooting common issues
397
-
398
- **[Read the Prompting Guide](PROMPTING_GUIDE.md)**
399
-
400
- ---
401
-
402
- ## Google Search Grounding
403
-
404
- This server includes **Google Search grounding** functionality powered by Google's real-time web search, providing Gemini models with access to current web information. This feature is **enabled by default** and significantly enhances response accuracy for questions requiring up-to-date information.
405
-
406
- ### Key Benefits
407
-
408
- - **Real-time Information** - Access to current news, events, stock prices, weather, and developments
409
- - **Factual Accuracy** - Reduces AI hallucinations by grounding responses in verified web sources
410
- - **Source Citations** - Automatic citation of sources with search queries used
411
- - **Seamless Integration** - Works transparently without changing your existing workflow
412
- - **Smart Search** - AI automatically determines when to search based on query content
413
-
414
- ### How Google Search Grounding Works
415
-
416
- When you ask a question that benefits from current information, the system:
417
-
418
- 1. **Analyses your query** to determine if web search would improve the answer
419
- 2. **Generates relevant search queries** automatically based on your question
420
- 3. **Performs Google searches** using multiple targeted queries
421
- 4. **Processes search results** and synthesises information from multiple sources
422
- 5. **Provides enhanced response** with inline citations and source links
423
- 6. **Shows search metadata** including the actual queries used for transparency
424
-
425
- ### Perfect For These Use Cases
426
-
427
- **Current Events & News**
428
- ```
429
- What are the latest developments in AI announced this month?
430
- What's happening with the 2025 climate negotiations?
431
- Recent breakthroughs in quantum computing research?
432
- ```
433
-
434
- **Real-time Data**
435
- ```
436
- Current stock prices for major tech companies
437
- Today's weather forecast for London
438
- Latest cryptocurrency market trends
439
- ```
440
-
441
- **Recent Developments**
442
- ```
443
- New software releases and updates this week
444
- Recent scientific discoveries in medicine
445
- Latest policy changes in renewable energy
446
- ```
447
-
448
- **Fact Checking & Verification**
449
- ```
450
- Verify recent statements about climate change
451
- Check the latest statistics on global internet usage
452
- Confirm recent merger and acquisition announcements
453
- ```
454
-
455
- ### Controlling Grounding Behaviour
456
-
457
- **Default Behaviour**: Grounding is **enabled by default** for optimal results and accuracy.
458
-
459
- **Disable for Creative Tasks**: When you want purely creative or hypothetical responses:
460
- ```
461
- Use Gemini without web search to write a fictional story about dragons in space.
462
- Write a creative poem about imaginary colours that don't exist.
463
- ```
464
-
465
- **Technical Control**: When using the API directly, use the `grounding` parameter:
466
-
467
- ```json
468
- {
469
- "message": "Write a creative story about time travel",
470
- "model": "gemini-2.5-flash",
471
- "grounding": false
472
- }
473
- ```
474
-
475
- ```json
476
- {
477
- "message": "What are the latest developments in renewable energy?",
478
- "model": "gemini-2.5-flash",
479
- "grounding": true
480
- }
481
- ```
482
-
483
- ### Understanding Grounded Responses
484
-
485
- When grounding is active, responses include:
486
-
487
- **Source Citations**: Links to the websites used for information
488
- ```
489
- Sources: (https://example.com/article1) (https://example.com/article2)
490
- ```
491
-
492
- **Search Transparency**: The actual search queries used
493
- ```
494
- Search queries used: latest AI developments 2025, OpenAI GPT-5 release, Google Gemini updates
495
- ```
496
-
497
- **Enhanced Accuracy**: Information synthesis from multiple authoritative sources rather than relying solely on training data
498
-
499
- ## Deep Research
500
-
501
- The server includes a powerful **deep research** capability that performs iterative multi-step research on complex topics, synthesising comprehensive reports with proper source citations.
502
-
503
- ### How Deep Research Works
504
-
505
- Deep research conducts multiple research iterations, each building on previous findings:
506
-
507
- 1. **Initial Research** - Broad exploration of the topic
508
- 2. **Gap Analysis** - Identifies what hasn't been covered
509
- 3. **Targeted Research** - Digs deeper into specific areas
510
- 4. **Synthesis** - Creates comprehensive report with citations
511
- 5. **Iteration** - Repeats until thorough coverage achieved
512
-
513
- ### Using Deep Research
514
-
515
- ```
516
- Use Gemini deep research to investigate the impact of quantum computing on cybersecurity.
517
- ```
518
-
519
- You can specify research parameters:
520
- ```
521
- Use Gemini deep research with 7 iterations to create a comprehensive report on renewable energy trends, focusing on solar and wind power adoption rates.
522
- ```
523
-
524
- ### Research Parameters
525
-
526
- - **max_iterations**: Number of research cycles (3-10, default 5)
527
- - **focus_areas**: Specific aspects to emphasise
528
- - **model**: Which Gemini model to use (defaults to latest stable)
529
-
530
- ### Best For
531
-
532
- - Academic research and literature reviews
533
- - Market analysis and competitive intelligence
534
- - Technology trend analysis
535
- - Policy research and impact assessments
536
- - Multi-faceted business problems
537
-
538
- ### Configuring max_iterations for Different Environments
539
-
540
- The `max_iterations` parameter controls how many research cycles are performed. Different AI environments have varying timeout tolerances, so it's important to configure appropriately:
541
-
542
- **Claude Desktop (Recommended: 3-5 iterations)**
543
- - **Timeout**: Approximately 4 minutes
544
- - **Recommended Setting**: Use 3-4 iterations for most research tasks
545
- - **Maximum Safe**: 5 iterations
546
- - **Why**: Claude Desktop has a stricter timeout to ensure responsive UI
547
-
548
- Example:
549
- ```
550
- Use Gemini deep research with 3 iterations to analyse competitive landscape in renewable energy storage.
551
- ```
552
-
553
- **Agent SDK / IDEs (VSCode, Cursor, Windsurf) (Recommended: 7-10 iterations)**
554
- - **Timeout**: Much longer (typically 10+ minutes)
555
- - **Recommended Setting**: Use 7-10 iterations for comprehensive research
556
- - **Maximum**: 10 iterations
557
- - **Why**: These environments have more generous timeouts and can handle longer-running processes
558
-
559
- Example:
560
- ```
561
- Use Gemini deep research with 8 iterations to create a comprehensive market analysis of AI chips in datacenter applications.
562
- ```
563
-
564
- **AI Platforms (Cline, Roo-Cline) (Recommended: 7-10 iterations)**
565
- - **Timeout**: Similar to Agent SDK environments
566
- - **Recommended Setting**: Use 7-10 iterations
567
- - **Maximum**: 10 iterations
568
-
569
- **If You Hit Context/Thread Limits**
570
-
571
- If you encounter timeout errors or thread limits:
572
-
573
- 1. **Reduce iterations**: Start with 3 iterations and gradually increase
574
- 2. **Narrow focus**: Use the `focus_areas` parameter to be more specific
575
- 3. **Split research**: Break complex topics into multiple smaller research tasks
576
- 4. **Check environment**: Verify which environment you're using and adjust accordingly
577
-
578
- Example with focused research:
579
- ```
580
- Use Gemini deep research with 3 iterations focusing on cost analysis and market adoption to examine solar panel technology trends.
581
- ```
582
-
583
- **Note**: The server automatically manages context efficiently, so Claude Desktop users are unlikely to hit thread limits with recommended iteration counts. However, if you do encounter issues, simply reduce `max_iterations` to 3 or 4.
584
-
585
- **Note**: Deep research takes several minutes as it performs multiple iterations. Perfect for when you need comprehensive, well-researched analysis rather than quick answers.
586
-
587
- ## API Reference
588
-
589
- ### Available Tools
590
-
591
- #### `gemini_chat`
592
-
593
- Chat with Gemini models to generate text responses.
594
-
595
- **Parameters:**
596
-
597
- | Parameter | Type | Required | Default | Description |
598
- |-----------|------|----------|---------|-------------|
599
- | `message` | string | Yes | - | The message to send to Gemini |
600
- | `model` | string | No | *Latest stable* | Model to use (dynamically selected) |
601
- | `temperature` | number | No | 0.7 | Controls randomness (0.0-1.0) |
602
- | `max_tokens` | integer | No | 4096 | Maximum tokens in response (1-16384) |
603
- | `system_prompt` | string | No | - | System instruction to guide the model |
604
- | `grounding` | boolean | No | true | Enable Google Search grounding for real-time information |
605
-
606
- **Example:**
607
- ```json
608
- {
609
- "message": "What are the latest developments in quantum computing?",
610
- "model": "gemini-1.5-pro",
611
- "temperature": 0.5,
612
- "max_tokens": 1000,
613
- "system_prompt": "You are a helpful technology expert. Provide current, factual information with sources where possible.",
614
- "grounding": true
615
- }
616
- ```
617
-
618
- #### `gemini_list_models`
619
-
620
- Retrieve information about all discovered Gemini models.
621
-
622
- **Parameters:** None required
623
-
624
- **Example:**
625
- ```json
626
- {}
627
- ```
628
-
629
- **Response includes:**
630
- - Model names and display names
631
- - Descriptions of each model's strengths
632
- - Context window sizes (directly from Google)
633
- - Recommended use cases
634
-
635
- #### `gemini_deep_research`
636
-
637
- Conduct iterative multi-step research on complex topics.
638
-
639
- **Parameters:**
640
-
641
- | Parameter | Type | Required | Default | Description |
642
- |-----------|------|----------|---------|-------------|
643
- | `research_question` | string | Yes | - | The topic or question to research |
644
- | `max_iterations` | integer | No | 5 | Number of research cycles (3-10) |
645
- | `focus_areas` | array | No | - | Specific aspects to emphasise |
646
- | `model` | string | No | *Latest stable* | Model to use for research |
647
-
648
- **Example:**
649
- ```json
650
- {
651
- "research_question": "Impact of AI on healthcare diagnostics",
652
- "max_iterations": 7,
653
- "focus_areas": ["accuracy improvements", "cost implications", "regulatory challenges"]
654
- }
655
- ```
656
-
657
- ### Available Models
658
-
659
- Models are **dynamically discovered** from Google's API. The exact list may vary, but typically includes:
660
-
661
- | Model Pattern | Best For | Description |
662
- |---------------|----------|-------------|
663
- | **gemini-2.5-flash** | General use, latest features | Latest Gemini 2.5 Flash - Fast, versatile performance |
664
- | **gemini-2.5-pro** | Complex reasoning | Latest Gemini 2.5 Pro - Advanced reasoning capabilities |
665
- | **gemini-2.0-flash** | Speed-optimised tasks | Gemini 2.0 Flash - Fast, efficient model |
666
- | **gemini-1.5-flash** | Quick responses | Gemini 1.5 Flash - Fast, efficient model |
667
- | **gemini-1.5-pro** | Large context | Gemini 1.5 Pro - 2M token context window |
668
-
669
- **Note**: Use `gemini_list_models` to see the exact models available with current context window sizes.
670
-
671
- ## Development
672
-
673
- ### Building from Source
674
-
675
- ```bash
676
- # Clone the repository
677
- git clone https://github.com/houtini-ai/gemini-mcp.git
678
- cd gemini-mcp
679
-
680
- # Install dependencies
681
- npm install
682
-
683
- # Build the project
684
- npm run build
685
-
686
- # Run in development mode
687
- npm run dev
688
- ```
689
-
690
- ### Scripts
691
-
692
- | Command | Description |
693
- |---------|-------------|
694
- | `npm run build` | Compile TypeScript to JavaScript |
695
- | `npm run dev` | Run in development mode with live reload |
696
- | `npm start` | Run the compiled server |
697
- | `npm test` | Run test suite |
698
- | `npm run lint` | Check code style |
699
- | `npm run lint:fix` | Fix linting issues automatically |
700
-
701
- ### Project Structure
702
-
703
- ```
704
- src/
705
- ├── config/ # Configuration management
706
- │ ├── index.ts # Main configuration
707
- │ └── types.ts # Configuration types
708
- ├── services/ # Core business logic
709
- │ ├── base-service.ts
710
- │ └── gemini/ # Gemini service implementation
711
- │ ├── index.ts
712
- │ └── types.ts
713
- ├── tools/ # MCP tool implementations
714
- │ ├── gemini-chat.ts
715
- │ ├── gemini-list-models.ts
716
- │ └── gemini-deep-research.ts
717
- ├── utils/ # Utility functions
718
- │ ├── logger.ts # Winston logging setup
719
- │ └── error-handler.ts
720
- ├── cli.ts # CLI entry point
721
- └── index.ts # Main server implementation
722
- ```
723
-
724
- ### Architecture
725
-
726
- The server follows a clean, layered architecture:
727
-
728
- 1. **CLI Layer** (`cli.ts`) - Command-line interface
729
- 2. **Server Layer** (`index.ts`) - MCP protocol handling
730
- 3. **Tools Layer** (`tools/`) - MCP tool implementations
731
- 4. **Service Layer** (`services/`) - Business logic and API integration
732
- 5. **Utility Layer** (`utils/`) - Cross-cutting concerns
733
-
734
- ## Troubleshooting
735
-
736
- ### Common Issues
737
-
738
- #### "GEMINI_API_KEY environment variable not set"
739
-
740
- **Solution:**
741
- ```bash
742
- # Make sure your API key is set in the Claude Desktop configuration
743
- # See the Configuration section above
744
- ```
745
-
746
- #### Server not appearing in Claude Desktop
747
-
748
- **Solutions:**
749
- 1. **Restart Claude Desktop** after updating configuration
750
- 2. **Check your configuration file path**:
751
- - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
752
- - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
753
- 3. **Verify JSON syntax** - use a JSON validator if needed
754
- 4. **Ensure your API key is valid** - test at [Google AI Studio](https://makersuite.google.com/app/apikey)
755
-
756
- #### "Module not found" errors with npx
757
-
758
- **Solutions:**
759
- ```bash
760
- # Clear npx cache and try again
761
- npx --yes @houtini/gemini-mcp
762
-
763
- # Or install globally if preferred
764
- npm install -g @houtini/gemini-mcp
765
- ```
766
-
767
- #### Node.js version issues
768
-
769
- **Solution:**
770
- ```bash
771
- # Check your Node.js version
772
- node --version
773
-
774
- # Should be v24.0.0 or higher
775
- # Install latest Node.js from https://nodejs.org
776
- ```
777
-
778
- ### Debug Mode
779
-
780
- Enable detailed logging by setting `LOG_LEVEL=debug` in your Claude Desktop configuration:
781
-
782
- ```json
783
- {
784
- "mcpServers": {
785
- "gemini": {
786
- "command": "npx",
787
- "args": ["@houtini/gemini-mcp"],
788
- "env": {
789
- "GEMINI_API_KEY": "your-api-key-here",
790
- "LOG_LEVEL": "debug"
791
- }
792
- }
793
- }
794
- }
795
- ```
796
-
797
- ### Log Files
798
-
799
- Logs are written to:
800
- - **Console output** (visible in Claude Desktop developer tools)
801
- - **`logs/combined.log`** - All log levels
802
- - **`logs/error.log`** - Error logs only
803
-
804
- ### Testing Your Setup
805
-
806
- Test the server with these Claude queries:
807
-
808
- 1. **Basic connectivity**: "Can you list the available Gemini models?"
809
- 2. **Simple chat**: "Use Gemini to explain photosynthesis."
810
- 3. **Advanced features**: "Use Gemini 1.5 Pro with temperature 0.9 to write a creative poem about coding."
811
-
812
- ### Performance Tuning
813
-
814
- For better performance:
815
-
816
- 1. **Adjust token limits** based on your use case
817
- 2. **Use appropriate models** (Flash for speed, Pro for complex tasks)
818
- 3. **Monitor logs** for rate limiting or API issues
819
- 4. **Set reasonable temperature values** (0.7 for balanced, 0.3 for focused, 0.9 for creative)
820
-
821
- ## Contributing
822
-
823
- Contributions are welcome! Please follow these steps:
824
-
825
- 1. **Fork the repository**
826
- 2. **Create a feature branch**: `git checkout -b feature/amazing-feature`
827
- 3. **Make your changes** and add tests if applicable
828
- 4. **Ensure all tests pass**: `npm test`
829
- 5. **Lint your code**: `npm run lint:fix`
830
- 6. **Build the project**: `npm run build`
831
- 7. **Commit your changes**: `git commit -m 'Add amazing feature'`
832
- 8. **Push to the branch**: `git push origin feature/amazing-feature`
833
- 9. **Open a Pull Request**
834
-
835
- ### Development Guidelines
836
-
837
- - Follow TypeScript best practices
838
- - Add tests for new functionality
839
- - Update documentation as needed
840
- - Use conventional commit messages
841
- - Ensure backwards compatibility
842
-
843
- ## License
844
-
845
- This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
846
-
847
- ## Disclaimer and Important Information
848
-
849
- **Use at Your Own Risk**: This software is provided "as is" without warranty of any kind, express or implied. The authors and contributors accept no responsibility for any damages, data loss, security breaches, or other issues arising from the use of this software.
850
-
851
- **Content Safety**: This MCP server interfaces with Google's Gemini AI models. Whilst the server implements content safety settings, the quality and appropriateness of AI-generated content cannot be guaranteed. Users are responsible for:
852
- - Reviewing AI-generated content before use
853
- - Ensuring compliance with applicable laws and regulations
854
- - Implementing additional safety measures as needed for their use case
855
-
856
- **API Key Security**: Your Google Gemini API key is sensitive credential information. Users are responsible for:
857
- - Keeping API keys confidential and secure
858
- - Not committing API keys to version control
859
- - Rotating keys if exposure is suspected
860
- - Managing API usage and associated costs
861
-
862
- **Data Privacy**: This server processes data sent through the Model Context Protocol. Users should:
863
- - Avoid sending sensitive, personal, or confidential information
864
- - Review Google's privacy policy and terms of service
865
- - Understand that data may be processed by Google's services
866
- - Implement appropriate data handling policies
867
-
868
- **Production Use**: Whilst designed with professional standards, users deploying this in production environments should:
869
- - Conduct their own security audits
870
- - Implement appropriate monitoring and logging
871
- - Have incident response procedures
872
- - Regularly update dependencies
873
-
874
- **Third-Party Services**: This software relies on external services (Google Gemini API, npm packages). Service availability, pricing, and functionality may change without notice.
875
-
876
- **No Professional Advice**: Content generated by AI models should not be considered professional advice (legal, medical, financial, etc.) without proper verification by qualified professionals.
877
-
878
- By using this software, you acknowledge that you have read this disclaimer and agree to use the software at your own risk.
879
-
880
- ## Support
881
-
882
- - **GitHub Issues**: [Report bugs or request features](https://github.com/houtini-ai/gemini-mcp/issues)
883
- - **GitHub Discussions**: [Ask questions or share ideas](https://github.com/houtini-ai/gemini-mcp/discussions)
884
-
885
- ## Changelog
886
-
887
- ### v1.0.4
888
-
889
- **Security and Dependency Updates**
890
- - Updated @google/generative-ai to v0.24.1 (from v0.21.0)
891
- - Updated @modelcontextprotocol/sdk to v1.19.1 (from v1.18.1)
892
- - Updated winston, typescript, and other development dependencies
893
- - Changed default safety settings from BLOCK_NONE to BLOCK_MEDIUM_AND_ABOVE for better content safety
894
- - Added comprehensive disclaimer section covering usage risks, API security, and data privacy
895
- - All dependencies audited with zero vulnerabilities
896
-
897
- ### v1.1.0
898
-
899
- **Deep Research & Enhanced Model Discovery**
900
- - Added deep research capability for iterative multi-step analysis
901
- - Enhanced model discovery with better filtering
902
- - Improved default model selection logic
903
- - Better handling of experimental vs stable models
904
- - Documentation updates to reflect dynamic discovery
905
-
906
- ### v1.0.3
907
-
908
- **Enhanced Google Search Grounding**
909
- - Fixed grounding metadata field name issues for improved reliability
910
- - Enhanced source citation processing and display
911
- - Verified compatibility with latest Google Generative AI SDK (v0.21.0)
912
- - Comprehensive grounding documentation and usage examples
913
- - Resolved field naming inconsistencies in grounding response handling
914
- - Improved grounding metadata debugging and error handling
915
-
916
- ### v1.0.2
917
-
918
- **Google Search Grounding Introduction**
919
- - Added Google Search grounding functionality enabled by default
920
- - Real-time web search integration for current information and facts
921
- - Grounding metadata in responses with source citations
922
- - Configurable grounding parameter in chat requests
923
- - Enhanced accuracy for current events, news, and factual queries
924
-
925
- ### v1.0.0
926
-
927
- **Initial Release**
928
- - Complete Node.js/TypeScript rewrite from Python
929
- - Professional modular architecture with services pattern
930
- - Comprehensive error handling and logging system
931
- - Full MCP protocol compliance
932
- - Support for multiple Gemini models
933
- - NPM package distribution ready
934
- - Enterprise-grade configuration management
935
- - Production-ready build system
936
-
937
- ---
938
-
939
- **Built with care for the Model Context Protocol community**
940
-
941
- For more information about MCP, visit [modelcontextprotocol.io](https://modelcontextprotocol.io)
1
+ # Gemini MCP Server
2
+
3
+ [![Smithery MCP Server](https://smithery.ai/badge/@houtini/gemini-mcp)](https://smithery.ai/server/@houtini/gemini-mcp)
4
+ [![npm version](https://img.shields.io/npm/v/@houtini/gemini-mcp.svg?style=flat-square)](https://www.npmjs.com/package/@houtini/gemini-mcp)
5
+ [![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg?style=flat-square)](https://opensource.org/licenses/Apache-2.0)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.3-blue?style=flat-square&logo=typescript)](https://www.typescriptlang.org/)
7
+ [![MCP](https://img.shields.io/badge/MCP-Compatible-green?style=flat-square)](https://modelcontextprotocol.io)
8
+
9
+ A production-ready Model Context Protocol server for Google's Gemini AI models. I've built this with TypeScript and the latest MCP SDK (1.25.3), focusing on real-world reliability rather than feature bloat.
10
+
11
+ ## What This Does
12
+
13
+ This server connects Claude Desktop (or any MCP client) to Google's Gemini models. The integration is straightforward: chat with Gemini, get model information, and run deep research tasks with Google Search grounding built in.
14
+
15
+ What I think matters here: the server discovers available models automatically from Google's API, which means you're always working with the latest releases without updating configuration files. No hardcoded model lists that go stale.
16
+
17
+ ## Quick Start
18
+
19
+ The simplest way to use this is with `npx` - no installation required:
20
+
21
+ ```bash
22
+ # Get your API key from Google AI Studio first
23
+ # https://makersuite.google.com/app/apikey
24
+
25
+ # Test it works (optional)
26
+ npx @houtini/gemini-mcp
27
+
28
+ # Add to Claude Desktop (configuration below)
29
+ ```
30
+
31
+ ## Installation Options
32
+
33
+ ### Recommended: npx (No Installation)
34
+
35
+ ```bash
36
+ npx @houtini/gemini-mcp
37
+ ```
38
+
39
+ This approach pulls the latest version automatically. I prefer this because you don't clutter your system with global packages, and updates happen transparently.
40
+
41
+ ### Alternative: Global Installation
42
+
43
+ ```bash
44
+ npm install -g @houtini/gemini-mcp
45
+ gemini-mcp
46
+ ```
47
+
48
+ ### Alternative: Local Project
49
+
50
+ ```bash
51
+ npm install @houtini/gemini-mcp
52
+ npx @houtini/gemini-mcp
53
+ ```
54
+
55
+ ### From Source (Developers)
56
+
57
+ ```bash
58
+ git clone https://github.com/houtini-ai/gemini-mcp.git
59
+ cd gemini-mcp
60
+ npm install
61
+ npm run build
62
+ npm start
63
+ ```
64
+
65
+ ## Configuration
66
+
67
+ ### Step 1: Get Your API Key
68
+
69
+ Visit [Google AI Studio](https://makersuite.google.com/app/apikey) to create a free API key. This takes about 30 seconds.
70
+
71
+ ### Step 2: Configure Claude Desktop
72
+
73
+ Add this to your Claude Desktop config file:
74
+
75
+ **Windows**: `%APPDATA%\Claude\claude_desktop_config.json`
76
+ **macOS**: `~/Library/Application Support/Claude/claude_desktop_config.json`
77
+
78
+ #### Using npx (Recommended)
79
+
80
+ ```json
81
+ {
82
+ "mcpServers": {
83
+ "gemini": {
84
+ "command": "npx",
85
+ "args": ["@houtini/gemini-mcp"],
86
+ "env": {
87
+ "GEMINI_API_KEY": "your-api-key-here"
88
+ }
89
+ }
90
+ }
91
+ }
92
+ ```
93
+
94
+ #### Using Global Installation
95
+
96
+ ```json
97
+ {
98
+ "mcpServers": {
99
+ "gemini": {
100
+ "command": "gemini-mcp",
101
+ "env": {
102
+ "GEMINI_API_KEY": "your-api-key-here"
103
+ }
104
+ }
105
+ }
106
+ }
107
+ ```
108
+
109
+ Requires `npm install -g @houtini/gemini-mcp` first.
110
+
111
+ #### Using Local Build
112
+
113
+ ```json
114
+ {
115
+ "mcpServers": {
116
+ "gemini": {
117
+ "command": "node",
118
+ "args": ["./node_modules/@houtini/gemini-mcp/dist/index.js"],
119
+ "env": {
120
+ "GEMINI_API_KEY": "your-api-key-here"
121
+ }
122
+ }
123
+ }
124
+ }
125
+ ```
126
+
127
+ Only works if installed locally in the current directory.
128
+
129
+ ### Step 3: Restart Claude Desktop
130
+
131
+ After updating the config, restart Claude Desktop. The server loads on startup.
132
+
133
+ ### Optional: Additional Configuration
134
+
135
+ ```json
136
+ {
137
+ "mcpServers": {
138
+ "gemini": {
139
+ "command": "npx",
140
+ "args": ["@houtini/gemini-mcp"],
141
+ "env": {
142
+ "GEMINI_API_KEY": "your-api-key-here",
143
+ "LOG_LEVEL": "info",
144
+ "GEMINI_ALLOW_EXPERIMENTAL": "false"
145
+ }
146
+ }
147
+ }
148
+ }
149
+ ```
150
+
151
+ **Environment Variables:**
152
+
153
+ | Variable | Default | What It Does |
154
+ |----------|---------|--------------|
155
+ | `GEMINI_API_KEY` | *required* | Your Google AI Studio API key |
156
+ | `LOG_LEVEL` | `info` | Logging detail: `debug`, `info`, `warn`, `error` |
157
+ | `GEMINI_ALLOW_EXPERIMENTAL` | `false` | Include experimental models (set `true` to enable) |
158
+
159
+ ## Dynamic Model Discovery
160
+
161
+ The server automatically discovers available Gemini models from Google's API on first use. This happens transparently - you don't need to configure anything.
162
+
163
+ ### How It Works
164
+
165
+ 1. Server starts instantly with reliable fallback models
166
+ 2. First request triggers model discovery from Google's API (adds 1-2 seconds once)
167
+ 3. Subsequent requests use the discovered models (no delay)
168
+ 4. If discovery fails, fallback models work immediately
169
+
170
+ What I've found: this approach keeps you current with Google's releases whilst maintaining instant startup. The server filters to stable production models by default, which avoids experimental model rate limits.
171
+
172
+ ### What Gets Discovered
173
+
174
+ - All available Gemini models (stable and experimental)
175
+ - Accurate context window sizes directly from Google
176
+ - Model capabilities and recommended use cases
177
+ - Latest releases as soon as Google makes them available
178
+
179
+ The default model selection prioritises: stable models over experimental, newest version available, Flash variants for speed, and capability matching for your request type.
180
+
181
+ ### Performance Impact
182
+
183
+ - Startup: 0ms (instant)
184
+ - First request: +1-2 seconds (one-time discovery)
185
+ - Subsequent requests: 0ms overhead
186
+ - Discovery failure: 0ms (uses fallback immediately)
187
+
188
+ Check your logs after first request to see what was discovered:
189
+ ```
190
+ Models discovered from API (count: 38, defaultModel: gemini-2.5-flash)
191
+ ```
192
+
193
+ ## Experimental Models
194
+
195
+ By default, the server uses stable production models. This ensures reliable performance and avoids Google's stricter rate limits on experimental releases.
196
+
197
+ ### Stable vs Experimental
198
+
199
+ **Stable Models** (default behaviour):
200
+ - Production-ready
201
+ - Better rate limits
202
+ - Consistent performance
203
+ - Examples: `gemini-2.5-flash`, `gemini-2.5-pro`, `gemini-2.0-flash`
204
+
205
+ **Experimental Models** (opt-in):
206
+ - Latest features before stable release
207
+ - Stricter rate limits
208
+ - Potentially unexpected behaviour
209
+ - Can be deprecated quickly
210
+ - Examples: `gemini-exp-1206`, `gemini-2.0-flash-thinking-exp`
211
+
212
+ ### Enabling Experimental Models
213
+
214
+ Set `GEMINI_ALLOW_EXPERIMENTAL=true` in your configuration:
215
+
216
+ ```json
217
+ {
218
+ "mcpServers": {
219
+ "gemini": {
220
+ "command": "npx",
221
+ "args": ["@houtini/gemini-mcp"],
222
+ "env": {
223
+ "GEMINI_API_KEY": "your-api-key-here",
224
+ "GEMINI_ALLOW_EXPERIMENTAL": "true"
225
+ }
226
+ }
227
+ }
228
+ }
229
+ ```
230
+
231
+ This includes experimental models in discovery and makes them eligible as defaults. You can still explicitly request any model regardless of this setting - the flag only affects which models are used automatically.
232
+
233
+ ### When to Enable
234
+
235
+ Keep experimental disabled if you need reliable, consistent performance or you're building production applications.
236
+
237
+ Enable experimental if you're testing cutting-edge features, doing research, or you understand the rate limit trade-offs.
238
+
239
+ ## Usage Examples
240
+
241
+ ### Basic Chat
242
+
243
+ ```
244
+ Can you help me understand quantum computing using Gemini?
245
+ ```
246
+
247
+ Claude automatically uses the `gemini_chat` tool.
248
+
249
+ ### Creative Writing
250
+
251
+ ```
252
+ Use Gemini to write a short story about artificial intelligence discovering creativity.
253
+ ```
254
+
255
+ ### Technical Analysis
256
+
257
+ ```
258
+ Use Gemini Pro to explain the differences between various machine learning algorithms.
259
+ ```
260
+
261
+ ### Model Selection
262
+
263
+ ```
264
+ Use Gemini 1.5 Pro to analyse this code and suggest improvements.
265
+ ```
266
+
267
+ ### Getting Model Information
268
+
269
+ ```
270
+ Show me all available Gemini models and their capabilities.
271
+ ```
272
+
273
+ ---
274
+
275
+ ## Complete Prompting Guide
276
+
277
+ Check the **[Comprehensive Prompting Guide](PROMPTING_GUIDE.md)** for:
278
+
279
+ - Advanced prompting techniques
280
+ - Model selection strategies
281
+ - Parameter tuning (temperature, tokens, system prompts)
282
+ - Using Google Search grounding
283
+ - Creative workflows and use cases
284
+ - Best practices
285
+ - Troubleshooting
286
+
287
+ **[Read the Prompting Guide](PROMPTING_GUIDE.md)**
288
+
289
+ ---
290
+
291
+ ## Google Search Grounding
292
+
293
+ Google Search grounding is built in and enabled by default. This gives Gemini models access to current web information, which significantly improves accuracy for questions requiring up-to-date data.
294
+
295
+ ### What It Does
296
+
297
+ When you ask a question that benefits from current information:
298
+ 1. Analyses your query to determine if web search helps
299
+ 2. Generates relevant search queries automatically
300
+ 3. Performs Google searches using targeted queries
301
+ 4. Processes results and synthesises information
302
+ 5. Provides enhanced response with inline citations
303
+ 6. Shows search metadata including queries used
304
+
305
+ ### Best Use Cases
306
+
307
+ **Current Events & News**
308
+ ```
309
+ What are the latest developments in AI announced this month?
310
+ Recent breakthroughs in quantum computing research?
311
+ ```
312
+
313
+ **Real-time Data**
314
+ ```
315
+ Current stock prices for major tech companies
316
+ Today's weather forecast for London
317
+ ```
318
+
319
+ **Recent Developments**
320
+ ```
321
+ New software releases this week
322
+ Latest scientific discoveries in medicine
323
+ ```
324
+
325
+ **Fact Checking**
326
+ ```
327
+ Verify recent statements about climate change
328
+ Check the latest statistics on global internet usage
329
+ ```
330
+
331
+ ### Controlling Grounding
332
+
333
+ Grounding is enabled by default. Disable it for purely creative or hypothetical responses:
334
+
335
+ ```
336
+ Use Gemini without web search to write a fictional story about dragons in space.
337
+ ```
338
+
339
+ For API calls, use the `grounding` parameter:
340
+
341
+ ```json
342
+ {
343
+ "message": "Write a creative story about time travel",
344
+ "grounding": false
345
+ }
346
+ ```
347
+
348
+ ### Understanding Grounded Responses
349
+
350
+ Grounded responses include source citations and search transparency:
351
+
352
+ ```
353
+ Sources: (https://example.com/article1) (https://example.com/article2)
354
+ Search queries used: latest AI developments 2025, OpenAI GPT-5 release
355
+ ```
356
+
357
+ What I've found: grounding dramatically reduces hallucinations for factual queries whilst maintaining creative flexibility when you need it.
358
+
359
+ ## Deep Research
360
+
361
+ The server includes deep research capability that performs iterative multi-step research on complex topics. This synthesises comprehensive reports with proper citations.
362
+
363
+ ### How It Works
364
+
365
+ Deep research conducts multiple research iterations:
366
+
367
+ 1. Initial broad exploration
368
+ 2. Gap analysis identifying what's missing
369
+ 3. Targeted research into specific areas
370
+ 4. Synthesis into comprehensive report
371
+ 5. Iteration until thorough coverage
372
+
373
+ ### Using Deep Research
374
+
375
+ ```
376
+ Use Gemini deep research to investigate the impact of quantum computing on cybersecurity.
377
+ ```
378
+
379
+ With parameters:
380
+ ```
381
+ Use Gemini deep research with 7 iterations to create a comprehensive report on renewable energy trends, focusing on solar and wind power adoption rates.
382
+ ```
383
+
384
+ ### Research Parameters
385
+
386
+ | Parameter | Type | Default | What It Does |
387
+ |-----------|------|---------|--------------|
388
+ | `research_question` | string | *required* | The topic to investigate |
389
+ | `max_iterations` | integer | 5 | Research cycles (3-10) |
390
+ | `focus_areas` | array | - | Specific aspects to emphasise |
391
+ | `model` | string | *latest stable* | Which model to use |
392
+
393
+ ### Best For
394
+
395
+ - Academic research and literature reviews
396
+ - Market analysis and competitive intelligence
397
+ - Technology trend analysis
398
+ - Policy research and impact assessments
399
+ - Multi-faceted business problems
400
+
401
+ ### Configuring Iterations by Environment
402
+
403
+ Different AI environments have different timeout tolerances:
404
+
405
+ **Claude Desktop (3-5 iterations recommended)**
406
+ - Timeout: ~4 minutes
407
+ - Safe maximum: 5 iterations
408
+ - Use 3-4 for most tasks
409
+
410
+ **Agent SDK / IDEs (7-10 iterations recommended)**
411
+ - Timeout: 10+ minutes
412
+ - Maximum: 10 iterations
413
+ - Use 7-10 for comprehensive research
414
+
415
+ **AI Platforms like Cline, Roo-Cline (7-10 iterations)**
416
+ - Similar to Agent SDK
417
+ - Can handle longer processes
418
+
419
+ ### Handling Timeouts
420
+
421
+ If you hit timeout or thread limits:
422
+
423
+ 1. Reduce iterations (start with 3)
424
+ 2. Narrow focus using `focus_areas` parameter
425
+ 3. Split complex topics into smaller research tasks
426
+ 4. Check which environment you're using
427
+
428
+ Example with focused research:
429
+ ```
430
+ Use Gemini deep research with 3 iterations focusing on cost analysis and market adoption to examine solar panel technology trends.
431
+ ```
432
+
433
+ Deep research takes several minutes. It's designed for comprehensive analysis rather than quick answers.
434
+
435
+ ## API Reference
436
+
437
+ ### gemini_chat
438
+
439
+ Chat with Gemini models.
440
+
441
+ **Parameters:**
442
+
443
+ | Parameter | Type | Required | Default | What It Does |
444
+ |-----------|------|----------|---------|--------------|
445
+ | `message` | string | Yes | - | The message to send |
446
+ | `model` | string | No | *Latest stable* | Which model to use |
447
+ | `temperature` | number | No | 0.7 | Randomness (0.0-1.0) |
448
+ | `max_tokens` | integer | No | 8192 | Maximum response length (1-32768) |
449
+ | `system_prompt` | string | No | - | System instruction |
450
+ | `grounding` | boolean | No | true | Enable Google Search |
451
+
452
+ **Example:**
453
+ ```json
454
+ {
455
+ "message": "What are the latest developments in quantum computing?",
456
+ "model": "gemini-1.5-pro",
457
+ "temperature": 0.5,
458
+ "max_tokens": 1000,
459
+ "system_prompt": "You are a technology expert. Provide current information with sources.",
460
+ "grounding": true
461
+ }
462
+ ```
463
+
464
+ ### gemini_list_models
465
+
466
+ Retrieve information about discovered Gemini models.
467
+
468
+ **Parameters:** None required
469
+
470
+ **Example:**
471
+ ```json
472
+ {}
473
+ ```
474
+
475
+ **Response includes:**
476
+ - Model names and display names
477
+ - Descriptions of strengths
478
+ - Context window sizes from Google
479
+ - Recommended use cases
480
+
481
+ ### gemini_deep_research
482
+
483
+ Conduct iterative multi-step research.
484
+
485
+ **Parameters:**
486
+
487
+ | Parameter | Type | Required | Default | What It Does |
488
+ |-----------|------|----------|---------|--------------|
489
+ | `research_question` | string | Yes | - | Topic to research |
490
+ | `max_iterations` | integer | No | 5 | Research cycles (3-10) |
491
+ | `focus_areas` | array | No | - | Specific areas to emphasise |
492
+ | `model` | string | No | *Latest stable* | Model to use |
493
+
494
+ **Example:**
495
+ ```json
496
+ {
497
+ "research_question": "Impact of AI on healthcare diagnostics",
498
+ "max_iterations": 7,
499
+ "focus_areas": ["accuracy improvements", "cost implications", "regulatory challenges"]
500
+ }
501
+ ```
502
+
503
+ ### Available Models
504
+
505
+ Models are dynamically discovered from Google's API. Typical available models:
506
+
507
+ | Model | Best For | Description |
508
+ |-------|----------|-------------|
509
+ | **gemini-2.5-flash** | General use | Latest Flash - fast, versatile |
510
+ | **gemini-2.5-pro** | Complex reasoning | Latest Pro - advanced capabilities |
511
+ | **gemini-2.0-flash** | Speed-optimised | Gemini 2.0 Flash - efficient |
512
+ | **gemini-1.5-flash** | Quick responses | Gemini 1.5 Flash - fast |
513
+ | **gemini-1.5-pro** | Large context | 2M token context window |
514
+
515
+ Use `gemini_list_models` to see exact available models with current context limits.
516
+
517
+ ## Development
518
+
519
+ ### Building from Source
520
+
521
+ ```bash
522
+ git clone https://github.com/houtini-ai/gemini-mcp.git
523
+ cd gemini-mcp
524
+ npm install
525
+ npm run build
526
+ npm run dev
527
+ ```
528
+
529
+ ### Scripts
530
+
531
+ | Command | What It Does |
532
+ |---------|--------------|
533
+ | `npm run build` | Compile TypeScript |
534
+ | `npm run dev` | Development mode with live reload |
535
+ | `npm start` | Run compiled server |
536
+ | `npm test` | Run tests |
537
+ | `npm run lint` | Check code style |
538
+ | `npm run lint:fix` | Fix linting issues |
539
+
540
+ ### Project Structure
541
+
542
+ ```
543
+ src/
544
+ ├── config/ # Configuration management
545
+ ├── services/ # Business logic
546
+ │ └── gemini/ # Gemini API integration
547
+ ├── tools/ # MCP tool implementations
548
+ ├── utils/ # Logger and error handling
549
+ ├── cli.ts # CLI entry
550
+ └── index.ts # Main server
551
+ ```
552
+
553
+ ### Architecture
554
+
555
+ The server follows clean, layered architecture:
556
+
557
+ 1. CLI Layer - Command-line interface
558
+ 2. Server Layer - MCP protocol handling
559
+ 3. Tools Layer - MCP tool implementations
560
+ 4. Service Layer - Business logic and API integration
561
+ 5. Utility Layer - Logging and error handling
562
+
563
+ ## Troubleshooting
564
+
565
+ ### "GEMINI_API_KEY environment variable not set"
566
+
567
+ Check your Claude Desktop configuration includes the API key in the `env` section.
568
+
569
+ ### Server Not Appearing in Claude Desktop
570
+
571
+ 1. Restart Claude Desktop after configuration changes
572
+ 2. Verify config file path:
573
+ - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
574
+ - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
575
+ 3. Validate JSON syntax
576
+ 4. Test your API key at [Google AI Studio](https://makersuite.google.com/app/apikey)
577
+
578
+ ### "Module not found" with npx
579
+
580
+ ```bash
581
+ # Clear npx cache
582
+ npx --yes @houtini/gemini-mcp
583
+
584
+ # Or install globally
585
+ npm install -g @houtini/gemini-mcp
586
+ ```
587
+
588
+ ### Node.js Version Issues
589
+
590
+ ```bash
591
+ # Check version
592
+ node --version
593
+
594
+ # Should be v18.0.0 or higher
595
+ # Update from https://nodejs.org
596
+ ```
597
+
598
+ ### Debug Mode
599
+
600
+ Enable detailed logging:
601
+
602
+ ```json
603
+ {
604
+ "mcpServers": {
605
+ "gemini": {
606
+ "command": "npx",
607
+ "args": ["@houtini/gemini-mcp"],
608
+ "env": {
609
+ "GEMINI_API_KEY": "your-api-key-here",
610
+ "LOG_LEVEL": "debug"
611
+ }
612
+ }
613
+ }
614
+ }
615
+ ```
616
+
617
+ ### Log Files
618
+
619
+ Logs are written to:
620
+ - Console output (Claude Desktop developer tools)
621
+ - `logs/combined.log` - All levels
622
+ - `logs/error.log` - Errors only
623
+
624
+ ### Testing Your Setup
625
+
626
+ Test with these queries:
627
+ 1. "Can you list the available Gemini models?"
628
+ 2. "Use Gemini to explain photosynthesis."
629
+ 3. "Use Gemini 1.5 Pro with temperature 0.9 to write a creative poem about coding."
630
+
631
+ ### Performance Tuning
632
+
633
+ For better performance:
634
+
635
+ - Adjust token limits based on your use case
636
+ - Use appropriate models (Flash for speed, Pro for complexity)
637
+ - Monitor logs for rate limiting issues
638
+ - Set temperature values appropriately (0.7 balanced, 0.3 focused, 0.9 creative)
639
+
640
+ ## Contributing
641
+
642
+ Contributions welcome. Follow these steps:
643
+
644
+ 1. Fork the repository
645
+ 2. Create a feature branch: `git checkout -b feature/amazing-feature`
646
+ 3. Make your changes and add tests
647
+ 4. Run tests: `npm test`
648
+ 5. Lint: `npm run lint:fix`
649
+ 6. Build: `npm run build`
650
+ 7. Commit: `git commit -m 'Add amazing feature'`
651
+ 8. Push: `git push origin feature/amazing-feature`
652
+ 9. Open a Pull Request
653
+
654
+ ### Development Guidelines
655
+
656
+ - Follow TypeScript best practices
657
+ - Add tests for new functionality
658
+ - Update documentation
659
+ - Use conventional commit messages
660
+ - Maintain backwards compatibility
661
+
662
+ ## Technical Details
663
+
664
+ ### Migration to MCP SDK 1.25.3
665
+
666
+ This server has been migrated to the latest MCP SDK (1.25.3) with ES modules support. Key technical changes:
667
+
668
+ **SDK Updates:**
669
+ - Migrated from `Server` class to `McpServer` API
670
+ - Tool registration uses `registerTool` with Zod validation
671
+ - ES modules throughout (`"type": "module"`)
672
+ - TypeScript configured for `nodenext` module resolution
673
+
674
+ **Compatibility:**
675
+ - Node.js 18+ (changed from 24+ for broader compatibility)
676
+ - All imports use `.js` extensions for ES module compliance
677
+ - Zod schemas for runtime type validation
678
+ - Modern MCP protocol implementation
679
+
680
+ **Build System:**
681
+ - TypeScript compiles to ES2022 modules
682
+ - Clean separation between business logic and MCP interface
683
+ - Preserved all Gemini API client functionality
684
+
685
+ What this means practically: the server now follows modern Node.js and MCP standards, which should prevent compatibility issues with future Claude Desktop updates whilst maintaining all existing functionality.
686
+
687
+ ## Licence
688
+
689
+ This project is licensed under the Apache 2.0 Licence - see the [LICENSE](LICENSE) file for details.
690
+
691
+ ## Disclaimer
692
+
693
+ **Use at Your Own Risk**: This software is provided "as is" without warranty. The authors accept no responsibility for damages, data loss, or other issues arising from use.
694
+
695
+ **Content Safety**: This server interfaces with Google's Gemini AI models. Whilst content safety settings are implemented, AI-generated content quality cannot be guaranteed. Users are responsible for reviewing AI output before use and ensuring compliance with applicable laws.
696
+
697
+ **API Key Security**: Your Google Gemini API key is sensitive. Keep it confidential, don't commit it to version control, rotate if exposed, and manage API usage costs.
698
+
699
+ **Data Privacy**: This server processes data through the Model Context Protocol. Avoid sending sensitive or confidential information. Review Google's privacy policy and implement appropriate data handling.
700
+
701
+ **Production Use**: Users deploying in production should conduct security audits, implement monitoring, have incident response procedures, and regularly update dependencies.
702
+
703
+ **Third-Party Services**: This software relies on external services (Google Gemini API, npm packages). Service availability, pricing, and functionality may change.
704
+
705
+ **No Professional Advice**: AI-generated content should not be considered professional advice (legal, medical, financial) without verification by qualified professionals.
706
+
707
+ By using this software, you acknowledge these terms and agree to use at your own risk.
708
+
709
+ ## Support
710
+
711
+ - **GitHub Issues**: [Report bugs or request features](https://github.com/houtini-ai/gemini-mcp/issues)
712
+ - **GitHub Discussions**: [Ask questions or share ideas](https://github.com/houtini-ai/gemini-mcp/discussions)
713
+
714
+ ## Changelog
715
+
716
+ ### v1.3.2 - Node.js 18+ Compatibility & Modern SDK
717
+
718
+ **Breaking Changes:** None (all tool interfaces preserved)
719
+
720
+ **Technical Updates:**
721
+ - Updated to MCP SDK 1.25.3 (from 1.19.1)
722
+ - Migrated to ES modules (`"type": "module"`)
723
+ - Changed Node.js requirement to >=18.0.0 (from >=24.0.0) for broader compatibility
724
+ - Migrated from `Server` to `McpServer` API
725
+ - Implemented Zod schema validation for all tools
726
+ - Updated TypeScript config to `nodenext` module resolution
727
+
728
+ **Fixes:**
729
+ - Resolved Node.js v24 ERR_MODULE_NOT_FOUND errors
730
+ - Fixed TypeScript compilation with DOM types for fetch API
731
+ - All imports now use `.js` extensions for ES module compliance
732
+
733
+ **What This Means:**
734
+ The server now works reliably with Node.js 18, 20, 22, and 24. All existing functionality preserved - this is purely a technical infrastructure update for better compatibility.
735
+
736
+ ### v1.1.0 - Deep Research & Enhanced Discovery
737
+
738
+ **New Features:**
739
+ - Added deep research capability for iterative analysis
740
+ - Enhanced model discovery with better filtering
741
+ - Improved default model selection logic
742
+ - Better handling of experimental vs stable models
743
+
744
+ ### v1.0.4 - Security & Dependencies
745
+
746
+ **Updates:**
747
+ - Updated @google/generative-ai to v0.24.1
748
+ - Updated @modelcontextprotocol/sdk to v1.19.1
749
+ - Changed safety settings to BLOCK_MEDIUM_AND_ABOVE
750
+ - Added comprehensive disclaimer
751
+ - Zero vulnerabilities in dependencies
752
+
753
+ ### v1.0.3 - Enhanced Grounding
754
+
755
+ **Improvements:**
756
+ - Fixed grounding metadata field names
757
+ - Enhanced source citation processing
758
+ - Improved grounding reliability
759
+ - Better error handling for grounding
760
+
761
+ ### v1.0.2 - Google Search Grounding
762
+
763
+ **New Features:**
764
+ - Added Google Search grounding (enabled by default)
765
+ - Real-time web search integration
766
+ - Source citations in responses
767
+ - Configurable grounding parameter
768
+
769
+ ### v1.0.0 - Initial Release
770
+
771
+ **Core Features:**
772
+ - Complete TypeScript rewrite
773
+ - Professional modular architecture
774
+ - Comprehensive error handling
775
+ - Full MCP protocol compliance
776
+ - Multiple Gemini model support
777
+ - NPM package distribution
778
+ - Production-ready build system
779
+
780
+ ---
781
+
782
+ **Built for the Model Context Protocol community**
783
+
784
+ For more about MCP, visit [modelcontextprotocol.io](https://modelcontextprotocol.io)