Spider MCP Server

Spider MCP Server

Enables crawling and extracting clean content from documentation websites with optional LLM-powered analysis for intelligent summaries, code example extraction, and content classification.

Category
访问服务器

README

Spider MCP Server

An MCP server for crawling and spidering documentation websites, extracting clean text content, and using LLM-powered analysis to provide intelligent summaries and context through the Model Context Protocol.

Features

  • Crawl entire documentation websites with configurable depth limits
  • Extract clean text content from HTML pages using multiple extraction methods
  • Intelligent content parsing that removes navigation, ads, and other noise
  • LLM-powered content analysis using Anthropic Claude (Haiku/Sonnet)
  • Automatic content summarization and key point extraction
  • Intelligent code example extraction and categorization
  • Code example detection across multiple programming languages
  • Intelligent link discovery and relevance ranking
  • Content type classification (tutorial, reference, API docs, etc.)
  • Respect robots.txt and implement proper crawling etiquette
  • File-based caching with TTL and compression
  • Search through cached documentation content with LLM enhancement
  • Concurrent crawling with rate limiting
  • Support for various documentation layouts and formats

Installation

git clone <repository-url>
cd spider-mcp
bun install
cp .env.example .env

Usage

As MCP Server

Run the server to expose MCP tools:

bun run dev

MCP Client Integration

This server implements the Model Context Protocol (MCP) specification and communicates via stdio transport. MCP enables AI assistants to securely access external tools and data sources. To use this server, you need an MCP-compatible client like Claude Desktop, or you can integrate it programmatically using the MCP SDK.

Claude Desktop Integration

Add to your Claude Desktop MCP configuration:

{
  "mcpServers": {
    "spider-mcp": {
      "command": "bun",
      "args": ["run", "/path/to/spider-mcp/src/index.ts"],
      "env": {
        "ANTHROPIC_API_KEY": "your_api_key_here"
      }
    }
  }
}

Programmatic Usage Examples

// Example using @modelcontextprotocol/sdk
import { Client } from '@modelcontextprotocol/sdk/client/index.js';
import { StdioClientTransport } from '@modelcontextprotocol/sdk/client/stdio.js';

const client = new Client({
  name: "spider-client",
  version: "1.0.0"
}, {
  capabilities: {}
});

// Connect to the spider MCP server
const transport = new StdioClientTransport({
  command: "bun",
  args: ["run", "/path/to/spider-mcp/src/index.ts"]
});

await client.connect(transport);

// Extract code examples from documentation
const result = await client.request({
  method: "tools/call",
  params: {
    name: "spider_docs",
    arguments: {
      url: "https://docs.anthropic.com/en/docs/quickstart",
      enable_llm_analysis: true,
      llm_analysis_type: "code_examples",
      max_depth: 2
    }
  }
});

Available Tools

spider_docs

Crawl a documentation website and cache the content with optional LLM analysis.

Parameters:

  • url (required): Base URL of the documentation site
  • max_depth (optional): Maximum crawl depth (default: 3)
  • include_patterns (optional): URL patterns to include
  • exclude_patterns (optional): URL patterns to exclude
  • enable_llm_analysis (optional): Enable LLM-powered content analysis
  • llm_analysis_type (optional): Type of analysis:
    • full - Complete analysis with summary, key points, links, and code examples
    • summary - Content summarization only
    • links - Link analysis and relevance ranking
    • classification - Content type classification
    • code_examples - Extract and categorize code examples only

Example with code extraction:

{
  "url": "https://docs.example.com/api",
  "max_depth": 2,
  "enable_llm_analysis": true,
  "llm_analysis_type": "code_examples"
}

get_page

Retrieve a specific page from the cache.

Parameters:

  • url (required): URL of the page to retrieve

search_docs

Search through cached documentation content.

Parameters:

  • query (required): Search query
  • limit (optional): Maximum results to return (default: 10)

list_pages

List all cached pages with optional filtering and sorting.

Parameters:

  • filter (optional): Filter pages by URL pattern
  • sort (optional): Sort field (url, title, timestamp)
  • order (optional): Sort order (asc, desc)

clear_cache

Clear cached pages matching a pattern.

Parameters:

  • url_pattern (optional): Pattern to match for clearing

analyze_content

Perform LLM-powered analysis on a specific cached page.

Parameters:

  • url (required): URL of the page to analyze
  • analysis_type (optional): Same options as spider_docs above

Example for code extraction:

{
  "url": "https://docs.example.com/api/users",
  "analysis_type": "code_examples"
}

get_summary

Get an intelligent summary of a cached page.

Parameters:

  • url (required): URL of the page to summarize
  • summary_length (optional): Length of summary (short, medium, long)
  • focus_areas (optional): Specific areas to focus on in the summary

Configuration

Configuration can be provided through:

  1. Environment variables (see .env.example)
  2. JSON configuration files in config/ directory
  3. Runtime parameters passed to tools

LLM Integration

To enable LLM-powered content analysis, set your Anthropic API key:

export ANTHROPIC_API_KEY=your_api_key_here

The server will automatically detect the API key and enable LLM features. Without an API key, the server operates in basic mode with programmatic content extraction only.

Example Configuration

{
  "maxDepth": 3,
  "maxPages": 100,
  "concurrency": 5,
  "userAgent": "SpiderMCP/1.0 Documentation Crawler",
  "timeout": 10000,
  "retryAttempts": 3,
  "cacheTTL": 86400000,
  "respectRobotsTxt": true,
  "includePatterns": ["/docs/*", "/api/*"],
  "excludePatterns": ["/blog/*", "*.pdf"]
}

Development

bun test
bun run typecheck
bun run build

Testing the Spider

Use the included test script to try out the functionality locally:

# Test with code example extraction on a documentation site
bun run test-spider.ts https://docs.anthropic.com/en/docs/quickstart

# Test with a specific site focusing on code examples
ANTHROPIC_API_KEY=your_key bun run test-spider.ts https://docs.example.com

# Test code-only extraction
bun run test-spider.ts https://docs.python.org/3/tutorial/

The test script demonstrates the spider functionality outside of MCP and will show you:

  • Crawled pages with metadata
  • Extracted code examples with languages and categories
  • LLM analysis results including summaries and classifications
  • Cache statistics and performance metrics

Note: The test script uses the spider functionality directly, not through MCP protocol.

Architecture

  • src/spider/ - Core crawling and parsing logic
  • src/mcp/ - MCP server implementation and tool handlers
  • src/extractors/ - Content extraction strategies
  • src/llm/ - LLM integration and content analysis
  • src/utils/ - Utility functions and configuration
  • cache/ - File system cache storage
  • config/ - Configuration files

Extraction Methods

The server supports multiple content extraction methods:

  1. Readability - Mozilla Readability algorithm for article extraction
  2. Cheerio - Custom CSS selector-based extraction
  3. Markdown - HTML to Markdown conversion with Turndown
  4. LLM Analysis - Anthropic Claude for intelligent content understanding and code extraction

Code Example Extraction

The LLM analysis can intelligently extract and categorize code examples from documentation:

  • Language Detection: Automatically detects programming languages (JavaScript, Python, bash, JSON, etc.)
  • Code Categories:
    • api_call - API requests, SDK calls, HTTP requests
    • configuration - Config files, settings, environment setup
    • implementation - Complete functions, classes, modules
    • usage_example - How to use a feature or library
    • snippet - Small code fragments or utilities
    • complete_example - Full working examples or applications
  • Format Preservation: Maintains exact formatting, indentation, and syntax
  • Context Awareness: Provides meaningful descriptions for each code example

Example Output Format

When using code example extraction, the output includes structured code examples:

{
  "codeExamples": [
    {
      "language": "javascript",
      "code": "const response = await fetch('/api/users', {\n  method: 'GET',\n  headers: {\n    'Authorization': 'Bearer ' + apiKey\n  }\n});",
      "description": "Fetch users from API with authentication",
      "category": "api_call"
    },
    {
      "language": "python",
      "code": "import requests\n\nresponse = requests.get('/api/users', headers={\n    'Authorization': f'Bearer {api_key}'\n})",
      "description": "Python example for API authentication",
      "category": "api_call"
    },
    {
      "language": "json",
      "code": "{\n  \"database\": {\n    \"host\": \"localhost\",\n    \"port\": 5432\n  }\n}",
      "description": "Database configuration file",
      "category": "configuration"
    }
  ]
}

Caching

  • Two-tier caching: in-memory + file system
  • Configurable TTL and cache size limits
  • Automatic cleanup of expired entries
  • Domain-based cache organization

Robots.txt Compliance

  • Fetches and parses robots.txt automatically
  • Respects crawl-delay directives
  • Honors disallow/allow rules
  • Discovers sitemaps

Rate Limiting

  • Configurable concurrent request limits
  • Exponential backoff for failed requests
  • Per-domain crawl delays
  • Timeout handling

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选