serper-search
A Model Context Protocol server that enables web searching using the Serper API for Google search results, with optional web page content fetching.
README
Serper Search MCP Server
A Model Context Protocol (MCP) server that enables web searching using the Serper API for Google search results.
Features
- Search the web using Serper API for Google search results
- Requires Serper API key for authentication
- Returns structured results with titles, URLs, and descriptions
- Fetches and includes actual web page content for each result
- Configurable number of results per search
- Supports streamable-http transport for LibreChat integration
- Docker containerization support
- Health checks and monitoring
- Built-in rate limiting to respect API limits
Installation
- Clone or download this repository
- Install dependencies:
npm install
- Build the server:
npm run build
Usage Modes
Local Development (Stdio Mode)
For local development and direct MCP client integration:
npm start
Add the server to your MCP configuration:
For VSCode (Claude Dev Extension):
{
"mcpServers": {
"web-search": {
"command": "node",
"args": ["/path/to/web-search/build/index.js"]
}
}
}
For Claude Desktop:
{
"mcpServers": {
"web-search": {
"command": "node",
"args": ["/path/to/web-search/build/index.js"]
}
}
}
HTTP Mode (Container-Ready)
For containerized deployments or LibreChat integration:
# Start in HTTP mode
npm run start:http
# or
node build/index.js --http
# or set environment variable
MCP_HTTP_MODE=true npm start
The server will expose:
- MCP endpoint:
http://localhost:3000/mcp(for JSON-RPC 2.0 requests) - Health endpoint:
http://localhost:3000/health - Health check:
http://localhost:3000/health
Docker Deployment
Using Docker directly:
# Build the image
npm run docker:build
# Run the container
npm run docker:run
Or manually:
docker build -t web-search-mcp .
docker run -p 3000:3000 -e MCP_HTTP_MODE=true web-search-mcp
Using Docker Compose:
# Start the service
npm run docker:up
# View logs
npm run docker:logs
# Stop the service
npm run docker:down
Container Configuration
Environment variables:
MCP_HTTP_MODE: Set totrueto enable HTTP/SSE modePORT: Port number (default: 3000)SEARCH_RATE_LIMIT_MS: Minimum milliseconds between search requests (default: 500)
The container includes:
- Health checks
- Non-root user execution
- CORS support
- Automatic restart policies
Rate Limiting
The server includes built-in rate limiting to be respectful to Google's servers:
- Default: Minimum 500ms between search requests
- Configurable: Set
SEARCH_RATE_LIMIT_MSenvironment variable - Automatic: If requests come in faster than the limit, the server will automatically wait
- Logging: Rate limiting events are logged to stderr
Example with custom rate limit:
# Set 1 second minimum between searches
SEARCH_RATE_LIMIT_MS=1000 npm run start:http
API Reference
Tool: search
Parameters:
{
"query": string, // The search query
"limit": number, // Optional: Number of results to return (default: 5, max: 10)
"maxContentLength": number // Optional: Max length of content to extract (default: 50000)
}
Tool: fetch_page_content
Parameters:
{
"url": string, // The URL of the web page to fetch
"maxContentLength": number // Optional: Max length of content to extract (default: 50000)
}
HTTP/SSE API
Health Check
GET /health
Returns:
{
"status": "ok",
"service": "web-search-mcp"
}
SSE Connection
GET /sse
Establishes Server-Sent Events connection for real-time communication.
Message Endpoint
POST /message
Content-Type: application/json
{
"jsonrpc": "2.0",
"id": "unique-id",
"method": "tools/call",
"params": {
"name": "search",
"arguments": {
"query": "your search query",
"limit": 5
}
}
}
Testing
A test client is included (test-client.html) for testing the HTTP/SSE endpoint. Open it in a browser and ensure the server is running in HTTP mode.
Example Usage
MCP Client (stdio mode):
use_mcp_tool({
server_name: "web-search",
tool_name: "search",
arguments: {
query: "your search query",
limit: 3
}
})
HTTP API (container mode):
const response = await fetch('http://localhost:3000/message', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
jsonrpc: "2.0",
id: "1",
method: "tools/call",
params: {
name: "search",
arguments: { query: "Model Context Protocol", limit: 5 }
}
})
});
Example response:
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"content": [
{
"type": "text",
"text": "[{\"title\":\"Example Result\",\"url\":\"https://example.com\",\"description\":\"Description...\"}]"
}
]
}
}
Fetch Page Content Tool
HTTP API Example
{
"jsonrpc": "2.0",
"id": "1",
"method": "tools/call",
"params": {
"name": "fetch_page_content",
"arguments": {
"url": "https://en.wikipedia.org/wiki/Model_Context_Protocol",
"maxContentLength": 10000
}
}
}
Example Response
{
"jsonrpc": "2.0",
"id": "1",
"result": {
"content": [
{
"type": "text",
"text": "[Cleaned web page content here...]"
}
]
}
}
Limitations
Since this tool uses web scraping of Google search results, there are some important limitations to be aware of:
-
Rate Limiting: Google may temporarily block requests if too many searches are performed in a short time. To avoid this:
- Keep searches to a reasonable frequency
- Use the limit parameter judiciously
- Consider implementing delays between searches if needed
-
Result Accuracy:
- The tool relies on Google's HTML structure, which may change
- Some results might be missing descriptions or other metadata
- Complex search operators may not work as expected
-
Legal Considerations:
- This tool is intended for personal use
- Respect Google's terms of service
- Consider implementing appropriate rate limiting for your use case
Contributing
Feel free to submit issues and enhancement requests!
License
This project is licensed under the MIT License. See the LICENSE file for details.
推荐服务器
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 模型以安全和受控的方式获取实时的网络信息。