mcpField
S
searchapi-mcp-server

searchapi-mcp-server

本地服务
github.com/Ahmednsh搜索与检索08 周前更新

关于 searchapi-mcp-server

searchapi-mcp-server 通过 SearchApi.io 为 LLM 客户端提供 Google 搜索、购物、职位和 YouTube 搜索。它将结果整理为精简的结构化文本,并在可用时优先呈现直接答案。

主要功能

  1. 01Google 网页搜索
  2. 02Google 购物搜索
  3. 03Google 职位搜索
  4. 04YouTube 搜索
  5. 05精简的结构化文本结果

适用场景

  1. 01查找问题相关的网页结果
  2. 02比较商品列表
  3. 03按地点搜索职位
  4. 04查找相关 YouTube 视频

MCP 相关

向 MCP 客户端提供四种由 SearchApi.io 支持的搜索工具:Google 搜索、Google 购物、Google 职位和 YouTube 搜索。

配置

本地服务的配置在各客户端中通用,复制后粘贴到客户端的 MCP 配置文件即可。

mcp.json · 通用配置
{
"mcpServers": {
"ahmednsh-searchapi": {
"command": "npx",
"args": [
"-y",
"@ahmednsh/searchapi-mcp-server"
],
"env": {
"SEARCHAPI_API_KEY": "<SEARCHAPI_API_KEY>"
}
}
}
}
启动命令npx -y @ahmednsh/searchapi-mcp-server
需要配置的环境变量
SEARCHAPI_API_KEY密钥SearchApi.io API key (create one at https://www.searchapi.io/)

本地服务需要在你的电脑上安装运行环境(如 Node.js 18+)。各客户端的配置文件位置不同,请参考客户端文档。

安装包
npm@ahmednsh/searchapi-mcp-server1.0.2

工具

4

收录的工具列表 · 更新于 2 周前

参数类型必填说明
qstring是搜索查询
glstring否用于本地化结果的两位国家代码(例如 us、sa)
hlstring否界面语言代码(例如 en、ar、zh-CN)
numinteger否要返回的自然搜索结果数量(1–20,默认值为 10)

详细介绍

searchapi-mcp-server

CI

npx @ahmednsh/searchapi-mcp-server

将 SearchApi.io 封装为四种工具的 MCP 服务:Google 搜索、Google 购物、Google 职位和 YouTube 搜索。结果以紧凑的结构化文本返回,专为大模型上下文设计——优先提供直接答案,不返回原始 JSON。

社区项目,与 SearchApi.io 无关联,也未获得其认可。 “SearchApi” 是其各自所有者的商标。

Claude Desktop 配置

在 searchapi.io 获取 API 密钥,然后将服务添加到 claude_desktop_config.json(Windows 上为 %AppData%\Claude\,macOS 上为 ~/Library/Application Support/Claude/):

{
  "mcpServers": {
    "searchapi": {
      "command": "npx",
      "args": ["-y", "@ahmednsh/searchapi-mcp-server"],
      "env": {
        "SEARCHAPI_API_KEY": "your-api-key"
      }
    }
  }
}

重启 Claude Desktop。四种工具会显示在“searchapi”服务下。

工具

google_search

q(必填)、num(1–20,默认值为 10)、gl(国家代码,例如 sa)、hl(语言代码,例如 ar)。

只要 Google 返回直接答案功能(答案框、知识图谱、AI 概览),就会将其置于自然搜索结果之前:

Search results for "capital of Saudi Arabia":

---

[Answer box]
Saudi Arabia Capital: Riyadh

---

1. Riyadh
   https://en.wikipedia.org/wiki/Riyadh
   Riyadh is the capital and largest city of Saudi Arabia. It is also the capital of the Riyadh Province and the centre of the Riyadh Governorate.
2. Riyadh | Population, Climate, Map, History, & Facts
   https://www.britannica.com/place/Riyadh
   Riyadh is Saudi Arabia's capital and largest city. It became the capital of the Saud dynasty in 1824 and, except for a brief period in the ...
google_shopping

q(必填)、gl(国家代码)、include_links(布尔值,默认值为 false)。

Shopping results for "wireless mouse" (showing 10 of 40):

1. Logitech M220 Silent Wireless Mouse
   $13.83 — Walmart — 4.8★ (44,000 reviews)
   Free 90-day returns
2. Logitech G305 Lightspeed Wireless Gaming Mouse
   $29.99 — Target — 4.6★ (8,100 reviews)
   30-day returns
google_jobs

q(必填)、location(例如 "Riyadh, Saudi Arabia")。

Job results for "software engineer" in "Riyadh, Saudi Arabia":

1. Senior Software Engineer - Backend — Delivery Hero
   Riyadh Saudi Arabia · via Delivery Hero
   No degree mentioned
   Apply: https://careers.deliveryhero.com/job/senior-software-engineer-backend-in-riyadh-saudi-arabia-jid-7417
   About the opportunity We are looking for a highly talented Senior Backend Engineer to join our Riyadh office. If you are looking for a place where ...
youtube_search

q(必填)。

YouTube results for "model context protocol tutorial":

1. Model Context Protocol Clearly Explained | MCP Beyond the Hype
   https://www.youtube.com/watch?v=tzrwxLNHtRY
   codebasics ✓ — 557,404 views — 15:04 — 1 year ago
   This video contains a very simple explanation of MCP, also known as Model Context Protocol. We will first understand what ...
2. What is MCP? Integrate AI Agents with Databases & APIs
   https://www.youtube.com/watch?v=eur8dUO9mvE
   IBM Technology ✓ — 684,035 views — 3:46 — 1 year ago
   Dive into the world of Model Context Protocol and learn how to seamlessly connect AI agents to databases, APIs, and more.

开发者须知

  • 错误语义: 工具执行失败(缺少或无效的密钥、HTTP 429/4xx/5xx、网络错误)时,会返回一条易读消息并设置 isError: true,让客户端和模型能够区分调用失败与搜索内容。“无结果”不是错误——空搜索也算成功,消息会提示模型更换关键词,而不是重试。
  • google_shopping 的 include_links 默认关闭,因为 Google 购物的商品链接是约 500 个字符的跟踪 URL,指向 Google 而非商家;结果会显示卖家名称。如有需要,请设置 include_links: true。
  • 输出上限: 每次调用最多返回 10 条结果(截断时,标题会显示 showing 10 of N);职位描述会移除 HTML,并截断至 250 个字符。
  • 布局: src/index.ts 用于注册工具并与 SearchApi 通信;src/format.ts 包含纯粹的响应转文本格式化函数,并在 src/format.test.ts 中进行单元测试(npm test)。

开发

git clone https://github.com/Ahmednsh/searchapi-mcp-server.git && cd searchapi-mcp-server && npm install && npm run build
npm test

许可证

MIT

评论

支持 Markdown

第一次接触 MCP?

从协议是什么,到在客户端里装上第一个服务,这几条回答覆盖了大多数入门问题。

一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。