[KongchangAI]
· 2 min read· 1,324 words

Connecting AI Coding Assistants to Real-Time Web Access with an MCP Server

Connecting AI Coding Assistants to Real-Time Web Access with an MCP Server

Connect a web scraping server via MCP so AI coding assistants can autonomously fetch real-time web information during tasks.

This article explains how to connect web data servers to coding assistants like Claude Code, Claude Desktop, and Cursor via the Model Context Protocol (MCP), solving the problem of LLM knowledge being frozen at the training cutoff and unable to perceive the latest web changes. Using the XCrawl MCP server as an example, it provides tools like scrape, search, map, and crawl, corresponding to single-page scraping, search discovery, site structure mapping, and batch collection. There are two connection methods: a hosted HTTP endpoint and a local stdio process—the former offers zero operations overhead and cross-client compatibility, while the latter keeps the key on your machine for easier auditing. The article also offers prompt-writing guidance and token control practices, such as preferring Markdown, mapping before crawling, replacing full-site crawls with targeted scrapes, and preserving source URLs.

Large language models' knowledge often stops at the moment their training data was cut off, while the content on web pages may have been updated just this morning. If you're using Claude Code, Claude Desktop, Cursor, or any other MCP-compatible client, you can connect to a web data server via the Model Context Protocol (MCP), letting the AI fetch real-time information on its own when needed. This article focuses on the practical value of this capability, how to configure it, and token usage efficiency.

MCP Fills the "Real-Time" Gap for Coding Assistants

AI coding assistants connected to real-time web access via MCP

MCP is an open protocol that allows AI clients to call external tools. A web scraping MCP server exposes tools like "scrape this URL" or "search the web," which the assistant can invoke autonomously when a task requires fresh information—looking up the latest docs for a library, verifying a changelog, comparing pricing pages, or collecting examples from a site. This addresses the most typical limitation of LLMs: the model itself has extensive knowledge but doesn't know what changed on a web page this morning. Giving the assistant real-time scraping capability is like adding a "on-site verification" method to its reasoning process, without relying on users to manually copy and paste web content.

MCP (Model Context Protocol) was proposed and open-sourced by Anthropic in late 2024, positioned as a universal interface layer between AI applications and external data sources and tools. It uses a client-server architecture: hosts like Claude Desktop and Cursor act as clients, communicating with one or more MCP servers via JSON-RPC; servers declare their capabilities as "tools," "resources," or "prompt templates," and clients discover and invoke them at runtime. Compared to writing a separate plugin for each service, MCP's value lies in a single implementation being reusable across all compatible clients—similar to how the Language Server Protocol (LSP) unified the relationship between editors and language tools. The protocol supports two transport methods, stdio and HTTP: the former suits local processes, the latter suits remote hosted services.

What Tools a Web MCP Server Provides

Taking XCrawl's MCP server as an example (npm package xcrawl-mcp, connecting to the XCrawl web data API), the tools it exposes cover common web data retrieval scenarios:

  • xcrawl_scrape: Scrape a single page, returning Markdown, HTML, links, or a summary
  • xcrawl_search: Perform a web search and return structured results
  • xcrawl_map: List accessible URLs under a domain
  • xcrawl_crawl and xcrawl_check_crawl_status: Crawl a site area as a background task and collect results
  • xcrawl_key_status: Check the API key and remaining quota

The division of labor among these tools is fairly clear: single-page scraping handles precise data retrieval, search handles discovery, map handles understanding site structure, and crawl handles batch collection. For coding tasks, the most common combination is "search first to locate, then scrape precisely by URL."

Two Ways to Connect: Hosted Endpoint vs. Local Process

MCP server configuration and tool list

The simplest approach is to use a hosted MCP URL—no process needs to run on your machine. Add this to Claude Desktop's claude_desktop_config.json:

{
  "mcpServers": {
    "xcrawl": {
      "url": "https://mcp.xcrawl.com/YOUR_API_KEY/mcp"
    }
  }
}

In Claude Code, you can add the same endpoint with a terminal command:

claude mcp add --transport http xcrawl https://mcp.xcrawl.com/YOUR_API_KEY/mcp

If you prefer not to have the API key appear in the URL, the server also supports passing the key via an Authorization: Bearer request header.

The other option is running locally via stdio (requires Node.js 18+):

XCRAWL_API_KEY=YOUR_API_KEY npx -y xcrawl-mcp

Or register it directly with Claude Code:

claude mcp add xcrawl -e XCRAWL_API_KEY=YOUR_API_KEY -- npx -y xcrawl-mcp

The advantage of the hosted endpoint is zero operations overhead and cross-client compatibility; the advantage of the local process is that the key stays on your machine, making it easier to audit call behavior. Both approaches provide identical capabilities to the assistant, and the choice depends on your team's preferences for credential management and deployment complexity.

stdio and HTTP are the two transport layers defined by the MCP specification. With stdio transport, the client launches the MCP server as a subprocess, and the two exchange JSON-RPC messages over standard input/output; the lifecycle is tied to the client, and the connection drops when the process exits. With HTTP transport, the client connects directly to a long-running remote endpoint, supports streaming responses, and multiple clients can share the same service. When choosing stdio, the key is typically injected into the subprocess as an environment variable and doesn't appear in the network request URL; when choosing HTTP, the key can be placed in the URL path or the Authorization header. The two are no different in tool-calling semantics—the differences are concentrated in deployment, credential flow, and observability.

How to Write Prompts That Actually Get the Assistant to Use It

Once the tools are connected, prompt quality directly determines whether scraping is effective. Several phrasings from the original article are worth referencing:

  • "Read the migration guide at <URL> and list the breaking changes that affect our code."
  • "Search for <service>'s current rate limits and cite the source page."
  • "List the URLs under docs.example.com/guides and summarize what each guide covers."

What these prompts have in common is clear, verifiable goals. Requiring the assistant to cite source pages is especially important—it makes scraping results traceable and prevents the model from conflating search results with its own memory. For time-sensitive information like migration guides and rate limits, having the assistant attach the URLs it read is the lowest-cost way to verify conclusions.

A Few Practices for Controlling Token Consumption

Web scraping can easily blow up the context, and the original article offers several practical suggestions:

  • Prefer Markdown over HTML: Much smaller in size, and easier for the model to read
  • Map before you crawl: List URLs first, then pick only the pages you actually need
  • When you only need one answer, use a few targeted scrapes instead of crawling the whole site
  • Keep sources: Ask the assistant to attach the URLs it read for easy verification
  • Respect site rules: Honor each site's robots.txt and terms, and don't make high-frequency requests to small sites

These points essentially balance "information freshness" against "context budget." The larger the scraping scope, the more noise there is, and the harder it is for the model to locate key information. Targeted scraping with source citations is usually more reliable than dumping an entire site's content at once.

The size difference between HTML and Markdown comes from structural redundancy: HTML carries a large amount of tags, inline styles, scripts, and navigation elements, which contribute almost nothing to the model's understanding of the body text. After converting a page to Markdown, most of the markup overhead is typically removed while preserving semantic structures like heading hierarchy, lists, and links, making it more stable for the model to parse. The context window is a limited resource; a full-site crawl may return the complete content of dozens of pages, of which only a few are truly relevant. Targeted scraping spends tokens on pages known to be relevant, making both retrieval precision and cost more controllable. Additionally, requiring the assistant to attach source URLs alongside its conclusions preserves verifiable anchors in the output, making it easy to quickly locate the original page during human review.

What Changes After Connecting

With a web data MCP server connected, a coding assistant goes from "trained up to a certain point in time" to "able to check the live web when needed." Configuration is just a config entry or a single command, and a newly registered XCrawl account comes with 1,000 free credits—enough to trial this workflow on your own projects. Full documentation is at docs.xcrawl.com. For development scenarios that require frequent verification of documentation versions, dependency changes, or third-party service parameters, the marginal benefit of this kind of integration is quite direct.

#MCP server#AI coding assistant#real-time web access#web scraping#Claude Code#Cursor#Model Context Protocol#token control
Share:

Related articles