MCP URL Fetcher

by nathanonn
Verified

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

Integrations

  • Enables fetching and rendering of README files directly from GitHub repositories, making documentation accessible for analysis.

  • Provides complete Markdown rendering capabilities, allowing fetching and processing of Markdown content from various web sources.

MCP URL 格式转换器

模型上下文协议 (MCP) 服务器可从任何 URL 获取内容并将其转换为所需的输出格式。

概述

MCP URL 格式转换器提供从任何 Web URL 检索内容并将其转换为各种格式(HTML、JSON、Markdown 或纯文本)的工具,无论原始内容类型如何。它旨在与任何兼容 MCP 的客户端(包括 Claude for Desktop)配合使用,使 LLM 能够以一致的格式访问、转换和分析 Web 内容。

特征

  • 🔄格式转换:将任何 Web 内容转换为 HTML、JSON、Markdown 或纯文本
  • 🌐通用输入支持:处理网站、API、原始文件等
  • 🔍自动内容检测:智能识别源格式
  • 🧰强大的库支持:使用行业标准库:
    • Cheerio 用于 HTML 解析
    • 标记为 Markdown 处理
    • 用于 XML 处理的 Fast-XML-Parser
    • CSVtoJSON 用于 CSV 转换
    • SanitizeHTML 安全性
    • 拒绝 HTML 到 Markdown 的转换
  • 🔧高级格式处理
    • 使用元数据提取进行 HTML 解析
    • JSON 漂亮打印和结构保存
    • Markdown 渲染与样式
    • CSV 到表格的转换
    • XML 到 JSON 的转换
  • 📜历史记录跟踪:维护最近获取的 URL 的日志
  • 🛡️安全焦点:内容清理以防止 XSS 攻击

安装

先决条件

  • Node.js 16.x 或更高版本
  • npm 或 yarn

快速入门

  1. 克隆存储库:
    git clone https://github.com/yourusername/mcp-url-converter.git cd mcp-url-converter
  2. 安装依赖项:
    npm install
  3. 构建项目:
    npm run build
  4. 运行服务器:
    npm start

与 Claude for Desktop 集成

  1. 打开您的 Claude for Desktop 配置文件:
    • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
    • Windows: %APPDATA%\Claude\claude_desktop_config.json
  2. 将 URL 转换器服务器添加到您的配置中:
    { "mcpServers": { "url-converter": { "command": "node", "args": ["/absolute/path/to/mcp-url-converter/build/index.js"] } } }
  3. 重启 Claude 桌面版

可用工具

fetch

从任何 URL 获取内容并自动检测最佳输出格式。

参数:

  • url (字符串,必需):获取内容的 URL
  • format (字符串,可选):要转换为的格式( autohtmljsonmarkdowntext )。默认值: auto

例子:

Can you fetch https://example.com and choose the best format to display it?

fetch-json

从任何 URL 获取内容并将其转换为 JSON 格式。

参数:

  • url (字符串,必需):获取内容的 URL
  • prettyPrint (布尔值,可选):是否以美观的方式打印 JSON。默认值: true

例子:

Can you fetch https://example.com and convert it to JSON format?

fetch-html

从任何 URL 获取内容并将其转换为 HTML 格式。

参数:

  • url (字符串,必需):获取内容的 URL
  • extractText (布尔值,可选):是否仅提取文本内容。默认值: false

例子:

Can you fetch https://api.example.com/users and convert it to HTML?

fetch-markdown

从任何 URL 获取内容并将其转换为 Markdown 格式。

参数:

  • url (字符串,必需):获取内容的 URL

例子:

Can you fetch https://example.com and convert it to Markdown?

fetch-text

从任何 URL 获取内容并将其转换为纯文本格式。

参数:

  • url (字符串,必需):获取内容的 URL

例子:

Can you fetch https://example.com and convert it to plain text?

web-searchdeep-research

这些工具为 Perplexity 搜索功能提供接口(当 MCP 主机支持时)。

可用资源

recent-urls://list

返回最近获取的带有时间戳和输出格式的 URL 列表。

例子:

What URLs have I fetched recently?

安全

该服务器实施了多项安全措施:

  • 使用sanitize-html进行 HTML 清理以防止 XSS 攻击
  • 处理之前的内容验证
  • 错误处理和安全默认值
  • 使用 Zod 进行输入参数验证
  • 安全输出编码

测试

您可以使用 MCP 检查器测试服务器:

npm run test

故障排除

常见问题

  1. 连接错误:验证 URL 是否可访问且格式正确
  2. 转换错误:某些复杂内容可能无法在格式之间顺利转换
  3. 跨域问题:某些网站可能会阻止来自未知来源的请求

调试模式

要获取更多调试信息,请设置DEBUG环境变量:

DEBUG=mcp:* npm start

执照

该项目根据 MIT 许可证获得许可 - 有关详细信息,请参阅 LICENSE 文件。

致谢

  • 使用模型上下文协议构建
  • 使用现代的、积极维护的库,并注重安全
  • 基于 OWASP 建议的清理方法

最后更新:2025年3月29日

-
security - not tested
F
license - not found
-
quality - not tested

模型上下文协议服务器使 LLM 能够获取和处理多种格式(HTML、JSON、Markdown、文本)的 Web 内容,并具有自动格式检测功能。

  1. Overview
    1. Features
      1. Installation
        1. Prerequisites
        2. Quick Start
      2. Integration with Claude for Desktop
        1. Available Tools
          1. fetch
          2. fetch-json
          3. fetch-html
          4. fetch-markdown
          5. fetch-text
          6. web-search and deep-research
        2. Available Resources
          1. recent-urls://list
        3. Security
          1. Testing
            1. Troubleshooting
              1. Common Issues
              2. Debug Mode
            2. License
              1. Acknowledgments
                ID: 52yiq4sifj