agy-search

agy-search

Wraps the local agy CLI into an MCP server to provide a web_search tool that enables Claude Code to perform real internet searches through Gemini/Google.

Category
Visit Server

README

agy-search

把本机 agy(antigravity-cli,后端 Gemini,能真实联网搜索)包装成一个 stdio MCP server,向 Claude Code 暴露 web_search 工具。

为什么需要这个

Claude Code 接本地模型时,内置的 WebSearch 是 Anthropic 服务端工具,搜索由官方 API 后端执行——本地模型/代理不实现该工具,所以 WebSearch 会返回空结果(Did 0 searches),联网搜索能力缺失。

本项目通过 MCP 工具补齐这个缺口:Claude Code 调用 mcp__agy__web_search → server 内部 spawn agy 子进程 → agy 经 Gemini/Google 联网搜索 → 返回结果。

Claude Code ──(stdio JSON-RPC)──► MCP server(长驻)──(tools/call)──► spawn: agy --prompt ... --output-format json ──► Gemini/Google 搜索 ──► 解析 response 回传

前置要求

  • agy(antigravity-cli) 已安装并在 PATH 中,版本 ≥ 1.1.8
  • uv(Python 包管理器)
  • Python 3.14+

安装

git clone <repo-url> && cd agy-search
uv sync          # 安装依赖(fastmcp)

注册到 Claude Code

推荐全局注册(任意目录都可用),用项目 venv 的绝对路径:

claude mcp add agy -s user -- /<绝对路径>/agy-search/.venv/bin/agy-search

验证:

claude mcp list                 # 应列出 agy 且 ✔ Connected
claude mcp get agy              # Scope 应为 User config

注册后,Claude Code 内会出现工具 mcp__agy__web_search

使用

在 Claude Code 里直接问需要联网的问题即可,模型会自动调用 mcp__agy__web_search

今天有什么科技新闻?

工具签名:

web_search(query: str) -> str
  • query:搜索查询词(自然语言即可,agy 会自行联网检索)
  • 返回:agy 的答案文本(通常含来源)

可选:禁用不可用的内置 WebSearch

接本地模型时,内置 WebSearch 不可用却仍会被调用(白白浪费调用次数)。可在 ~/.claude/settings.jsonpermissions.deny 堵掉它,让搜索统一走 agy:

{
  "permissions": {
    "deny": ["WebSearch"]
  }
}

WebFetch 仍可用,用于抓取已知 URL,不必禁用。)

本地开发

# 跑 server(fastmcp CLI,file:object 格式导入 server 对象,默认 stdio)
uv run fastmcp run src/agy_search/__init__.py:mcp

# 或经 entry point
uv run agy-search

# 单独验证 agy 契约(不经 MCP)
agy --prompt "测试查询" --output-format json --print-timeout 90s

agy 调用契约(关键,有坑)

命令:agy --prompt "<查询>" --output-format json --print-timeout 90s

  • 一律用 --prompt 长选项,不用 -p(实测 -p 会返回 flag 解释而非执行任务)。
  • --print-timeout 默认 5m 太长,用 90s。
  • 返回 JSON 主用字段:response(答案文本)、status(SUCCESS/ERROR)、error
  • 成败判定不能只看 status:实测 status:"ERROR"response 仍可能含完整正确答案。判定逻辑——response 非空(trim 后)即成功并返回(忽略 status);response 空且 error 非空才算失败。
  • 失败时重试 1 次(应对 Eligibility check failed: EOF、SSE 断连等瞬时错误),仍失败则 raise ToolError(MCP 回 isError=True),server 不崩溃。

项目结构

src/agy_search/__init__.py   # 全部实现:FastMCP server + web_search 工具 + agy 调用 + 重试
pyproject.toml               # 依赖 fastmcp,entry point: agy-search = "agy_search:main"

逻辑内聚在单文件,无额外模块。待加第二个工具时再把 agy 调用逻辑抽成独立模块复用。

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured