io.github.capyBearista/gemini-researcher

搜索与获取

by capybearista

无状态 MCP server,可将 research queries 代理到 Gemini CLI,从而减少 agent context 与 model usage。

什么是 io.github.capyBearista/gemini-researcher

无状态 MCP server,可将 research queries 代理到 Gemini CLI,从而减少 agent context 与 model usage。

README

Gemini Researcher

NPM Version NPM Downloads License: BSD-3 Claude

<a href="https://glama.ai/mcp/servers/@capyBearista/gemini-researcher"> <img width="380" height="200" src="https://glama.ai/mcp/servers/@capyBearista/gemini-researcher/badge" /> </a>

A lightweight, stateless MCP (Model Context Protocol) server that lets developer agents (Claude Code, GitHub Copilot) hand off deep repository analysis to the Gemini CLI. The server is read-only, returns structured JSON (as text content), and is designed to reduce the calling agent's context and model usage.

Status: v1 complete. Core features are stable, but still early days. Feedback welcome!

If this saved you tokens, ⭐ please consider giving it a star! :)

The primary goals:

  • Reduce agent context usage by letting Gemini CLI read large codebases locally and do its own research
  • Reduce calling-agent model usage by offloading heavy analysis to Gemini
  • Keep the server stateless and read-only for safety

Why use this?

Instead of copying entire files into your agent's context (burning tokens and cluttering the conversation), this server lets Gemini CLI read files directly from your project. Your agent sends a research query, Gemini reads and synthesizes using its large context window, and returns structured results. You save tokens, your agent stays focused, and complex codebase analysis becomes practical.

Verified clients: Claude Code, Cursor, VS Code (GitHub Copilot)

[!NOTE] It definitely works with other clients, but I haven't personally tested them yet. Please open an issue if you try it elsewhere!

Table of contents

Overview

Gemini Researcher accepts queries from your AI agent and uses Gemini CLI to analyze your local code files. Results are returned as formatted JSON for your agent to use.

Runtime safety

The server runs Gemini CLI with safety restrictions enabled. See docs/runtime-contract.md for full technical details.

Default invocation pattern:

bash
gemini [ -m <model> ] --output-format json --approval-mode default [--admin-policy <path>] -p "<prompt>"

Key safety points:

  • Uses --approval-mode default (not yolo mode) for controlled execution
  • Enforces read-only policy by default to prevent file changes
  • Policy blocks mutating tools like write_file, replace, run_shell_command
  • Strict enforcement can be disabled with GEMINI_RESEARCHER_ENFORCE_ADMIN_POLICY=0 (not recommended)

Auth and health check

Run health_check with includeDiagnostics: true to see auth status and server health.

authStatusWhat it meansImpact
configuredGemini CLI is authenticatedServer ready to use
unauthenticatedNo valid authentication foundServer marked as degraded
unknownCould not verify auth statusServer marked as degraded

health_check.status values:

  • ok: Gemini CLI is available, auth is working, and safety policy is enforced
  • degraded: Setup incomplete, auth unclear, or safety policy disabled

Prerequisites

  • Node.js 18+ installed
  • Gemini CLI installed: npm install -g @google/gemini-cli
  • Gemini CLI authenticated (recommended: gemini → Login with Google) or set GEMINI_API_KEY

Quick checks:

bash
node --version
gemini --version

Quickstart

Step 1: Validate environment

Run the setup wizard to verify Gemini CLI is installed and authenticated:

bash
npx gemini-researcher init

Step 2: Configure your MCP client

Standard config works in most of the tools:

json
{
  "mcpServers": {
    "gemini-researcher": {
      "command": "npx",
      "args": [
        "gemini-researcher"
      ]
    }
  }
}

[!NOTE] On native Windows, some MCP hosts use shell-less process spawning and may not resolve npm command shims reliably (npx, gemini). If startup fails with launch errors (spawn ... ENOENT / GEMINI_CLI_LAUNCH_FAILED despite working in PowerShell), prefer Docker or WSL for immediate reliability. See the full remediation tree in docs/platforms/windows.md.

<details> <summary>VS Code</summary>

Add to your VS Code MCP settings (create .vscode/mcp.json if needed):

json
{
  "servers": {
    "gemini-researcher": {
      "command": "npx",
      "args": [
        "gemini-researcher"
      ]
    }
  }
}
</details> <details> <summary>Claude Code</summary>

Option 1: Command line (recommended)

Local (user-wide) scope

bash
# Add the MCP server via CLI
claude mcp add --transport stdio gemini-researcher -- npx gemini-researcher 

# Verify it was added
claude mcp list

Project scope

Navigate to your project directory, then run:

bash
# Add the MCP server via CLI
claude mcp add --scope project --transport stdio gemini-researcher -- npx gemini-researcher

# Verify it was added
claude mcp list

Option 2: Manual configuration

Add to .mcp.json in your project root (project scope):

json
{
  "mcpServers": {
    "gemini-researcher": {
      "command": "npx",
      "args": [
        "gemini-researcher"
      ]
    }
  }
}

Or add to ~/.claude/settings.json for local scope.

After adding the server, restart Claude Code and use /mcp to verify the connection.

</details> <details> <summary>Cursor</summary>

Go to Cursor Settings -> Tools & MCP -> Add a Custom MCP Server. Add the following configuration:

json
{
  "mcpServers": {
    "gemini-researcher": {
      "type": "stdio",
      "command": "npx",
      "args": [
        "gemini-researcher"
      ]
    }
  }
}
</details>

[!NOTE] The server automatically uses the directory where the IDE opened your workspace as the project root or where your terminal is. To analyze a different directory, optionally set PROJECT_ROOT:

Example

json
{
  "mcpServers": {
    "gemini-researcher": {
      "command": "npx",
      "args": [
        "gemini-researcher"
      ],
      "env": {
        "PROJECT_ROOT": "/path/to/your/project"
      }
    }
  }
}

Step 3: Restart your MCP client

Step 4: Test it

Ask your agent: "Use gemini-researcher to analyze the project."

Tools

All tools return structured JSON (as MCP text content). Large responses are chunked (~10KB per chunk) and cached for 1 hour.

ToolPurposeWhen to use
quick_queryFast analysis with flash modelQuick questions about specific files or small code sections
deep_researchIn-depth analysis with pro modelComplex multi-file analysis, architecture reviews, security audits
analyze_directoryMap directory structureUnderstanding unfamiliar codebases, generating project overviews
validate_pathsPre-check file pathsVerify files exist before running expensive queries
health_checkDiagnosticsTroubleshooting server/Gemini CLI issues
fetch_chunkGet chunked responsesRetrieve remaining parts of large responses

Query tool fallback chains are family-aware:

  • quick_query: flash -> flash_lite -> auto
  • deep_research: pro -> flash -> flash_lite -> auto
  • analyze_directory: flash -> flash_lite -> auto

When using API-key auth, fallback also handles model-unavailable/unsupported errors (not only quota/capacity errors).

Example workflows

Understanding a security vulnerability:

code
Agent: Use deep_research to analyze authentication flow across @src/auth and @src/middleware, focusing on security

Quick code explanation:

code
Agent: Use quick_query to explain the login flow in @src/auth.ts, be concise

Mapping an unfamiliar codebase:

code
Agent: Use analyze_directory on src/ with depth 3 to understand the project structure
<details> <summary>Full tool schemas (for reference)</summary>

quick_query

json
{
  "prompt": "Explain @src/auth.ts login flow",
  "focus": "security",
  "responseStyle": "concise"
}

deep_research

json
{
  "prompt": "Analyze authentication across @src/auth and @src/middleware",
  "focus": "architecture",
  "citationMode": "paths_only"
}

analyze_directory

json
{
  "path": "src",
  "depth": 3,
  "maxFiles": 200
}

validate_paths

json
{
  "paths": ["src/auth.ts", "README.md"]
}

health_check

json
{
  "includeDiagnostics": true
}

fetch_chunk

json
{
  "cacheKey": "cache_abc123",
  "chunkIndex": 2
}
</details>

Docker

A pre-built multi-platform Docker image is available on Docker Hub:

bash
# Pull the image (works on Intel/AMD and Apple Silicon)
docker pull capybearista/gemini-researcher:latest

# Run the server (mount your project and provide API key)
docker run -i --rm \
  -e GEMINI_API_KEY="your-api-key" \
  -v /path/to/your/project:/workspace \
  capybearista/gemini-researcher:latest

For MCP client configuration with Docker:

json
{
  "mcpServers": {
    "gemini-researcher": {
      "command": "docker",
      "args": [
        "run", "-i", "--rm",
        "-e", "GEMINI_API_KEY",
        "-v", "/path/to/your/project:/workspace",
        "capybearista/gemini-researcher:latest"
      ],
      "env": {
        "GEMINI_API_KEY": "your-api-key-here"
      }
    }
  }
}

[!NOTE]

  • The -i flag is required for stdio transport
  • The container mounts your project to /workspace (the project root)
  • Replace /path/to/your/project with your actual project path
  • Replace your-api-key with your actual Gemini API key (this is required for Docker usage)

Platform guides

Troubleshooting (common issues)

  • Remediation decision tree:
Error / signalRun this check firstChange this configuration next
GEMINI_CLI_LAUNCH_FAILED or spawn ... ENOENTgemini --help and npx --version in the same terminal profile used by your MCP hostPrefer Docker or WSL config. If staying native, point host command to a stable shim/binary path and restart host.
health_check warning: "resolves only through cmd /c fallback"Run health_check with includeDiagnostics: true and inspect diagnostics.resolutionUpdate host config to launch the reported .cmd shim directly instead of relying on cmd /c fallback.
MCP host cannot launch server via npxnpx --versionChange host server command from npx gemini-researcher to installed binary path (or Docker transport).
ADMIN_POLICY_UNSUPPORTED / output format unsupportedgemini --help and confirm --admin-policy, json, stream-jsonUpgrade Gemini CLI to v0.36.0+
AUTH_MISSING / AUTH_UNKNOWNgemini interactive login and rerun health_checkAuthenticate Gemini CLI or set GEMINI_API_KEY
  • GEMINI_CLI_NOT_FOUND: Install Gemini CLI: npm install -g @google/gemini-cli
  • GEMINI_CLI_LAUNCH_FAILED: This is a launch-path issue, not an auth/capability issue. On Windows, command shims can fail in shell-less spawn contexts. Validate gemini --help and npx --version interactively, then prefer Docker or WSL if host launch mode is strict.
  • GEMINI_RESEARCHER_GEMINI_COMMAND: Override the Gemini command name/path used by the server (for wrappers or pinned binary locations).
  • GEMINI_RESEARCHER_GEMINI_ARGS_PREFIX: Prefix extra Gemini args for every invocation (for example --config <file>).
  • health_check diagnostics redact sensitive token-like values in configured args prefix output.
  • AUTH_MISSING: Run gemini, and authenticate or set GEMINI_API_KEY
  • AUTH_UNKNOWN: Auth could not be confirmed (often network/CLI probe failure). If launch errors are present, fix launch-path first; otherwise verify gemini works interactively, then retry.
  • ADMIN_POLICY_MISSING: Reinstall package or verify policies/read-only-enforcement.toml exists in installed package.
  • ADMIN_POLICY_UNSUPPORTED: Upgrade Gemini CLI to v0.36.0+ (gemini --help should include --admin-policy).
  • Capability errors (ADMIN_POLICY_UNSUPPORTED, output format unsupported) should be interpreted only after a successful gemini --help probe. If probe launch fails, treat it as launch-path failure first.
  • GEMINI_RESEARCHER_ENFORCE_ADMIN_POLICY=0: Disables strict startup policy checks. This reduces safety guarantees.
  • .gitignore blocking files: Gemini respects .gitignore by default; toggle fileFiltering.respectGitIgnore in gemini /settings if you intentionally want ignored files included (note: this changes Gemini behavior globally)
  • PATH_NOT_ALLOWED: All @path references must resolve inside the configured project root (process.cwd() by default). Use validate_paths to pre-check paths.
  • QUOTA_EXCEEDED: Server retries with fallback models; if all options are exhausted, reduce scope (use quick_query) or wait for quota reset.

Contributing

Read the Contributing Guide to get started.

Quick links:

License

BSD-3-Clause License


<p align="center"> Made with ♡ for the AI-assisted dev community </p>

常见问题

io.github.capyBearista/gemini-researcher 是什么?

无状态 MCP server,可将 research queries 代理到 Gemini CLI,从而减少 agent context 与 model usage。

相关 Skills

技能搜索

by daymade

Universal
热门

通过CCPM直接搜索、查看、安装、更新和卸载Claude Code Skill,适合查找PDF、代码审查等场景插件,也能列出已装Skill并自动执行命令返回结果。

想给Claude Code找对技能时,用它能一站式搜索、安装和管理CCPM注册表里的能力,省去到处翻找的时间。

搜索与获取
未扫描1.4k

深度研究

by daymade

Universal
热门

围绕既定模板拆题、多轮检索、整理证据表并交叉校验引用,产出格式严格、可追溯的研究报告,适合市场调研、竞品分析、政策追踪等高要求写作任务

把网页搜索、信息检索和研究分析串成一条链路,适合需要快速汇总线索、做深度判断的开发与研究工作。

搜索与获取
未扫描1.4k

标准研究员

by levnikolaevich

Universal

基于项目技术栈和 Epic/Story 需求,用 MCP Ref 检索相关 RFC、行业标准与架构模式,整理成可直接写入 Story Technical Notes 的研究结论与参考链接。

做技术方案时先让标准研究员帮你查标准与设计模式,基于 MCP Ref 产出可复用的技术注释研究,省下大量检索整理时间。

搜索与获取
未扫描559

相关 MCP Server

网页抓取

编辑精选

by Anthropic

热门

Fetch 是 MCP 官方参考服务器,让 AI 能抓取网页并转为 Markdown 格式。

这个服务器解决了 AI 直接处理网页内容时格式混乱的问题,适合需要让 Claude 分析在线文档或新闻的开发者。不过作为参考实现,它缺乏生产级的安全配置,你得自己处理反爬虫和隐私风险。

搜索与获取
89.8k

Brave 搜索

编辑精选

by Anthropic

热门

Brave Search 是让 Claude 直接调用 Brave 搜索 API 获取实时网络信息的 MCP 服务器。

如果你想让 AI 助手帮你搜索最新资讯或技术文档,这个工具能绕过传统搜索的限制,直接返回结构化数据。特别适合需要实时信息的开发者,比如查 API 更新或竞品动态。不过它依赖 Brave 的 API 配额,高频使用可能受限。

搜索与获取
89.7k

by Anthropic

热门

Puppeteer 是让 Claude 自动操作浏览器进行网页抓取和测试的 MCP 服务器。

这个服务器解决了手动编写 Puppeteer 脚本的繁琐问题,适合需要自动化网页交互的开发者,比如抓取动态内容或做端到端测试。不过,作为参考实现,它可能缺少生产级的安全防护,建议在可控环境中使用。

搜索与获取
89.2k

评论