# Google SERP & AI Agent Search Intelligence Pro (`meanusarcanus/google-serp-extractor-1`) Actor

Extract Google organic rankings, People Also Ask (PAA) queries, and sponsored ads with zero rate-limit blocks. Token-optimized Markdown for AI agents & LLMs. Just $2.49/1k results (45% cheaper)!

- **URL**: https://apify.com/meanusarcanus/google-serp-extractor-1.md
- **Developed by:** [Meanus Arcanus](https://apify.com/meanusarcanus) (community)
- **Categories:**
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 1 bookmarks
- **User rating**: No ratings yet

## Pricing

from $2.49 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

Actors are web data automations that power AI and operations. They run on the Apify platform to scrape websites, process data, connect APIs, and automate workflows.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.
Actors are written with capital "A".

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.
The best way to integrate Actors is as follows.

- **AI agents and MCP clients** — the [Apify MCP server](https://docs.apify.com/integrations/mcp.md) at `https://mcp.apify.com` (remote, streamable HTTP, OAuth on first use).
- **Agentic workflows and local Actor development** — [Agent Skills](https://apify.com/.well-known/agent-skills/index.json) with the [Apify CLI](https://docs.apify.com/cli/docs.md): `npm install -g apify-cli`, then `apify login`.
- **JavaScript/TypeScript projects** — the official [JS/TS client](https://docs.apify.com/api/client/js/docs.md): `npm install apify-client`.
- **Python projects** — the official [Python client](https://docs.apify.com/api/client/python/docs.md): `pip install apify-client`.
- **Any other language** — the [REST API](https://docs.apify.com/api/v2.md).

For usage examples, see the [API](#api) section below.

For more details, see Apify documentation as [Markdown index](https://docs.apify.com/llms.txt) and [Markdown full-text](https://docs.apify.com/llms-full.txt).

# README

## 🤖 Google SERP & AI Agent Grounding — Model Context Protocol (MCP) Server

[![MCP Protocol](https://img.shields.io/badge/MCP-Model_Context_Protocol-blue.svg)](https://modelcontextprotocol.io/)
[![Python 3.8+](https://img.shields.io/badge/Python-3.8+-blue.svg)](https://www.python.org/)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)
[![Glama](https://img.shields.io/badge/Glama-MCP_Server-purple.svg)](https://glama.ai/mcp/servers)

A high-performance **Model Context Protocol (MCP) Server** and live Google search grounding engine for **Claude Desktop, Cursor IDE, LangChain, and Autonomous AI Agents**.

<p align="center">
  <img src="https://raw.githubusercontent.com/meanusarcanus/google-serp-extractor/master/assets/logo.jpg" alt="Google SERP MCP Server Logo" width="180" style="border-radius: 24px;" />
</p>

***

### ⚡ Overview

This repository provides a standardized **Model Context Protocol (MCP)** server (`mcp_server.py`) that equips LLMs and autonomous agents with real-time web search and webpage content extraction without hallucination.

- 🛡️ **Zero 429 Rate-Limit Blocks**: Automatic anti-blocking engine with multi-engine fallback.
- 🤖 **LLM-Optimized Grounding**: Returns token-budgeted Markdown context with structured citations (`[1]`, `[2]`).
- 📄 **Universal Markdown Extractor**: Strips navigation, ads, and scripts from any URL to produce dense Markdown for RAG context windows.
- 🔌 **Zero-Config MCP Integration**: Plug-and-play with Claude Desktop, Cursor, and Antigravity.

***

### 🛠️ MCP Tools & Capabilities

The server exposes the following Model Context Protocol (MCP) tools:

| Tool Name | Parameters | Description |
| :--- | :--- | :--- |
| **`search_google_agent`** | `query` *(string)*, `max_results` *(int)*, `max_tokens` *(int)*, `country_code` *(string)* | Searches Google and returns token-optimized Markdown context with structured citations (`[1]`, `[2]`) specifically formatted for LLM system prompts and RAG grounding. |
| **`extract_webpage_markdown`** | `url` *(string)*, `max_chars` *(int)* | Fetches any live URL, strips boilerplate/ads/navbars, and converts the page into clean Markdown text for LLM ingestion. |

***

### 🔌 Quickstart: Connect to Claude Desktop & Cursor

#### 1. Claude Desktop Configuration

Add this server to your `claude_desktop_config.json`:

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

```json
{
  "mcpServers": {
    "google-serp-agent": {
      "command": "python3",
      "args": [
        "/path/to/google-serp-extractor/mcp_server.py"
      ]
    }
  }
}
```

#### 2. Cursor IDE Configuration (`.cursor/mcp.json`)

```json
{
  "mcpServers": {
    "google-serp-agent": {
      "command": "python3",
      "args": ["/path/to/google-serp-extractor/mcp_server.py"]
    }
  }
}
```

***

### 📦 Python SDK & LangChain Tool Usage

You can also use this library directly inside Python scripts and LangChain agents:

```bash
pip install google-serp-extractor
```

```python
from google_serp_extractor import agent_search_and_ground, extract_webpage_markdown

## 1. Ground your LLM with real-time web search facts
result = agent_search_and_ground(
    query="Latest breakthroughs in Quantum Computing 2026",
    max_results=3,
    max_tokens=1500
)

## Feed context directly into your LLM prompt
print(result["context_markdown"])

## 2. Extract clean Markdown from any live URL
page_md = extract_webpage_markdown("https://en.wikipedia.org/wiki/Artificial_intelligence")
print(page_md["markdown"][:500])
```

***

### 🌐 Serverless REST API Endpoints

| Method | Endpoint | Description |
| :--- | :--- | :--- |
| `POST` | `/api/v1/agent/search` | AI Agent search with token budgeting and citation formatting (Tavily/Exa alternative). |
| `POST` | `/api/v1/agent/extract` | Universal URL-to-Markdown extractor for RAG pipelines. |
| `POST` | `/api/v1/search` | Raw Google SERP batch search with organic rankings, PAA, and ads. |
| `GET` | `/api/v1/health` | Service health status and supported agent capabilities. |

***

### 📄 License

MIT License. Created by Meanus Arcanus.

# Actor input Schema

## `search_queries` (type: `array`):

Provide target search keywords or topics to query Google SERPs. Enter one search term per line or pass as an array.

## `page_depth` (type: `integer`):

Number of SERP pagination pages to extract per query (1 to 5).

## `country_code` (type: `string`):

Two-letter ISO country code for geo-location (e.g. us, ph, uk, ca, th, de).

## `language_code` (type: `string`):

Two-letter ISO language code (e.g. en, es, fr, th, de).

## `include_paa` (type: `boolean`):

Extract related question blocks and answer snippets.

## `include_paid_ads` (type: `boolean`):

Extract sponsored Google Ads and destination URLs.

## Actor input object example

```json
{
  "search_queries": [
    "What are the top 5 CRM tools",
    "Best Python web scraping frameworks"
  ],
  "page_depth": 1,
  "country_code": "us",
  "language_code": "en",
  "include_paa": true,
  "include_paid_ads": true
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "search_queries": [
        "What are the top 5 CRM tools",
        "Best Python web scraping frameworks"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("meanusarcanus/google-serp-extractor-1").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "search_queries": [
        "What are the top 5 CRM tools",
        "Best Python web scraping frameworks",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("meanusarcanus/google-serp-extractor-1").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "search_queries": [
    "What are the top 5 CRM tools",
    "Best Python web scraping frameworks"
  ]
}' |
apify call meanusarcanus/google-serp-extractor-1 --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,meanusarcanus/google-serp-extractor-1"
        }
    }
}

```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/AaWXxe1UzNoHskEPu/builds/YiEJxOHaaZ9AOWQwj/openapi.json
