MCP Server Fetch Python

by tatn

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 content from JavaScript-rendered pages through a headless browser, making it possible to extract content from modern web applications and SPAs

  • Converts web page content to well-formatted Markdown while preserving structural elements like tables and definition lists

  • Leverages OpenAI's vision capabilities for AI-powered content extraction from media files (images and videos) when provided with an API key

mcp-server-fetch-python

一个 MCP 服务器,用于获取网页内容并将其转换为各种格式。该服务器提供全面的工具来从网页中提取内容,包括对 JavaScript 渲染内容和媒体文件的支持。

特征

工具

该服务器提供了四种专用工具:

  • get-raw-text :直接从 URL 中提取原始文本内容,无需浏览器渲染
    • 参数:
      • url :目标网页的 URL(文本、JSON、XML、csv、tsv 等)(必需)
    • 最适合用于结构化数据格式或需要快速、直接访问的情况
  • get-rendered-html :使用无头浏览器获取完全渲染的 HTML 内容
    • 参数:
      • url :目标网页的URL(必填)
    • 对于需要 JavaScript 渲染的现代 Web 应用程序和 SPA 至关重要
  • get-markdown :将网页内容转换为格式良好的 Markdown
    • 参数:
      • url :目标网页的URL(必填)
    • 保留结构元素,同时提供清晰、可读的文本输出
  • get-markdown-from-media :从媒体文件中提取 AI 驱动的内容
    • 参数:
      • url :目标媒体文件(图片、视频)的 URL(必需)
    • 利用计算机视觉和 OCR 进行视觉内容分析
    • 需要在环境变量中设置有效的 OPENAI_API_KEY
    • 如果未设置 API 密钥或处理媒体文件时出现问题,将返回错误消息

用法

克劳德桌面

要与 Claude Desktop 一起使用,请添加服务器配置:

在 MacOS 上: ~/Library/Application\ Support/Claude/claude_desktop_config.json
在 Windows 上: %APPDATA%/Claude/claude_desktop_config.json

"mcpServers": { "mcp-server-fetch-python": { "command": "uvx", "args": [ "mcp-server-fetch-python" ] } }

环境变量

可以配置以下环境变量:

  • OPENAI_API_KEY :使用get-markdown-from-media工具时必需。此密钥用于 AI 驱动的图像分析和内容提取。
  • PYTHONIOENCODING :如果在输出中遇到字符编码问题,请设置为“utf-8”。
  • MODEL_NAME :指定要使用的模型名称。默认为“gpt-4o”。
"mcpServers": { "mcp-server-fetch-python": { "command": "uvx", "args": [ "mcp-server-fetch-python" ], "env": { "OPENAI_API_KEY": "sk-****", "PYTHONIOENCODING": "utf-8", "MODEL_NAME": "gpt-4o", } } }

本地安装

或者,您可以在本地安装并运行服务器:

git clone https://github.com/tatn/mcp-server-fetch-python.git cd mcp-server-fetch-python uv sync uv build

然后将以下配置添加到Claude Desktop配置文件中:

"mcpServers": { "mcp-server-fetch-python": { "command": "uv", "args": [ "--directory", "path\\to\\mcp-server-fetch-python", # Replace with actual path to the cloned repository "run", "mcp-server-fetch-python" ] } }

发展

调试

您可以使用npx通过以下命令启动 MCP Inspector:

npx @modelcontextprotocol/inspector uvx mcp-server-fetch-python
npx @modelcontextprotocol/inspector uv --directory path\\to\\mcp-server-fetch-python run mcp-server-fetch-python

You must be authenticated.

A
security – no known vulnerabilities
A
license - permissive license
A
quality - confirmed to work

用于获取 Web 内容并将其转换为各种格式的 MCP 服务器。

  1. Features
    1. Tools
  2. Usage
    1. Claude Desktop
  3. Environment Variables
    1. Local Installation
  4. Development
    1. Debugging
ID: 8d0zm2o56d