Google Search MCP Server

by mixelpixx
Verified

local-only server

The server can only run on the client’s local machine because it depends on local resources.

Integrations

  • Provides Google search capabilities to AI models through an MCP server interface, allowing for advanced search queries with filtering options for date, language, country, and safe search

  • Integrates with Google Cloud Platform for API credentials and Custom Search capabilities needed to power the Google search functionality

Cline + VS Code で使用するために構築されました。

Google 検索 MCP サーバー

Google検索機能とウェブページコンテンツ分析ツールを提供するMCP(Model Context Protocol)サーバー。このサーバーにより、AIモデルはGoogle検索を実行し、ウェブページコンテンツをプログラムで分析できるようになります。

特徴

  • フィルタリング オプション(日付、言語、国、セーフサーチ)を備えた高度な Google 検索
  • 詳細なウェブページコンテンツの抽出と分析
  • 複数のソースを比較するためのバッチウェブページ分析
  • API 認証情報の環境変数サポート
  • 包括的なエラー処理とユーザーフィードバック
  • AIアシスタントとのシームレスな統合を実現するMCP準拠インターフェース

前提条件

  • Node.js (v16 以上)
  • Python (v3.8以上)
  • Google Cloud Platform アカウント
  • カスタム検索エンジンID
  • Google APIキー

インストール

  1. リポジトリをクローンします。
    git clone https://github.com/your-username/google-search-mcp.git cd google-search-mcp
  2. Node.js の依存関係をインストールします。
    npm install
  3. Python の依存関係をインストールします。
    pip install flask google-api-python-client flask-cors beautifulsoup4 trafilatura markdownify
  4. TypeScript コードをビルドします。
    npm run build
  5. Python サーバーを起動するためのヘルパー スクリプトを作成します (Windows の例):
    # Create start-python-servers.cmd @echo off echo Starting Python servers for Google Search MCP... REM Start Python search server start "Google Search API" cmd /k "python google_search.py" REM Start Python link viewer start "Link Viewer" cmd /k "python link_view.py" echo Python servers started. You can close this window.

構成

API認証情報

Google API 認証情報は、次の 2 つの方法で提供できます。

  1. 環境変数(推奨):
    • 環境にGOOGLE_API_KEYGOOGLE_SEARCH_ENGINE_IDを設定します
    • サーバーはこれらの値を自動的に使用します
  2. 設定ファイル:
    • ルートディレクトリにapi-keys.jsonファイルを作成します: GXP6

MCP設定の構成

MCP 設定ファイルにサーバー構成を追加します。

Cline(VS Code拡張機能)の場合

ファイルの場所: %APPDATA%\Code\User\globalStorage\saoudrizwan.claude-dev\settings\cline_mcp_settings.json

{ "mcpServers": { "google-search": { "command": "C:\\Program Files\\nodejs\\node.exe", "args": ["C:\\path\\to\\google-search-mcp\\dist\\google-search.js"], "cwd": "C:\\path\\to\\google-search-mcp", "env": { "GOOGLE_API_KEY": "your-google-api-key", "GOOGLE_SEARCH_ENGINE_ID": "your-custom-search-engine-id" }, "disabled": false, "autoApprove": [] } } }

Claudeデスクトップアプリ用

ファイルの場所: %APPDATA%\Claude\claude_desktop_config.json

{ "mcpServers": { "google-search": { "command": "C:\\Program Files\\nodejs\\node.exe", "args": ["C:\\path\\to\\google-search-mcp\\dist\\google-search.js"], "cwd": "C:\\path\\to\\google-search-mcp", "env": { "GOOGLE_API_KEY": "your-google-api-key", "GOOGLE_SEARCH_ENGINE_ID": "your-custom-search-engine-id" }, "disabled": false, "autoApprove": [] } } }

サーバーの実行

方法 1: Python サーバーを個別に起動する (推奨)

  1. まず、ヘルパー スクリプトを使用して Python サーバーを起動します。
    start-python-servers.cmd
  2. Node.js サーバーのみを実行するように MCP 設定を構成します。
    { "command": "C:\\Program Files\\nodejs\\node.exe", "args": ["C:\\path\\to\\google-search-mcp\\dist\\google-search.js"] }

方法2:オールインワンスクリプト

1 つのコマンドで TypeScript サーバーと Python サーバーの両方を起動します。

npm run start:all

利用可能なツール

Googleで検索し、ウェブから関連する結果を返します。このツールは、Googleの検索エンジンを使用して、特定のトピックに関するウェブページ、記事、情報を検索します。

{ "name": "google_search", "arguments": { "query": "your search query", "num_results": 5, // optional, default: 5, max: 10 "date_restrict": "w1", // optional, restrict to past day (d1), week (w1), month (m1), year (y1) "language": "en", // optional, ISO 639-1 language code (en, es, fr, de, ja, etc.) "country": "us", // optional, ISO 3166-1 alpha-2 country code (us, uk, ca, au, etc.) "safe_search": "medium" // optional, safe search level: "off", "medium", "high" } }

2. ウェブページのコンテンツを抽出する

ウェブページからコンテンツを抽出・分析し、読みやすいテキストに変換します。このツールは、広告、ナビゲーション要素、その他の不要な要素を削除しながら、メインコンテンツのみを取得します。

{ "name": "extract_webpage_content", "arguments": { "url": "https://example.com" } }

3. 複数のウェブページを抽出する

複数のウェブページからコンテンツを抽出し、単一のリクエストで分析します。異なるソース間で情報を比較したり、特定のトピックに関する包括的な情報を収集したりするのに最適です。

{ "name": "extract_multiple_webpages", "arguments": { "urls": [ "https://example1.com", "https://example2.com" ] } }

使用例

Google 検索 MCP ツールの使用方法の例をいくつか示します。

基本検索

Search for information about artificial intelligence

フィルターを使った高度な検索

Search for recent news about climate change from the past week in Spanish

コンテンツ抽出

Extract the content from https://example.com/article

複数のコンテンツの比較

Compare information from these websites: - https://site1.com/topic - https://site2.com/topic - https://site3.com/topic

Google API認証情報の取得

  1. Google Cloud Consoleにアクセスします
  2. 新しいプロジェクトを作成するか、既存のプロジェクトを選択してください
  3. カスタム検索APIを有効にする
  4. API 認証情報 (API キー) を作成する
  5. カスタム検索エンジンのページに移動します
  6. 新しい検索エンジンを作成し、検索エンジンIDを取得します
  7. これらの資格情報をapi-keys.jsonファイルに追加します

エラー処理

サーバーは、次の詳細なエラー メッセージを提供します。

  • API 認証情報が見つからないか無効です
  • 失敗した検索リクエスト
  • 無効なウェブページのURL
  • ネットワーク接続の問題

建築

サーバーは 2 つの主要コンポーネントで構成されています。

  1. TypeScript MCPサーバー: MCPプロトコル通信を処理し、ツールインターフェースを提供します
  2. Python Flask サーバー: Google API のインタラクションとウェブページのコンテンツ分析を管理します

ライセンス

マサチューセッツ工科大学

You must be authenticated.

A
security – no known vulnerabilities
F
license - not found
A
quality - confirmed to work

Google検索機能とウェブページコンテンツ分析ツールを提供するMCP(Model Context Protocol)サーバー。このサーバーにより、AIモデルはGoogle検索を実行し、ウェブページコンテンツをプログラムで分析できるようになります。

  1. Google Search MCP Server
    1. Features
    2. Prerequisites
    3. Installation
    4. Configuration
    5. Running the Server
    6. Available Tools
    7. Example Usage
    8. Getting Google API Credentials
    9. Error Handling
    10. Architecture
    11. License
ID: 8m8reyzrcd