@houtini/gemini-mcp 1.3.1 → 1.3.3

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