一个使用 Search1API 提供搜索和爬取功能的模型上下文协议 (MCP) 服务器。
克隆仓库:
git clone https://github.com/fatwang2/search1api-mcp.git
cd search1api-mcp

配置 API 密钥: 在构建之前,您需要提供您的 Search1API 密钥。请参阅下面的设置指南部分,了解不同的方法(例如,使用 .env
文件或环境变量)。
安装依赖并构建:
npm install npm run build
注意:如果使用项目的 .env
文件方法来配置 API 密钥,请确保在执行此步骤之前该文件已经存在。
确保您的 API 密钥已配置(请参阅设置指南)。
启动服务器:
npm start
然后服务器将准备好接受来自 MCP 客户端的连接。
您需要让服务器能够访问您的 API 密钥。请选择以下一种方法:
方法 A:项目 .env
文件(推荐用于独立或 LibreChat)
如果您正在与当前版本的 LibreChat 集成,则需要使用此方法(请参见下面的具体部分)。
search1api-mcp
项目的根目录下创建一个名为 .env
的文件:# 在 search1api-mcp 目录中
echo "SEARCH1API_KEY=your_api_key_here" > .env

your_api_key_here
替换为您的实际密钥。npm install && npm run build
之前该文件已经存在。方法 B:环境变量(仅限独立)
在启动服务器之前设置 SEARCH1API_KEY
环境变量。
export SEARCH1API_KEY="your_api_key_here"
npm start

方法 C:MCP 客户端配置(高级)
某些 MCP 客户端允许在其配置中直接指定环境变量。这对于像 Cursor、VS Code 扩展等客户端非常有用。
{
"mcpServers": {
"search1api": {
"command": "npx",
"args": [
"-y",
"search1api-mcp"
],
"env": {
"SEARCH1API_KEY": "YOUR_SEARCH1API_KEY"
}
}
}
}

LibreChat 用户注意事项: 由于 LibreChat 当前的限制,方法 A(项目 .env
文件)是必需的方法。请参阅下面的专用集成部分以获取完整说明。
本节详细介绍了通过 Docker 与 LibreChat 集成所需的步骤。
概述:
docker-compose.yml
可访问的位置。.env
文件方法在此服务器目录内配置所需的 API 密钥。librechat.yaml
告诉 LibreChat 如何运行此服务器。逐步操作:
Clone the Repository:
Navigate to the directory on your host machine where you manage external services for LibreChat (this is often alongside your docker-compose.yml
). A common location is a dedicated mcp-server
directory.
# Example: Navigate to where docker-compose.yml lives, then into mcp-server
cd /path/to/your/librechat/setup/mcp-server
git clone https://github.com/fatwang2/search1api-mcp.git

Navigate into the Server Directory:
cd search1api-mcp

Configure API Key (Project .env
File Method - Required for LibreChat):
# Create the .env file
echo "SEARCH1API_KEY=your_api_key_here" > .env
# IMPORTANT: Replace 'your_api_key_here' with your actual Search1API key

Install Dependencies and Build:
This step compiles the server code into the build
directory.
npm install npm run build
Configure librechat.yaml
:
Edit your main librechat.yaml
file to tell LibreChat how to execute this MCP server. Add an entry under mcp_servers
:
# In your main librechat.yaml
mcp_servers:
# You can add other MCP servers here too
search1api:
# Optional: Display name for the server in LibreChat UI
# name: Search1API Tools
# Command tells LibreChat to use 'node'
command: node
# Args specify the script for 'node' to run *inside the container*
args:
- /app/mcp-server/search1api-mcp/build/index.js

args
path (/app/...
) is the location inside the LibreChat API container where the built server will be accessed (thanks to the volume bind in the next step).Configure Docker Volume Bind:
Edit your docker-compose.yml
(or more likely, your docker-compose.override.yml
) to map the search1api-mcp
directory from your host machine into the LibreChat API container. Find the volumes:
section for the api:
service:
# In your docker-compose.yml or docker-compose.override.yml
services:
api:
# ... other service config ...
volumes:
# ... other volumes likely exist here ...
# Add this volume bind:
- ./mcp-server/search1api-mcp:/app/mcp-server/search1api-mcp

./mcp-server/search1api-mcp
): This is the path on your host machine relative to where your docker-compose.yml
file is located. Adjust it if you cloned the repo elsewhere.:/app/mcp-server/search1api-mcp
): This is the path inside the container. It must match the directory structure used in the librechat.yaml
args
path.Restart LibreChat:
Apply the changes by rebuilding (if you modified docker-compose.yml
) and restarting your LibreChat stack.
docker compose down && docker compose up -d --build
# Or: docker compose restart api (if only librechat.yaml changed)

现在,Search1API 服务器应该作为工具提供者在 LibreChat 中可用。
search
query
(必需): 自然语言的搜索查询。请具体且简洁以获得更好的结果max_results
(可选, 默认: 10): 返回的结果数量search_service
(可选, 默认: "google"): 使用的搜索服务 (google, bing, duckduckgo, yahoo, x, reddit, github, youtube, arxiv, wechat, bilibili, imdb, wikipedia)crawl_results
(可选, 默认: 0): 需要爬取完整网页内容的结果数量include_sites
(可选): 要包含在搜索中的网站列表exclude_sites
(可选): 要从搜索中排除的网站列表time_range
(可选): 搜索结果的时间范围 ("day", "month", "year")news
query
(必需): 自然语言的搜索查询。请具体且简洁以获得更好的结果max_results
(可选, 默认: 10): 返回的结果数量search_service
(可选, 默认: "bing"): 使用的搜索服务 (google, bing, duckduckgo, yahoo, hackernews)crawl_results
(可选, 默认: 0): 需要爬取完整网页内容的结果数量include_sites
(可选): 要包含在搜索中的网站列表exclude_sites
(可选): 要从搜索中排除的网站列表time_range
(可选): 搜索结果的时间范围 ("day", "month", "year")crawl
url
(必需): 要爬取的 URLsitemap
url
(必需): 要获取站点地图的 URLreasoning
content
(必需): 需要深度思考的问题或难题trending
search_service
(必需): 指定要从中获取热门话题的平台 (github, hackernews)max_results
(可选, 默认: 10): 返回的最大热门条目数.env
支持,并更新了依赖项。本项目采用MIT许可证 - 详情请参阅LICENSE文件。