The Model Context Protocol (MCP), open-sourced by Anthropic, has emerged as the standard for connecting AI coding assistants and desktop agents to external tools. Modern developer environments—including Cursor, Claude Desktop, Cline (VS Code), and Zed—use MCP to let language models discover and invoke external tools autonomously.

While local file editing and terminal commands are built into these environments, real-time web search is often missing or gated behind slow browser scrapers. When you ask your IDE about recent API deprecations, new package releases, or current documentation, the LLM either hallucinates or fails.

This guide walks through implementing a standalone, production-grade MCP search server that connects your AI IDE directly to Google and Bing via Serqo, using local stdio transport with sub-second response times and zero browser overhead.

Architecture: How MCP Search Works in AI IDEs

Layer Component Protocol / Transport Responsibility
Host Cursor / Claude Desktop / Cline JSON-RPC 2.0 via stdio Discovers tools via tools/list and initiates tool calls based on user prompt.
MCP Server Local TypeScript Process HTTPS POST to Serqo API Receives tool call arguments, queries Serqo, and slices organic results into clean prompt context.
Gateway Serqo Search Engine (serqo.io) Managed Residential Proxies Rotates residential IPs, solves CAPTCHAs, and parses Google/Bing into normalized JSON.

Token Economics: Browser Scraping vs. Serqo MCP

Search Strategy Context Consumed Retrieval Latency Failure Modes
Puppeteer / Playwright Scraping 20,000 – 60,000 tokens 4,000 – 10,000 ms IP blocks, CAPTCHAs, high CPU overhead
Raw Unfiltered SERP Scrapers 3,000 – 8,000 tokens 1,500 – 3,500 ms DOM layout bloat, CSS class noise
Serqo MCP Search Tool 150 – 350 tokens 400 – 800 ms Zero browser dependencies, clean text slicing

Standalone MCP Server Implementation (TypeScript)

Below is the complete, single-file MCP server using the official @modelcontextprotocol/sdk. It registers a search_web tool that executes structured searches against Serqo:

1. Project Setup

mkdir -p serqo-mcp-server && cd serqo-mcp-server
npm init -y
npm install @modelcontextprotocol/sdk zod
npm install -D typescript @types/node tsx
npx tsc --init

2. Server Source Code (server.ts)

import { Server } from "@modelcontextprotocol/sdk/server/index.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import {
  CallToolRequestSchema,
  ListToolsRequestSchema,
} from "@modelcontextprotocol/sdk/types.js";

const SERP_API_KEY = process.env.SERP_API_KEY;
if (!SERP_API_KEY) {
  console.error("Fatal: SERP_API_KEY environment variable is required.");
  process.exit(1);
}

const server = new Server(
  {
    name: "serqo-search-server",
    version: "1.0.0",
  },
  {
    capabilities: {
      tools: {},
    },
  }
);

// Register available tools
server.setRequestHandler(ListToolsRequestSchema, async () => {
  return {
    tools: [
      {
        name: "search_web",
        description:
          "Perform real-time Google or Bing web search for technical documentation, library release notes, error messages, and current facts.",
        inputSchema: {
          type: "object",
          properties: {
            query: {
              type: "string",
              description: "The search query (e.g. 'Node.js 22 LTS fetch changes')",
            },
            engine: {
              type: "string",
              enum: ["google", "bing"],
              default: "google",
              description: "Search engine provider to use.",
            },
            num: {
              type: "number",
              default: 5,
              description: "Number of top organic results to retrieve (1-10).",
            },
          },
          required: ["query"],
        },
      },
    ],
  };
});

// Tool execution handler
server.setRequestHandler(CallToolRequestSchema, async (request) => {
  if (request.params.name !== "search_web") {
    throw new Error(`Unknown tool: ${request.params.name}`);
  }

  const { query, engine = "google", num = 5 } = request.params.arguments as {
    query: string;
    engine?: "google" | "bing";
    num?: number;
  };

  try {
    const res = await fetch("https://serqo.io/v1/search", {
      method: "POST",
      headers: {
        "x-api-key": SERP_API_KEY,
        "Content-Type": "application/json",
      },
      body: JSON.stringify({
        engine,
        q: query,
        gl: "us",
        hl: "en",
      }),
    });

    if (!res.ok) {
      const errText = await res.text();
      return {
        content: [
          {
            type: "text",
            text: `Serqo API error HTTP ${res.status}: ${errText}`,
          },
        ],
        isError: true,
      };
    }

    const payload = await res.json();
    const results = (payload?.data?.results || []).slice(0, 5);

    if (results.length === 0) {
      return {
        content: [
          {
            type: "text",
            text: `No search results found for query: "${query}".`,
          },
        ],
      };
    }

    // Format clean, token-efficient context for the LLM
    const formattedResults = results.map((item: any, idx: number) => {
      return `[${idx + 1}] ${item.title}\nURL: ${item.url}\nSummary: ${item.snippet || "No description provided."}`;
    }).join("\n\n");

    return {
      content: [
        {
          type: "text",
          text: `Found ${results.length} results for "${query}":\n\n${formattedResults}`,
        },
      ],
    };
  } catch (err: any) {
    return {
      content: [
        {
          type: "text",
          text: `Failed to execute search: ${err.message || String(err)}`,
        },
      ],
      isError: true,
    };
  }
});

// Start listening via standard I/O
async function run() {
  const transport = new StdioServerTransport();
  await server.connect(transport);
}

run().catch((err) => {
  console.error("Server crashed:", err);
  process.exit(1);
});

Configuring Cursor, Claude Desktop & Cline

1. Cursor IDE Configuration

Add the server to your workspace's .cursor/mcp.json or global Cursor MCP settings:

{
  "mcpServers": {
    "serqo-search": {
      "command": "npx",
      "args": ["-y", "tsx", "/ABSOLUTE/PATH/TO/serqo-mcp-server/server.ts"],
      "env": {
        "SERP_API_KEY": "YOUR_SERQO_API_KEY"
      }
    }
  }
}

2. Claude Desktop Configuration

Edit your local claude_desktop_config.json:

{
  "mcpServers": {
    "web-search": {
      "command": "npx",
      "args": ["-y", "tsx", "/ABSOLUTE/PATH/TO/serqo-mcp-server/server.ts"],
      "env": {
        "SERP_API_KEY": "YOUR_SERQO_API_KEY"
      }
    }
  }
}

3. Cline (VS Code Extension)

Open the Cline extension settings → MCP Servers → Configure MCP Servers, and paste the JSON configuration block shown above. Once saved, Cline will automatically detect the search_web tool.

Production Boundaries & Error Handling

Continue reading