Search MCP Server

Search MCP Server

A Model Context Protocol (MCP) server for integrating Google Search capabilities into AI applications.

Category
访问服务器

README

Search MCP Server

A Model Context Protocol (MCP) server for integrating Google Search capabilities into AI applications

🤖 Native Claude Desktop integration - Use Google search directly in Claude!


Language / 语言: English | 中文


⚠️ Disclaimer

This project is for educational and research purposes only. It is a personal tool designed to help developers integrate search capabilities into their AI applications. Users are responsible for ensuring their use complies with applicable terms of service and applicable laws and regulations.

Important:

  • This is NOT an official product of any search engine
  • This is NOT affiliated with or endorsed by any search provider
  • Google and Google Search are trademarks of Google LLC. This project is independent and not endorsed by or affiliated with Google.
  • Users must comply with Google's Terms of Service
  • Users must comply with Google's Automated Query Guidelines
  • Respect rate limits and robots.txt
  • Use at your own risk

Features

  • Google Search Integration - Leverage Google's powerful search engine
  • MCP Protocol Support - Native Claude Desktop integration via Model Context Protocol
  • REST API - Standard HTTP interface for web applications
  • Localized Search - Geographic location-based search results
  • Session Management - Cookie-based session persistence
  • Rate Limiting - Built-in request throttling for responsible use
  • Smart Retry - Automatic recovery with exponential backoff

Quick Start

Prerequisites

  • Node.js 18+
  • npm or yarn

Installation

# Clone repository
git clone https://github.com/CodeMK/search-mcp.git
cd search-mcp

# Install dependencies
npm install

# Install Playwright browser
npx playwright install chromium

# Copy environment config
cp .env.example .env

# Build the project
npm run build

Choose Your Mode

This project supports two modes - choose based on your use case:

🤖 MCP Server Mode (Recommended for Claude Desktop)

Perfect for AI-assisted development with Claude Desktop:

search-mcp mcp

Then configure Claude Desktop following the MCP Setup Guide below.

🌐 REST API Mode (For Web Applications)

Traditional HTTP API for web applications:

search-mcp start

Server runs on http://localhost:3000/api/search


🤖 Claude Desktop Setup

Step 1: Find Config File

Windows:

%APPDATA%\Claude\claude_desktop_config.json

macOS:

~/Library/Application Support/Claude/claude_desktop_config.json

Step 2: Add Configuration

{
  "mcpServers": {
    "search": {
      "command": "node",
      "args": ["D:\\search-mcp\\dist\\mcp-server.js"],
      "env": {
        "HEADLESS": "true",
        "LOG_LEVEL": "info"
      }
    }
  }
}

Important: Replace D:\\search-mcp with your actual project path. On macOS/Linux, use forward slashes: /path/to/search-mcp/dist/mcp-server.js

Step 3: Restart Claude Desktop

Completely quit and restart Claude Desktop.

Step 4: Test

In Claude Desktop, type:

Please use search to find "TypeScript tutorial"

API Usage

REST API Endpoint

curl -X POST http://localhost:3000/api/search \
  -H "Content-Type: application/json" \
  -d '{"query": "TypeScript", "region": "US"}'

MCP Tool (Claude Desktop)

Available as the search tool in Claude Desktop conversations.

Request Parameters:

Param Type Required Default Description
query string - Search keyword
region string auto Country code (US, JP, GB, CN, etc.)
numResults number 10 Number of results

Response Example:

{
  "statusCode": 200,
  "result": {
    "success": true,
    "meta": {
      "regionCode": "US",
      "regionName": "United States",
      "resultCount": 5,
      "latency": 15000
    },
    "results": [
      {
        "rank": 1,
        "title": "TypeScript: JavaScript with syntax for types",
        "link": "https://www.typescriptlang.org/",
        "snippet": "TypeScript is a strongly typed programming language..."
      }
    ]
  }
}

Configuration

Environment Variables

# Server Configuration
PORT=3000                    # REST API server port
HOST=0.0.0.0                 # Server host
LOG_LEVEL=info               # Log level

# Browser Configuration
HEADLESS=true                # Headless mode
DEVTOOLS=false               # Enable DevTools
SLOW_MO=0                    # Slow motion (ms)

# Search Configuration
DEFAULT_REGION=US            # Default region
MAX_RESULTS=10               # Max results per search

Responsible Use

Rate Limiting

To ensure respectful and responsible use:

  • Min Delay: 15 seconds between requests
  • Max Delay: 30 seconds between requests
  • Burst Limit: Max 2 requests per 3 minutes

Best Practices

  1. Respect robots.txt - Follow website guidelines
  2. Limit request frequency - Don't overload servers
  3. Use for legitimate purposes - Educational and research only
  4. Comply with Google ToS - Follow Google's Terms of Service
  5. Avoid automated queries - Respect Google's Automated Query Guidelines

Project Structure

search-mcp/
├── src/
│   ├── mcp-server.ts      # MCP server entry point
│   ├── index.ts           # REST API entry point
│   ├── cli.ts             # CLI tool entry point
│   ├── api/               # REST API routes
│   ├── services/          # Core business logic
│   ├── engines/           # Browser automation
│   ├── utils/             # Utilities
│   └── config/            # Configuration
├── dist/                  # Compiled output
├── data/                  # Runtime data (cookies)
├── logs/                  # Application logs
└── scripts/               # Utility scripts

Development

npm run dev          # REST API development mode
npm run dev:mcp      # MCP server development mode
npm run build        # Build TypeScript
npm run start        # Production REST API mode
npm run start:mcp    # Production MCP mode
npm run test         # Run tests

Documentation

  • 📘 MCP_GUIDE.md - Complete MCP setup and usage guide
  • 🍪 Cookie Management - See MCP_GUIDE.md
  • 📝 Development Guide - See MCP_GUIDE.md

Troubleshooting

Claude Desktop Cannot Connect

  1. ✅ Build project: npm run build
  2. ✅ Check config: Ensure path to mcp-server.js is correct
  3. ✅ Check dependencies: npm install
  4. ✅ Restart Claude Desktop completely

CAPTCHA Detected

  1. Set HEADLESS=false in .env
  2. Restart the server
  3. Complete CAPTCHA manually in browser
  4. Cookies will be saved for future use

Connection Closed

  • Wait 3-5 minutes before retrying
  • System has automatic retry mechanism
  • Check if burst limit was triggered

Legal & Ethics

Compliance

Users of this project must:

Prohibited Uses

  • ❌ Commercial exploitation without permission
  • ❌ Spam or abuse of services
  • ❌ Violating intellectual property rights
  • ❌ Bypassing security measures for malicious purposes
  • ❌ Violating Google's Terms of Service or automated query policies

License

MIT License - See LICENSE file for details


Contributing

Contributions are welcome! Please:

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Submit a pull request

Acknowledgments


Resources


Note: This is a personal project for learning purposes. It is not affiliated with, endorsed by, or sponsored by any search provider or other company.

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选