<RETURN_TO_BASE

Building an AgentQL MCP Server to Extract and Visualize Web Data

Discover how to implement an AgentQL MCP server within Claude Desktop to extract and visualize structured web data, demonstrated on Amazon AI book listings.

What is AgentQL?

AgentQL enables scraping of any website containing unstructured data by defining the exact structure of the information you want. This approach guarantees consistent, structured results even from pages with dynamic content or frequently changing layouts.

Setting Up the Environment

To implement an AgentQL Model Context Protocol (MCP) server inside Claude Desktop, start by preparing your environment:

  • Node.js: Required for running the AgentQL server via npx. Download and install from nodejs.org with default settings.
  • Claude Desktop: Download from https://claude.ai/download to use built-in visualization features.
  • AgentQL API Key: Obtain your API key at dev.agentql.com/api-keys and keep it secure for later use.

Installing Required Packages

After installing Node.js, open your terminal and execute:

npm install -g agentql-mcp

Configuring the MCP Server in Claude

Configure Claude to connect with your AgentQL MCP server by editing or creating the claude_desktop_config.json file in the Claude installation directory. Insert the following configuration, replacing <YOUR_API_KEY> with your actual API key:

{
    "mcpServers": {
      "agentql": {
        "command": "npx",
        "args": ["-y", "agentql-mcp"],
        "env": {
          "AGENTQL_API_KEY": "<YOUR_API_KEY>"
        }
      }
    }
  }

Running and Using the Server

Once configured, your MCP server will appear inside Claude. It offers a powerful tool called extract_web_data, which accepts a URL and a natural language description of the data structure to extract.

For demonstration, an Amazon search results page for AI books was scraped. Claude’s interactive terminal generates code to process and visualize the extracted data, allowing edits as needed. The visualization includes bar charts showing prices, ratings, and review counts, plus a scatter plot comparing price versus rating along with key summary statistics.

Practical Applications

AgentQL’s ability to scrape websites and integrate with platforms like Notion or GitHub makes it a versatile tool for automating documentation, tracking, and data-driven workflows by transforming unstructured web content into structured, actionable insights via natural language commands.

🇷🇺

Сменить язык

Читать эту статью на русском

Переключить на Русский