mcpField
W
Web Scraping with Anthropic’s MCP

Web Scraping with Anthropic’s MCP

ローカル
brightdata.comブラウザ自動化578 週間前に更新

Web Scraping with Anthropic’s MCP について

Claude や Cursor をスクレイピングツールに接続したい開発者向けのガイドと、Python 製 MCP サーバーの例です。Amazon 商品情報の抽出と Bright Data の利用方法を紹介します。

主な機能

  1. 01JavaScript 描画ページの取得
  2. 02Amazon 商品情報の構造化抽出
  3. 03Playwright と LXML の利用
  4. 04stdio トランスポートでの接続

活用シーン

  1. 01Amazon 商品ページの最新情報取得
  2. 02Python 製ウェブ抽出 MCP サーバーの構築

MCP 対応

サンプルサーバーは、Claude Desktop や Cursor などの MCP クライアントにページ取得と商品情報抽出のツールを公開します。ガイドでは Bright Data によるウェブデータ抽出も説明します。

設定

ローカルサーバーの設定はどのクライアントでも共通です。コピーしてクライアントの MCP 設定ファイルに貼り付けてください。

インストール方法は未掲載です

このサーバーのパッケージやリモートエンドポイントはまだ取得できていません。プロジェクトの README の手順に従ってください。

リポジトリ

ツール

ツール一覧はまだ取得されていません

ローカルサーバーのツールはマシン上で起動して初めて取得できます。メンテナーはまだツール一覧を提供していません。

詳細

Anthropic の MCP を使ったウェブスクレイピング

Bright Data のプロモーション

このガイドでは、オンデマンドのデータ抽出用に MCP サーバーをセットアップし、開発ツールに接続して、Bright Data を活用しながら AI 対応のウェブ情報をすぐに取得する方法を説明します。

制約を理解する:LLM が現実世界とのやり取りに支援を必要とする理由

大規模言語モデル(LLM)は、大量のトレーニングデータセットからテキストを処理し、生成することに優れています。しかし、重大な制約があります。外部の世界と自然にやり取りすることができません。そのため、ローカルファイルへのアクセス、カスタムスクリプトの実行、ウェブサイトからの最新情報の取得といった機能が組み込まれていません。

基本的な例を考えてみましょう。Claude に、現在公開されている Amazon の商品ページから詳細を抽出するよう頼んでも、追加のツールがなければ不可能です。なぜでしょうか?インターネットを閲覧したり、外部のアクションを実行したりする機能が備わっていないためです。

claude-without-mcp

補助ツールがなければ、LLM はリアルタイムデータや外部システムとの連携が必要な実用的なタスクを実行できません。

ここで、Anthropic の Model Context Protocol(MCP)が役立ちます。MCP により、LLM はデータ抽出ツール、API、スクリプトなどの外部ツールと、安全で標準化された方法で通信できます。

実際の違いを見てみましょう。カスタム MCP サーバーを統合したところ、Claude を通じて Amazon の商品情報を構造化データとして直接抽出できました。

claude-amazon-product-data-extraction-results

MCP の重要性

  • 標準化: MCP は、LLM ベースのシステムが外部ツールやデータに接続するための統一されたインターフェースを提供します。API がウェブ連携を標準化したのと同様です。これにより、カスタム連携の必要性が大幅に減り、開発が加速します。
  • 柔軟性とスケーラビリティ: 開発者は、ツール連携を書き直すことなく、LLM やホスティングプラットフォームを置き換えられます。MCP は stdio など複数の通信方式に対応しているため、さまざまな構成に適応できます。
  • LLM の機能強化: MCP は、LLM を最新のデータや外部ツールに接続することで、静的な応答の範囲を超えた対応を可能にします。これにより、状況に応じて最新かつ関連性の高い情報を提供し、現実世界でのアクションを実行できるようになります。

たとえ:

MCP は、LLM 向けの USB インターフェースだと考えてください。USB を使えば、キーボード、プリンター、外付けドライブなどのさまざまなデバイスを、特別なドライバーなしで互換性のある機器に接続できます。同じように、MCP を使うと、LLM は標準化されたプロトコルで幅広いツールに接続できるため、そのたびにカスタム連携を行う必要はありません。

Model Context Protocol の概要

Model Context Protocol(MCP)は、Anthropic が開発したオープン標準で、LLM が外部のツール、API、データソースと一貫性のある安全な方法で連携できるようにします。ユニバーサルコネクターとして機能し、LLM がウェブサイトのデータ抽出、データベースへのクエリ、スクリプトの実行といった現実のタスクを実行できるようにします。

Anthropic が導入したものですが、MCP はオープンで拡張可能なため、誰でも標準を実装したり、貢献したりできます。Retrieval-Augmented Generation(RAG)に取り組んだことがあれば、この概念を理解しやすいでしょう。MCP は、軽量な JSON-RPC インターフェースを通じてやり取りを標準化することで、この考え方を発展させ、モデルがライブデータにアクセスしてアクションを実行できるようにします。

MCP アーキテクチャの解説

MCP はその基盤として、AI モデルと外部機能の間の通信を標準化します。

基本的な考え方: 標準化されたインターフェース(通常は stdio などのトランスポートを介した JSON-RPC 2.0)により、LLM はクライアントを通じて、外部サーバーが公開するツールを検出して呼び出すことができます。

MCP は、次の 3 つの主要なコンポーネントからなるクライアント・サーバーアーキテクチャで動作します。

  1. MCP ホスト:LLM と外部ツールとのやり取りを開始し、管理する環境またはアプリケーションです。例として、Claude Desktop などの AI アシスタントや、Cursor などの IDE があります。
  2. MCP クライアント:ホスト内のコンポーネントで、MCP サーバーとの接続を確立して維持し、通信プロトコルを処理してデータ交換を管理します。
  3. MCP サーバー: MCP プロトコルを実装し、特定の機能を公開するプログラムです(開発者である私たちが作成します)。MCP サーバーはデータベース、ウェブサービス、または今回の例のようにウェブサイト(Amazon)と連携できます。サーバーは、次のような標準化された方法で機能を公開します。
    • ツール: 呼び出し可能な関数(例:scrape_amazon_product、get_weather_data)
    • リソース: 静的データを取得するための読み取り専用エンドポイント(例:ファイルの取得、JSON レコードの返却)
    • プロンプト: ツールやリソースとの LLM のやり取りをガイドする、定義済みのテンプレート

MCP アーキテクチャの図を以下に示します。

mcp-architecture-diagram-host-client-server-connections

画像の出典:Model Context Protocol

この構成では、ホスト(Claude Desktop または Cursor IDE)がMCP クライアントを起動し、クライアントが外部のMCP サーバーに接続します。そのサーバーはツール、リソース、プロンプトを公開し、AI が必要に応じてそれらを利用できるようにします。

ワークフローを簡単にまとめると、次のとおりです。

  • ユーザーが 「この Amazon のリンクから商品情報を取得してください。」 のようなメッセージを送信します
  • MCP クライアントが、そのタスクを処理できる登録済みのツールを確認します
  • クライアントが構造化されたリクエストを MCP サーバーに送信します
  • MCP サーバーが適切なアクションを実行します(例:ヘッドレスブラウザーの起動)
  • サーバーが構造化された結果を MCP クライアントに返します
  • クライアントが結果を LLM に転送し、LLM がユーザーに提示します

独自の MCP サーバーを開発する

Amazon の商品ページからデータを抽出する Python MCP サーバーを作成しましょう。

amazon-product-page-example

このサーバーは、HTML をダウンロードするツールと、整理された情報を抽出するツールの 2 つを提供します。Cursor または Claude Desktop の LLM クライアントを通じて、このサーバーを操作します。

ステップ 1:環境の準備

まず、Python 3 がインストールされていることを確認します。次に、仮想環境を作成して有効化します。

python -m venv mcp-amazon-scraper
# On macOS/Linux:
source mcp-amazon-scraper/bin/activate
# On Windows:
.\mcp-amazon-scraper\Scripts\activate

必要なライブラリである MCP Python SDK、Playwright、LXML をインストールします。

pip install mcp playwright lxml
# Install browser binaries for Playwright
python -m playwright install

以下がインストールされます。

  • mcp:Model Context Protocol サーバーおよびクライアント向けの Python SDK で、JSON-RPC 通信の詳細をすべて処理します
  • playwright:ブラウザー自動化ライブラリです。ヘッドレスブラウザー機能を備え、JavaScript を多用するウェブサイトのレンダリングとスクレイピングを行います
  • lxml:高速な XML/HTML 解析ライブラリです。XPath クエリを使ってウェブページから特定のデータ要素を簡単に抽出できます

つまり、MCP Python SDK(mcp)がプロトコルの詳細をすべて処理するため、Claude や Cursor が自然言語のプロンプトを通じて呼び出せるツールを公開できます。Playwright を使うと、JavaScript コンテンツも含めてウェブページ全体をレンダリングできます。また、lxml は強力な HTML 解析機能を提供します。

ステップ 2:MCP サーバーの起動

amazon_scraper_mcp.py という名前の Python ファイルを作成します。必要なモジュールをインポートし、FastMCP サーバーを初期化します。

import os
import asyncio
from lxml import html as lxml_html
from mcp.server.fastmcp import FastMCP
from playwright.async_api import async_playwright

# Define a temporary file path for the HTML content
HTML_FILE = os.path.join(os.getenv("TMPDIR", "/tmp"), "amazon_product_page.html")

# Initialize the MCP server with a descriptive name
mcp = FastMCP("Amazon Product Scraper")

print("MCP Server Initialized: Amazon Product Scraper")

これにより、MCP サーバーのインスタンスが作成されます。次に、ツールを追加します。

ステップ 3:fetch_page ツールの実装

このツールは URL を入力として受け取り、Playwright を使ってページに移動し、コンテンツの読み込みを待って HTML をダウンロードし、一時ファイルに保存します。

@mcp.tool()
async def fetch_page(url: str) -> str:
    """
    Fetches the HTML content of the given Amazon product URL using Playwright
    and saves it to a temporary file. Returns a status message.
    """
    print(f"Executing fetch_page for URL: {url}")
    try:
        async with async_playwright() as p:
            # Launch headless Chromium browser
            browser = await p.chromium.launch(headless=True)
            page = await browser.new_page()
            # Navigate to the URL with a generous timeout
            await page.goto(url, timeout=90000, wait_until="domcontentloaded")
            # Wait for a key element (e.g., body) to ensure basic loading
            await page.wait_for_selector("body", timeout=30000)
            # Add a small delay for any dynamic content rendering via JavaScript
            await asyncio.sleep(5)

            html_content = await page.content()
            with open(HTML_FILE, "w", encoding="utf-8") as f:
                f.write(html_content)

            await browser.close()
            print(f"Successfully fetched and saved HTML to {HTML_FILE}")
            return f"HTML content for {url} downloaded and saved successfully to {HTML_FILE}."
    except Exception as e:
        error_message = f"Error fetching page {url}: {str(e)}"
        print(error_message)
        return error_message

この非同期関数は Playwright を使い、Amazon のページで JavaScript のレンダリングが必要になる場合に対応します。@mcp.tool() デコレーターにより、この関数がサーバー内で呼び出し可能なツールとして登録されます。

ステップ 4:extract_info ツールの実装

このツールは、fetch_page が保存した HTML ファイルを読み込み、LXML と XPath セレクターを使って解析し、抽出した商品情報を含む辞書を返します。

def _extract_xpath(tree, xpath, default="N/A"):
    """Helper function to extract text using XPath, returning default if not found."""
    try:
        # Use text_content() to get text from node and children, strip whitespace
        result = tree.xpath(xpath)
        if result:
            return result[0].text_content().strip()
        return default
    except Exception:
        return default

def _extract_price(price_str):
    """Helper function to parse price string into a float."""
    if price_str == "N/A":
        return None
    try:
        # Remove currency symbols and commas, handle potential whitespace
        cleaned_price = "".join(filter(str.isdigit or str.__eq__("."), price_str))
        return float(cleaned_price)
    except (ValueError, TypeError):
        return None

@mcp.tool()
def extract_info() -> dict:
    """
    Parses the saved HTML file (downloaded by fetch_page) to extract
    Amazon product details like title, price, rating, features, etc.
    Returns a dictionary of the extracted data.
    """
    print(f"Executing extract_info from file: {HTML_FILE}")
    if not os.path.exists(HTML_FILE):
        return {
            "error": f"HTML file not found at {HTML_FILE}. Please run fetch_page first."
        }

    try:
        with open(HTML_FILE, "r", encoding="utf-8") as f:
            page_html = f.read()

        tree = lxml_html.fromstring(page_html)

        # --- XPath Selectors for Amazon Product Details ---
        title = _extract_xpath(tree, '//span[@id="productTitle"]')
        # Handle different price structures (main price, sale price)
        price_whole = _extract_xpath(tree, '//span[contains(@class, "a-price-whole")]')
        price_fraction = _extract_xpath(
            tree, '//span[contains(@class, "a-price-fraction")]'
        )
        price_str = (
            f"{price_whole}.{price_fraction}"
            if price_whole != "N/A"
            else _extract_xpath(tree, '//span[contains(@class,"a-offscreen")]')
        )  # Fallback to offscreen if needed

        price = _extract_price(price_str)

        # Original price (strike-through)
        original_price_str = _extract_xpath(
            tree, '//span[@class="a-price a-text-price"]//span[@class="a-offscreen"]'
        )
        original_price = _extract_price(original_price_str)

        # Rating
        rating_text = _extract_xpath(tree, '//span[@id="acrPopover"]/@title')
        rating = None
        if rating_text != "N/A":
            try:
                rating = float(rating_text.split()[0])
            except (ValueError, IndexError):
                rating = None

        # Review Count
        reviews_text = _extract_xpath(tree, '//span[@id="acrCustomerReviewText"]')
        review_count = None
        if reviews_text != "N/A":
            try:
                review_count = int(reviews_text.split()[0].replace(",", ""))
            except (ValueError, IndexError):
                review_count = None

        # Availability
        availability = _extract_xpath(
            tree,
            '//div[@id="availability"]//span/text()',
        )

        # Features (bullet points)
        feature_elements = tree.xpath(
            '//div[@id="feature-bullets"]//li//span[@class="a-list-item"]'
        )
        features = [
            elem.text_content().strip()
            for elem in feature_elements
            if elem.text_content().strip()
        ]

        # Calculate Discount
        discount = None
        if price and original_price and original_price > price:
            discount = round(((original_price - price) / original_price) * 100)

        extracted_data = {
            "title": title,
            "price": price,
            "original_price": original_price,
            "discount_percent": discount,
            "rating_stars": rating,
            "review_count": review_count,
            "features": features,
            "availability": availability.strip(),
        }
        print(f"Successfully extracted data: {extracted_data}")
        return extracted_data

    except Exception as e:
        error_message = f"Error parsing HTML: {str(e)}"
        print(error_message)  # Added for logging
        return {"error": error_message}

この関数は、LXML の fromstring を使って HTML を解析し、堅牢な XPath セレクターで目的の要素を検索します。

ステップ 5:サーバーの実行

最後に、amazon_scraper_mcp.py スクリプトの末尾に次の行を追加して、stdio トランスポートを使ってサーバーを起動します。このトランスポートは、Claude Desktop や Cursor などのクライアントと通信するローカル MCP サーバーで標準的に使用されます。

if __name__ == "__main__":
    print("Starting MCP Server with stdio transport...")
    # Run the server, listening via standard input/output
    mcp.run(transport="stdio")
完全なソースコード
import os
import asyncio
from lxml import html as lxml_html
from mcp.server.fastmcp import FastMCP
from playwright.async_api import async_playwright

# Define a temporary file path for the HTML content
HTML_FILE = os.path.join(os.getenv("TMPDIR", "/tmp"), "amazon_product_page.html")

# Initialize the MCP server with a descriptive name
mcp = FastMCP("Amazon Product Scraper")

print("MCP Server Initialized: Amazon Product Scraper")

@mcp.tool()
async def fetch_page(url: str) -> str:
    """
    Fetches the HTML content of the given Amazon product URL using Playwright
    and saves it to a temporary file. Returns a status message.
    """
    print(f"Executing fetch_page for URL: {url}")
    try:
        async with async_playwright() as p:
            # Launch headless Chromium browser
            browser = await p.chromium.launch(headless=True)
            page = await browser.new_page()
            # Navigate to the URL with a generous timeout
            await page.goto(url, timeout=90000, wait_until="domcontentloaded")
            # Wait for a key element (e.g., body) to ensure basic loading
            await page.wait_for_selector("body", timeout=30000)
            # Add a small delay for any dynamic content rendering via JavaScript
            await asyncio.sleep(5)

            html_content = await page.content()
            with open(HTML_FILE, "w", encoding="utf-8") as f:
                f.write(html_content)

            await browser.close()
            print(f"Successfully fetched and saved HTML to {HTML_FILE}")
            return f"HTML content for {url} downloaded and saved successfully to {HTML_FILE}."
    except Exception as e:
        error_message = f"Error fetching page {url}: {str(e)}"
        print(error_message)
        return error_message

def _extract_xpath(tree, xpath, default="N/A"):
    """Helper function to extract text using XPath, returning default if not found."""
    try:
        # Use text_content() to get text from node and children, strip whitespace
        result = tree.xpath(xpath)
        if result:
            return result[0].text_content().strip()
        return default
    except Exception:
        return default

def _extract_price(price_str):
    """Helper function to parse price string into a float."""
    if price_str == "N/A":
        return None
    try:
        # Remove currency symbols and commas, handle potential whitespace
        cleaned_price = "".join(filter(str.isdigit or str.__eq__("."), price_str))
        return float(cleaned_price)
    except (ValueError, TypeError):
        return None

@mcp.tool()
def extract_info() -> dict:
    """
    Parses the saved HTML file (downloaded by fetch_page) to extract
    Amazon product details like title, price, rating, features, etc.
    Returns a dictionary of the extracted data.
    """
    print(f"Executing extract_info from file: {HTML_FILE}")
    if not os.path.exists(HTML_FILE):
        return {
            "error": f"HTML file not found at {HTML_FILE}. Please run fetch_page first."
        }

    try:
        with open(HTML_FILE, "r", encoding="utf-8") as f:
            page_html = f.read()

        tree = lxml_html.fromstring(page_html)

        # --- XPath Selectors for Amazon Product Details ---
        title = _extract_xpath(tree, '//span[@id="productTitle"]')
        # Handle different price structures (main price, sale price)
        price_whole = _extract_xpath(tree, '//span[contains(@class, "a-price-whole")]')
        price_fraction = _extract_xpath(
            tree, '//span[contains(@class, "a-price-fraction")]'
        )
        price_str = (
            f"{price_whole}.{price_fraction}"
            if price_whole != "N/A"
            else _extract_xpath(tree, '//span[contains(@class,"a-offscreen")]')
        )  # Fallback to offscreen if needed

        price = _extract_price(price_str)

        # Original price (strike-through)
        original_price_str = _extract_xpath(
            tree, '//span[@class="a-price a-text-price"]//span[@class="a-offscreen"]'
        )
        original_price = _extract_price(original_price_str)

        # Rating
        rating_text = _extract_xpath(tree, '//span[@id="acrPopover"]/@title')
        rating = None
        if rating_text != "N/A":
            try:
                rating = float(rating_text.split()[0])
            except (ValueError, IndexError):
                rating = None

        # Review Count
        reviews_text = _extract_xpath(tree, '//span[@id="acrCustomerReviewText"]')
        review_count = None
        if reviews_text != "N/A":
            try:
                review_count = int(reviews_text.split()[0].replace(",", ""))
            except (ValueError, IndexError):
                review_count = None

        # Availability
        availability = _extract_xpath(
            tree,
            '//div[@id="availability"]//span/text()',
        )

        # Features (bullet points)
        feature_elements = tree.xpath(
            '//div[@id="feature-bullets"]//li//span[@class="a-list-item"]'
        )
        features = [
            elem.text_content().strip()
            for elem in feature_elements
            if elem.text_content().strip()
        ]

        # Calculate Discount
        discount = None
        if price and original_price and original_price > price:
            discount = round(((original_price - price) / original_price) * 100)

        extracted_data = {
            "title": title,
            "price": price,
            "original_price": original_price,
            "discount_percent": discount,
            "rating_stars": rating,
            "review_count": review_count,
            "features": features,
            "availability": availability.strip(),
        }
        print(f"Successfully extracted data: {extracted_data}")
        return extracted_data

    except Exception as e:
        error_message = f"Error parsing HTML: {str(e)}"
        print(error_message)  # Added for logging
        return {"error": error_message}

if __name__ == "__main__":
    print("Starting MCP Server with stdio transport...")
    # Run the server, listening via standard input/output
    mcp.run(transport="stdio")

MCP サーバーへの接続

サーバーのスクリプトが準備できたので、Claude Desktop や Cursor などの MCP クライアントに接続しましょう。

Claude Desktop でのセットアップ

ステップ 1: Claude Desktop を開きます。

ステップ 2: Settings -> Developer -> Edit Config に移動します。デフォルトのテキストエディターで claude_desktop_config.json ファイルが開きます。

claude-desktop-settings-menu-navigation

ステップ 3: mcpServers キーの下に、サーバーのエントリを追加します。args 内のパスを、amazon_scraper_mcp.py ファイルの絶対パスに置き換えてください。

{
  "mcpServers": {
    "amazon_product_scraper": {
      "command": "python",  // Or python3 if needed
      "args": ["/full/path/to/your/amazon_scraper_mcp.py"], // <-- IMPORTANT: Use the correct absolute path
    }
  }
}

ステップ 4: claude_desktop_config.json ファイルを保存し、変更を反映するために Claude Desktop を完全に終了してから、再度開きます。

ステップ 5: Claude Desktop のチャット入力欄に、小さなツールアイコン(ハンマー 🔨 のようなアイコン)が表示されているはずです。

claude-desktop-mcp-tools-icon-interface

ステップ 6: そのアイコンをクリックすると、fetch_page と extract_info のツールを備えた「Amazon Product Scraper」が一覧に表示されます。

claude-available-mcp-tools-dialog-amazon-scraper

ステップ 7: たとえば、次のようなプロンプトを送信します。 「この Amazon 商品の現在の価格、元の価格、評価を取得してください:https://www.amazon.com/dp/B09C13PZX7」。

ステップ 8: Claude は外部ツールが必要であることを検出し、まず fetch_page、次に extract_info を実行する許可を求めます。それぞれのツールで「このチャットで許可」をクリックします。

mcp-permission-dialog-fetch-page-amazon-tool

ステップ 9: 許可すると、MCP サーバーがツールを実行します。その後、Claude は構造化データを受け取り、チャットに表示します。

claude-amazon-product-data-extraction-results

Cursor でのセットアップ

AI を最優先に設計した IDE である Cursor の場合も、手順は同様です。

Step 1: Cursor を開きます。

Step 2: Settings ⚙️ を開き、MCP セクションに移動します。

cursor-ide-add-new-global-mcp-server-settings

Step 3: 「+Add a new global MCP Server」をクリックします。mcp.json 設定ファイルが開きます。スクリプトの絶対パスを使用して、サーバーのエントリーを追加します。

cursor-mcp-json-configuration-file-amazon-scraper

Step 4: mcp.json ファイルを保存すると、「amazon_product_scraper」が一覧に表示されます。正常に動作して接続されていれば、緑色の点が表示されます。

cursor-ide-configured-amazon-scraper-mcp-settings

Step 5: Cursor のチャット機能(Cmd+l または Ctrl+l)を使います。

Step 6: たとえば、次のようなプロンプトを送信します。「この Amazon の URL から、入手可能な商品データをすべて抽出してください:https://www.amazon.com/dp/B09C13PZX7。出力は構造化された JSON オブジェクトにしてください」

Step 7: Claude Desktop と同様に、Cursor は fetch_page ツールと extract_info ツールを実行する許可を求めます。これらのリクエストを承認します(「Run Tool」)。

Step 8: Cursor にはやり取りの流れが表示され、MCP ツールへの呼び出しが示された後、extract_info ツールから返された構造化 JSON データが表示されます。

cursor-ide-amazon-product-data-extraction-json-results Cursor の JSON 出力例を次に示します。

{
  "title": "Razer Basilisk V3 Customizable Ergonomic Gaming Mouse: Fastest Gaming Mouse Switch - Chroma RGB Lighting - 26K DPI Optical Sensor - 11 Programmable Buttons - HyperScroll Tilt Wheel - Classic Black",
  "price": 39.99,
  "original_price": 69.99,
  "discount_percent": 43,
  "rating_stars": 4.6,
  "review_count": 7782,
  "features": [
    "ICONIC ERGONOMIC DESIGN WITH THUMB REST — PC gaming mouse favored by millions worldwide with a form factor that perfectly supports the hand while its buttons are optimally positioned for quick and easy access",
    "11 PROGRAMMABLE BUTTONS — Assign macros and secondary functions across 11 programmable buttons to execute essential actions like push-to-talk, ping, and more",
    "HYPERSCROLL TILT WHEEL — Speed through content with a scroll wheel that free-spins until its stopped or switch to tactile mode for more precision and satisfying feedback that's ideal for cycling through weapons or skills",
    "11 RAZER CHROMA RGB LIGHTING ZONES — Customize each zone from over 16.8 million colors and countless lighting effects, all while it reacts dynamically with over 150 Chroma integrated games",
    "OPTICAL MOUSE SWITCHES GEN 2 — With zero unintended misclicks these switches provide crisp, responsive execution at a blistering 0.2ms actuation speed for up to 70 million clicks",
    "FOCUS+ 26K DPI OPTICAL SENSOR — Best-in-class mouse sensor with intelligent functions flawlessly tracks movement with zero smoothing, allowing for crisp response and pixel-precise accuracy",
    // ... (other features)
  ],
  "availability": "In Stock"
}

これは、MCP の柔軟性を示しています。同じサーバーが、異なるクライアントアプリケーションでもシームレスに動作します。

プロフェッショナルなウェブデータ抽出に Bright Data の MCP を使用する

Bright Data のエンタープライズグレードのModel Context Protocol(MCP)ソリューションは、プロキシ管理、ボット対策への対応、スケーリングの課題など、MCP サーバーを自ら管理する際の複雑さを解消し、AI エージェントや LLM とのシームレスな連携を実現します。

Bright Data の MCP に接続すると、SERP の結果やアクセスが難しいサイトなど、一般公開されているウェブデータにすぐアクセスできるようになり、AI ワークフローに最適化されます。

MCP を使うと、Web Unlocker、SERP API、Web Scraper API、Scraping Browser などのツールを備えた強力なウェブ抽出フレームワークを利用できます。主な特長は次のとおりです。

  • AI 対応データ: 前処理が不要な、事前に構造化されたコンテンツです。
  • スケーラビリティと信頼性: 処理速度を落とさず、大量のデータに対応します。
  • ブロックと CAPTCHA の回避: 高度なボット対策機能を備えています。
  • グローバル IP カバレッジ: Bright Data のプロキシを利用して、195 か国からアクセスできます。
  • シームレスな連携: あらゆる MCP クライアントとすばやくセットアップできます。
Bright Data MCP の前提条件

Bright Data MCP の統合を開始する前に、以下を用意してください。

  1. Bright Data アカウント: brightdata.com で登録します。初めてご利用になる方には、テスト用の無料クレジットが付与されます。
  2. API トークン: Bright Data アカウントの設定から API トークンを取得します(ユーザー設定ページ)。
  3. Web Unlocker ゾーン: Bright Data のコントロールパネルで Web Unlocker プロキシゾーンを作成します。mcp_unlocker のように覚えやすい識別子を選択してください(必要に応じて、後から環境変数で変更できます)。
  4. (任意)Scraping Browser ゾーン: 高度なブラウザー自動化機能(複雑な JavaScript 操作やスクリーンショットなど)が必要な場合は、Scraping Browser ゾーンを作成します。このゾーン用に提供される認証情報(ユーザー名とパスワード)は、Overview タブで確認して記録してください。通常、brd-customer-ACCOUNT_ID-zone-ZONE_NAME:PASSWORD の形式です。
クイックスタート:Claude Desktop 用の Bright Data MCP の設定

ステップ 1: Bright Data MCP サーバーは通常、Node.js に同梱されている npx を使用して実行します。必要に応じて、公式サイトから Node.js をインストールしてください。

ステップ 2: Claude Desktop で Settings -> Developer -> Edit Config(claude_desktop_config.json)を開きます。

ステップ 3: mcpServers の下に Bright Data サーバーの設定を追加します。プレースホルダーは実際の認証情報に置き換えてください。

{
  "mcpServers": {
    "Bright Data": { // Choose a name for the server
      "command": "npx",
      "args": ["@brightdata/mcp"],
      "env": {
        "API_TOKEN": "YOUR_BRIGHTDATA_API_TOKEN", // Paste your API token here
        "WEB_UNLOCKER_ZONE": "mcp_unlocker",     // Your Web Unlocker zone name
        // Optional: Add if using Scraping Browser tools
        "BROWSER_AUTH": "brd-customer-ACCOUNTID-zone-YOURZONE:PASSWORD"
      }
    }
  }
}

ステップ 4: 設定ファイルを保存し、Claude Desktop を再起動します。

ステップ 5: Claude Desktop のハンマーアイコン(🔨)にカーソルを合わせます。複数の MCP ツールが利用可能になっているはずです。

claude-desktop-interface-with-mcp-tools-available

スクレイパーを制限する可能性があることで知られる Zillow から、データを抽出してみましょう。Claude に「次の Zillow の URL から主要な物件データを JSON 形式で抽出してください:[https://www.zillow.com/apartments/arverne-ny/the-tides-at-arverne-by-the-sea/ChWHPZ/]」とプロンプトを入力します。

bright-data-mcp-zillow-property-extraction-process

必要な Bright Data MCP ツールの使用を Claude に許可します。Bright Data の MCP サーバーが、プロキシのローテーションや、必要に応じた Scraping Browser による JavaScript のレンダリングなど、内部処理の複雑さを管理します。

Bright Data のサーバーがデータを抽出して構造化データを返し、Claude がそのデータを表示します。

zillow-property-data-json-structure-bright-data-mcp

出力例を以下に示します。

{
  "propertyInfo": {
    "name": "The Tides At Arverne By The Sea",
    "address": "190 Beach 69th St, Arverne, NY 11692",
    "propertyType": "Apartment building",
    // ... more info
  },
  "rentPrices": {
    "studio": { "startingPrice": "$2,750", /* ... */ },
    "oneBed": { "startingPrice": "$2,900", /* ... */ },
    "twoBed": { "startingPrice": "$3,350", /* ... */ }
  },
  // ... amenities, policies, etc.
}

別の例:Hacker News の見出し

より簡単な問い合わせ:「Hacker News の最新ニュース記事 5 件のタイトルを教えてください」。

hacker-news-latest-articles-mcp-extraction-results

この例は、Bright Data の MCP サーバーを使うと、動的なコンテンツや強固に保護された Web コンテンツにも、AI ワークフローから直接簡単にアクセスできることを示しています。

さらに読む

AI や大規模言語モデル(LLM)について、より深く知るための過去のガイドをまとめました。

結論

Anthropic の Model Context Protocol は、AI システムが外部の世界とどのようにやり取りするかを根本的に変えるものです。特定のタスク向けにカスタム MCP サーバーを構築できます。Bright Data の MCP 統合により、ボット対策を回避し、AI 対応の構造化データを提供するエンタープライズグレードのウェブスクレイピング機能が加わります。

今すぐ登録して、AI ソリューションを無料でお試しください!

コメント

MCP は初めてですか?

プロトコルの概要から最初のサーバーの導入まで、よくある疑問にまとめて答えます。

AI アプリケーションが外部のツールやデータソースに統一的な方法で接続するためのオープンなプロトコルです。クライアントはモデルとの対話を担い、MCP サーバーはツール・リソース・プロンプトテンプレートを提供します。標準メッセージでやり取りするため、1 つのサーバーを複数のクライアントで再利用できます。