Ask Google MCP Server
A stdio MCP server that provides a single tool to query Gemini with Google Search grounding for current web information, returning synthesized answers with source links.
README
Ask Google MCP Server
ask-google-mcp is a stdio MCP server that exposes a single tool, ask_google.
That tool sends a question to Gemini with Google Search grounding enabled, then returns:
- a synthesized answer
- appended source links
- appended search queries Gemini performed
This is for agent workflows that need current web information inside an MCP client such as Claude Code.
What It Does
ask_google is useful when the agent needs information that should not be answered from stale training data alone, for example:
- latest versions, releases, and changelogs
- current docs, standards, or API changes
- comparisons between current products or libraries
- recent announcements or status checks
- short web research tasks with citations
The server is intentionally narrow:
- one MCP tool:
ask_google - stdio transport only
- no web UI
- no HTTP server
Recommended Setup: Claude Code User Scope
I checked the local Claude Code CLI help.
claude mcp --help shows that add supports scopes local, user, and project, and claude mcp add --help shows the default scope is local.
If you want this available across all projects, use --scope user.
Option 1: Install from npm globally
npm install -g @gpriday/ask-google-mcp
Then add it to Claude Code at user scope and set the API key directly in the MCP config:
claude mcp add --scope user -e GOOGLE_API_KEY=your_api_key_here ask-google -- ask-google-mcp
Verify it:
claude mcp get ask-google
claude mcp list
Option 2: Use a local checkout
This is better for development, not for normal usage.
git clone https://github.com/gpriday/ask-google-mcp.git
cd ask-google-mcp
npm install
Then register that checkout with Claude Code:
claude mcp add --scope user -e GOOGLE_API_KEY=your_api_key_here ask-google -- node /absolute/path/to/ask-google-mcp/src/index.js
Requirements
- Node.js
>=20 - A Google AI Studio API key with Gemini access
Get an API key here:
- https://aistudio.google.com/apikey
How Configuration Actually Works
The server loads environment variables in this order:
process.cwd()/.env~/.env- existing process environment variables
That means:
- it does read
~/.env - it does not read a fixed repository root unless the server process is started from that directory
- for Claude Code, passing the API key with
claude mcp add -e GOOGLE_API_KEY=...is the clearest and most reliable setup
Minimum required variable for live tool calls:
GOOGLE_API_KEY=your_api_key_here
Optional variables:
ASK_GOOGLE_TIMEOUT_MS=300000
ASK_GOOGLE_MAX_RETRIES=3
ASK_GOOGLE_INITIAL_RETRY_DELAY_MS=1000
# Auto-routing (on by default)
# ASK_GOOGLE_ROUTER_ENABLED=true
# ASK_GOOGLE_ROUTER_MODEL=flash-lite
# ASK_GOOGLE_ROUTER_TIMEOUT_MS=5000
# ASK_GOOGLE_ROUTER_FALLBACK_MODEL=flash
# Optional model alias overrides
# ASK_GOOGLE_MODEL_PRO=gemini-3.1-pro-preview
# ASK_GOOGLE_MODEL_FLASH=gemini-3.5-flash
# ASK_GOOGLE_MODEL_FLASH_LITE=gemini-3.1-flash-lite
Runtime Behavior
- The server starts even if
GOOGLE_API_KEYis missing. - MCP clients can still initialize and list tools without the key.
- The
ask_googletool itself returns an[AUTH_ERROR]if called without a key. - Requests time out after
ASK_GOOGLE_TIMEOUT_MSmilliseconds unless you override it. - Retries are enabled for retryable upstream failures.
Tool Reference
Tool name
ask_google
Inputs
question- required string, 1 to 4,000 characters (also accepted asqueryalias; do not set both)model- optional:auto(default),pro,flash, orflash-lite
Model aliases
pro->gemini-3.1-pro-previewflash->gemini-3.5-flashflash-lite->gemini-3.1-flash-lite
Those defaults can be overridden with environment variables if Google renames preview models.
Auto-routing (default)
When model is auto (the default), the server runs a tiny classifier call on Flash-Lite to pick the downstream tier based on query complexity:
- flash-lite — simple lookups, single facts, current versions, API signatures, math, trivia
- flash — research briefs, multi-source comparisons, code generation needing current syntax, "what changed in X" questions
- pro — deep reasoning, recommendations with trade-offs, architecture/strategy/migration decisions, opinion questions
The router has a tight timeout (5s by default) and strict JSON enum output. If it times out, fails, or returns something unusable, the server falls back to flash (configurable via ASK_GOOGLE_ROUTER_FALLBACK_MODEL) and proceeds with the normal grounded call.
You can still pin a specific model (pro, flash, flash-lite) to bypass the router. To disable auto-routing entirely and restore the old default-model behavior, set ASK_GOOGLE_ROUTER_ENABLED=false.
The routing decision is surfaced in the response's diagnostics.router block and in the diagnostics footer text (e.g., model=auto→pro · router=0.4s).
Example Tool Calls
Basic current-information query
{
"name": "ask_google",
"arguments": {
"question": "Find the current Node.js LTS version and its release date"
}
}
Faster lookup with flash
{
"name": "ask_google",
"arguments": {
"question": "What is the latest stable TypeScript release?",
"model": "flash"
}
}
Research-style comparison
{
"name": "ask_google",
"arguments": {
"question": "React 19 vs React 18: current migration risks, breaking changes, and official upgrade guidance"
}
}
What The Tool Returns
The tool returns text content that includes:
- Gemini's answer
- a
Sourcessection appended by the server - a
Search queries performedsection appended by the server when available
CLI Usage
If you installed the package globally:
ask-google-mcp
If you are running from a local checkout:
npm start
CLI flags:
ask-google-mcp --help
ask-google-mcp --version
Environment Validation
For local development, validate configuration with:
npm run check-env
That script checks:
- whether a local
.envor~/.envexists - whether
GOOGLE_API_KEYlooks present and non-placeholder - Node.js version compatibility
- optional runtime settings like timeout flags
Claude Desktop
Claude Code is the primary recommended workflow, but Claude Desktop can also run the server.
Global install example:
{
"mcpServers": {
"ask-google": {
"command": "ask-google-mcp",
"env": {
"GOOGLE_API_KEY": "your_api_key_here"
}
}
}
}
Local checkout example:
{
"mcpServers": {
"ask-google": {
"command": "node",
"args": ["/absolute/path/to/ask-google-mcp/src/index.js"],
"env": {
"GOOGLE_API_KEY": "your_api_key_here"
}
}
}
}
Development
Project structure:
src/
ask-google.js
config.js
errors.js
index.js
prompt.js
retry.js
router.js
router-prompt.txt
sanitize.js
server.js
system-prompt.txt
tool.js
scripts/
check-env.js
test/
integration/
support/
unit/
Scripts:
npm start- start the MCP servernpm test- run unit testsnpm run test:integration- run live integration tests when enablednpm run test:all- run both suitesnpm run dev- run withnode --watchnpm run check-env- validate environment config
Live integration tests only run when both are set:
RUN_LIVE_TESTS=1
GOOGLE_API_KEY=your_api_key_here
Error Categories
Tool failures are surfaced as MCP errors with categorized messages:
[AUTH_ERROR]- missing or invalid API key[QUOTA_ERROR]- quota or rate limit exceeded[TIMEOUT_ERROR]- request timed out[API_ERROR]- other Gemini/API failures
License
MIT
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。