Google Search MCP server

Integrates with Google Custom Search API and web scraping tools to enable web searches, content extraction, and analysis for research and data aggregation tasks.
Back to servers
Setup instructions
Provider
mixelpixx
Release date
Dec 19, 2024
Language
TypeScript
Package
Stats
925 downloads
83 stars

Google Search MCP Server is a powerful server that enables AI models to perform Google searches and analyze webpage content programmatically. It provides a standardized interface for searching the web, extracting content, and analyzing webpages through an MCP-compliant API.

Prerequisites

  • Node.js (v16 or higher)
  • Google Cloud Platform account
  • Custom Search Engine ID
  • Google API Key

Installation

  1. Clone the repository
  2. Install Node.js dependencies:
npm install
  1. Build the TypeScript code:
npm run build

Configuration

Set up Google API credentials

  1. Go to the Google Cloud Console
  2. Create a new project or select an existing one
  3. Enable the Custom Search API
  4. Create API credentials (API Key)
  5. Go to the Custom Search Engine page
  6. Create a new search engine and get your Search Engine ID

Configure environment variables

Set these as system environment variables or configure them in your MCP settings file:

  • GOOGLE_API_KEY: Your Google API key
  • GOOGLE_SEARCH_ENGINE_ID: Your Custom Search Engine ID

Add server configuration to MCP settings

Add the server configuration to your MCP settings file (typically located at %APPDATA%/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json):

{
  "mcpServers": {
    "google-search": {
      "autoApprove": [
        "google_search",
        "extract_webpage_content",
        "extract_multiple_webpages"
      ],
      "disabled": false,
      "timeout": 60,
      "command": "node",
      "args": [
        "/path/to/google-search-mcp-server/dist/google-search.js"
      ],
      "env": {
        "GOOGLE_API_KEY": "your-google-api-key",
        "GOOGLE_SEARCH_ENGINE_ID": "your-custom-search-engine-id"
      },
      "transportType": "stdio"
    }
  }
}

Running the Server

Start the MCP server:

npm run start

Available Tools

Google Search

Search Google and return relevant results from the web:

{
  "name": "google_search",
  "arguments": {
    "query": "your search query",
    "num_results": 5, // optional, default: 5
    "site": "example.com", // optional, limit results to specific website
    "language": "en", // optional, filter by language (ISO 639-1 code)
    "dateRestrict": "m6", // optional, filter by date (e.g., "m6" for last 6 months)
    "exactTerms": "exact phrase", // optional, search for exact phrase
    "resultType": "news", // optional, specify type (news, images, videos)
    "page": 2, // optional, page number for pagination (starts at 1)
    "resultsPerPage": 10, // optional, results per page (max: 10)
    "sort": "date" // optional, sort by "date" or "relevance" (default)
  }
}

The response includes:

  • Search results with title, link, and snippet in a readable format
  • Pagination information (current page, total results)
  • Categories of results (automatically detected)
  • Navigation hints for pagination

Extract Webpage Content

Extract and analyze content from a webpage:

{
  "name": "extract_webpage_content",
  "arguments": {
    "url": "https://example.com",
    "format": "markdown" // optional, format options: "markdown" (default), "html", or "text"
  }
}

The response includes:

  • Title and description of the webpage
  • Content statistics (word count, character count)
  • Content summary
  • Content preview (first 500 characters)

Extract Multiple Webpages

Extract and analyze content from multiple webpages in a single request:

{
  "name": "extract_multiple_webpages",
  "arguments": {
    "urls": [
      "https://example1.com",
      "https://example2.com"
    ],
    "format": "html" // optional, format options: "markdown" (default), "html", or "text"
  }
}

The response includes:

  • Title and description of each webpage
  • Content statistics for each webpage
  • Content summary for each webpage
  • Content preview for each webpage (first 150 characters)

Error Handling

The server provides detailed error messages for:

  • Missing or invalid API credentials
  • Failed search requests
  • Invalid webpage URLs
  • Network connectivity issues

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "google-search" '{"autoApprove":["google_search","extract_webpage_content","extract_multiple_webpages"],"disabled":false,"timeout":60,"command":"node","args":["/path/to/google-search-mcp-server/dist/google-search.js"],"env":{"GOOGLE_API_KEY":"your-google-api-key","GOOGLE_SEARCH_ENGINE_ID":"your-custom-search-engine-id"},"transportType":"stdio"}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "google-search": {
            "autoApprove": [
                "google_search",
                "extract_webpage_content",
                "extract_multiple_webpages"
            ],
            "disabled": false,
            "timeout": 60,
            "command": "node",
            "args": [
                "/path/to/google-search-mcp-server/dist/google-search.js"
            ],
            "env": {
                "GOOGLE_API_KEY": "your-google-api-key",
                "GOOGLE_SEARCH_ENGINE_ID": "your-custom-search-engine-id"
            },
            "transportType": "stdio"
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "google-search": {
            "autoApprove": [
                "google_search",
                "extract_webpage_content",
                "extract_multiple_webpages"
            ],
            "disabled": false,
            "timeout": 60,
            "command": "node",
            "args": [
                "/path/to/google-search-mcp-server/dist/google-search.js"
            ],
            "env": {
                "GOOGLE_API_KEY": "your-google-api-key",
                "GOOGLE_SEARCH_ENGINE_ID": "your-custom-search-engine-id"
            },
            "transportType": "stdio"
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later