特定のWebページを取得するためのMCPサーバーです。このサーバーは、指定されたURLからWebページの内容を取得し、その内容を解析して返すRESTful APIを提供します。さらに、Claude DesktopなどのAIアプリとの連携機能も提供します。
- Webページの取得とスクレイピング
- ページタイトルの抽出
- メタデータの抽出
- ページ本文の取得
- リンクの抽出
- 元のHTML取得
- AI連携機能:AIアプリが利用しやすい形式でコンテンツを提供
- Node.js (バージョン12以上)
- npm (バージョン6以上)
- このリポジトリをクローンします:
git clone https://github.com/snd-primary/mcp-web-scraper.git
cd mcp-web-scraper- 必要なパッケージをインストールします:
npm install- 環境変数を設定します:
cp .env.example .env必要に応じて.envファイルを編集します。
- サーバーを起動します:
npm start開発モードで起動する場合:
npm run dev- APIエンドポイントを使用します:
GET /scrape?url=https://example.com
url: スクレイピングするWebページのURL(必須)
{
"url": "https://example.com",
"title": "Example Domain",
"metaData": {
"description": "Example website description",
"keywords": "example, website, domain"
},
"bodyTextPreview": "This domain is for use in illustrative examples in documents...",
"bodyTextLength": 234,
"linkCount": 2,
"links": [
{
"href": "https://www.iana.org/domains/example",
"text": "More information..."
}
],
"html": "<!doctype html><html>...</html>"
}このAPIには、ClaudeなどのAIアプリと連携するための特別なエンドポイントが含まれています。
GET /ai/content?url=https://example.com&format=text&maxLength=4000
url: 取得するWebページのURL(必須)format: レスポンス形式('text', 'json', 'markdown'のいずれか、デフォルトは'text')maxLength: 最大文字数(省略可、デフォルトは4000文字)
Title: Example Domain
This domain is for use in illustrative examples in documents. You may use this domain in literature without prior coordination or asking for permission...
POST /ai/bulk
{
"urls": ["https://example.com", "https://example.org"],
"format": "json",
"maxLength": 2000
}{
"results": [
{
"url": "https://example.com",
"title": "Example Domain",
"content": "This domain is for use in illustrative examples..."
},
{
"url": "https://example.org",
"title": "Example Domain",
"content": "This domain is for use in illustrative examples..."
}
],
"count": 2,
"successCount": 2
}Claude Desktopなどのローカルで実行されるAIアプリケーションと連携するための例として、client-examples/claude-desktop-integration.jsファイルが含まれています。
- サーバーを起動します:
npm start - 連携スクリプトを実行します:
node client-examples/claude-desktop-integration.js https://example.com
このリポジトリのコードは、Chrome拡張機能としても簡単に改変できます。基本的な手順は以下の通りです:
manifest.jsonファイルを作成する- 拡張機能のUIを作成する(ポップアップなど)
- バックグラウンドスクリプトで
claude-desktop-integration.jsの関数を利用する
詳細な実装例については、chrome-extension-exampleディレクトリを参照してください(今後追加予定)。
Claude APIを直接利用して、Webページの内容をClaudeに送信する例も用意されています。APIキーを設定して、以下のように使用できます:
// client-examples/claude-api-integration.js の例を参照してください- 400 Bad Request: URLパラメータが不足している場合
- 500 Internal Server Error: スクレイピング中にエラーが発生した場合
server.jsファイルを編集して、必要に応じてスクレイピングロジックを変更できます- 特定のデータを抽出するためのカスタムロジックを追加できます
- レート制限や認証などの追加機能を実装できます
utils/textProcessor.jsを編集して、テキスト処理ロジックをカスタマイズできます
MIT