网页数据提取服务器

Firecrawl MCP Server是一个基于Firecrawl API的网页抓取、内容搜索、站点爬取和数据提取的模型上下文协议服务器。

  • by Msparihar
  • TypeScript
  • 本地部署
  • 3 星标
  • 更新于
在 GitHub 查看 Msparihar/mcp-server-firecrawl

使用说明

Firecrawl MCP服务器

模型上下文协议(MCP)服务器,用于使用Firecrawl API进行网页抓取、内容搜索、网站抓取和数据提取。

特性

  • Web剪贴:使用可自定义选项从任何网页提取内容

    • 移动设备仿真
    • 广告和弹出窗口阻止
    • 内容过滤
    • 结构化数据提取
    • 多种输出格式
  • 内容搜索:智能搜索功能

    • 多语言支持
    • 基于位置的结果
    • 可定制的结果限制
    • 结构化输出格式
  • 网站爬行:高级网络爬行功能

    • 深度控制
    • 路径过滤
    • 速率限制
    • 进度跟踪
    • 网站地图集成
  • 现场测绘:生成站点结构图

    • 子域名支持
    • 搜索筛选
    • 链接分析
    • 视觉层次
  • 数据提取:从多个URL提取结构化数据

    • 架构验证
    • 批量处理
    • 网络搜索丰富
    • 自定义提取提示

安装

# Global installation
npm install -g @modelcontextprotocol/mcp-server-firecrawl

# Local project installation
npm install @modelcontextprotocol/mcp-server-firecrawl

快速开始

  1. 从获取Firecrawl API密钥 开发人员门户

  2. 设置API密钥:

    Unix/Linux/macOS(bash/zsh):

    export FIRECRAWL_API_KEY=your-api-key
    

    Windows(命令提示符):

    set FIRECRAWL_API_KEY=your-api-key
    

    Windows(PowerShell):

    $env:FIRECRAWL_API_KEY = "your-api-key"
    

    替代方案:使用.env文件(建议用于开发):

    # Install dotenv
    npm install dotenv
    
    # Create .env file
    echo "FIRECRAWL_API_KEY=your-api-key" > .env
    

    然后在代码中:

    import dotenv from 'dotenv';
    dotenv.config();
    
  3. 运行服务器:

    mcp-server-firecrawl
    

整合

克劳德桌面应用程序

添加到MCP设置中:

{
  "firecrawl": {
    "command": "mcp-server-firecrawl",
    "env": {
      "FIRECRAWL_API_KEY": "your-api-key"
    }
  }
}

克劳德VSCode扩展

添加到MCP配置中:

{
  "mcpServers": {
    "firecrawl": {
      "command": "mcp-server-firecrawl",
      "env": {
        "FIRECRAWL_API_KEY": "your-api-key"
      }
    }
  }
}

使用示例

Web剪贴

// Basic scraping
{
  name: "scrape_url",
  arguments: {
    url: "https://example.com",
    formats: ["markdown"],
    onlyMainContent: true
  }
}

// Advanced extraction
{
  name: "scrape_url",
  arguments: {
    url: "https://example.com/blog",
    jsonOptions: {
      prompt: "Extract article content",
      schema: {
        title: "string",
        content: "string"
      }
    },
    mobile: true,
    blockAds: true
  }
}

网站爬行

// Basic crawling
{
  name: "crawl",
  arguments: {
    url: "https://example.com",
    maxDepth: 2,
    limit: 100
  }
}

// Advanced crawling
{
  name: "crawl",
  arguments: {
    url: "https://example.com",
    maxDepth: 3,
    includePaths: ["/blog", "/products"],
    excludePaths: ["/admin"],
    ignoreQueryParameters: true
  }
}

现场测绘

// Generate site map
{
  name: "map",
  arguments: {
    url: "https://example.com",
    includeSubdomains: true,
    limit: 1000
  }
}

数据提取

// Extract structured data
{
  name: "extract",
  arguments: {
    urls: ["https://example.com/product1", "https://example.com/product2"],
    prompt: "Extract product details",
    schema: {
      name: "string",
      price: "number",
      description: "string"
    }
  }
}

配置

看 配置指南 有关详细的设置选项。

API文档

看 API文档 了解详细的端点规范。

发展

# Install dependencies
npm install

# Build
npm run build

# Run tests
npm test

# Start in development mode
npm run dev

例子

检查 示例 更多使用示例的目录:

错误处理

服务器实现了强大的错误处理:

  • 指数回退的速率限制
  • 自动重试
  • 详细的错误消息
  • 调试记录

安全

  • API密钥保护
  • 请求验证
  • 域名分配
  • 速率限制
  • 安全错误消息

贡献

看 贡献.md 关于贡献指南。

许可证

MIT许可证-请参阅 许可证 了解详情。