
Gemini Grounding
STDIOAI-powered web search and summarization using Gemini API's grounding feature.
AI-powered web search and summarization using Gemini API's grounding feature.
A Model Context Protocol (MCP) server that provides AI-powered web search and summarization using the Gemini API's grounding feature. Unlike traditional search tools that return raw results, this server uses Gemini AI to synthesize information and provide comprehensive answers with citations.
git clone https://github.com/ml0-1337/mcp-gemini-grounding.git cd mcp-gemini-grounding make build
For a full list of available commands, run:
make help
# From source make install # Or using go install directly go install github.com/ml0-1337/mcp-gemini-grounding/cmd/gemini-grounding@latest
The server supports two authentication methods:
OAuth Credentials (Preferred)
~/.gemini/oauth_creds.json
API Key (Fallback)
GEMINI_API_KEY
environment variableChoose the appropriate configuration scope based on your needs:
Important: When using the CLI commands below, you must provide the full absolute path to the binary (e.g., /Users/username/projects/mcp-gemini-grounding/mcp-gemini-grounding
). Relative paths like ./mcp-gemini-grounding
will cause the server to fail.
Best for: Personal development servers, experimental configurations, or servers with sensitive credentials.
Option A: Using CLI (Recommended)
# If installed globally claude mcp add gemini-grounding # Or with full absolute path (required - relative paths will fail) claude mcp add gemini-grounding /full/path/to/mcp-gemini-grounding # Example: claude mcp add gemini-grounding /Users/username/projects/mcp-gemini-grounding/mcp-gemini-grounding
Option B: Manual configuration
{ "mcpServers": { "gemini-grounding": { "command": "/path/to/mcp-gemini-grounding", "env": { "GEMINI_API_KEY": "$GEMINI_API_KEY" } } } }
This configuration is stored in your project's .claude/settings.local.json
file and is not shared with others.
Best for: Team collaboration where all members need the same MCP server configuration.
Option A: Using CLI (Recommended)
# If installed globally claude mcp add gemini-grounding -s project # Or with full absolute path (required - relative paths will fail) claude mcp add gemini-grounding -s project /full/path/to/mcp-gemini # Example: claude mcp add gemini-grounding -s project /Users/username/projects/mcp-gemini-grounding/mcp-gemini-grounding
Option B: Manual configuration
.mcp.json
file in your project root{ "mcpServers": { "gemini-grounding": { "command": "mcp-gemini-grounding", "env": { "GEMINI_API_KEY": "$GEMINI_API_KEY" } } } }
GEMINI_API_KEY
environment variable locallyNote: Never commit actual API keys. Always use environment variable references (e.g., $GEMINI_API_KEY
).
Best for: Personal utility servers you want available across all your projects.
Option A: Using CLI (Recommended)
# If installed globally claude mcp add gemini-grounding -s user # Or with full absolute path (required - relative paths will fail) claude mcp add gemini-grounding -s user /full/path/to/mcp-gemini # Example: claude mcp add gemini-grounding -s user /Users/username/projects/mcp-gemini-grounding/mcp-gemini-grounding
Option B: Manual configuration
{ "mcpServers": { "gemini-grounding": { "command": "gemini", "env": { "GEMINI_API_KEY": "$GEMINI_API_KEY" } } } }
If you installed globally with go install
, you can simply use "command": "gemini"
.
After adding the server, set your API key:
# macOS/Linux export GEMINI_API_KEY="your-api-key-here" # Windows (PowerShell) $env:GEMINI_API_KEY="your-api-key-here" # Windows (Command Prompt) set GEMINI_API_KEY=your-api-key-here
For permanent configuration, add the export to your shell profile (~/.bashrc
, ~/.zshrc
, etc.).
Claude Code applies configurations in this order (highest to lowest priority):
This allows personal configurations to override shared ones when needed.
API Key Management:
$GEMINI_API_KEY
export GEMINI_API_KEY="your-api-key-here"
OAuth Credentials:
~/.gemini/oauth_creds.json
if availableTeam Environments:
.mcp.json
) without sensitive dataOnce configured, the google_search
tool will be available in Claude Code. You can use it by asking Claude to search and summarize information:
{ "name": "google_search", "description": "Uses Google Search via Gemini AI grounding to find information and provide synthesized answers with citations. Returns AI-generated summaries rather than raw search results.", "inputSchema": { "type": "object", "properties": { "query": { "type": "string", "description": "The search query to find information on the web" } }, "required": ["query"] } }
The tool returns search results with:
Example output:
Web search results for "quantum computing":
Quantum computing is a rapidly evolving field[1]. Recent breakthroughs have shown promise for practical applications[2].
Sources:
[1] Quantum Computing Explained - MIT (https://mit.edu/quantum)
[2] Latest Quantum Breakthroughs - Nature (https://nature.com/quantum)
# Install dependencies make deps # Build the project make build # Run tests make test # Run all quality checks make audit
Run make help
to see all available commands. Key commands include:
make build
, make run
, make install
make test
, make cover
, make test-race
make fmt
, make vet
, make lint
, make audit
make dev
, make watch
(requires air)make build-all
(builds for Linux, macOS, Windows)make mcp-install
, make mcp-config
make release
, make checksum
# Run all tests make test # Run tests with coverage make cover # Run tests with race detection make test-race # Generate HTML coverage report make cover-html
Various test scripts for OAuth2 and API testing are available in the scripts/test/
directory. See scripts/test/README.md for details.
graph TD subgraph User A[MCP Client e.g. Claude Code] end subgraph "mcp-gemini-grounding" B[cmd/gemini-grounding/main.go] C[internal/search] D[internal/gemini] E[internal/auth] end subgraph "Google Cloud" F[Gemini API] end A -- MCP Request --> B B -- Initializes --> C B -- Initializes --> D B -- Initializes --> E C -- Uses --> D D -- Uses --> E D -- Makes API Calls --> F style A fill:#f9f,stroke:#333,stroke-width:2px style F fill:#bbf,stroke:#333,stroke-width:2px
mcp-gemini-grounding/
├── cmd/gemini-grounding/ # Main application entry point
├── internal/
│ ├── auth/ # Authentication handling
│ ├── gemini/ # Gemini API client
│ └── search/ # MCP tool handler
├── go.mod
├── go.sum
└── README.md
Check OAuth credentials exist:
ls ~/.gemini/oauth_creds.json
Or ensure API key is set:
echo $GEMINI_API_KEY
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.