MCP-PDF2MD

MCP-PDF2MD

Converts PDF files from local storage or URLs to structured Markdown format using Mistral AI's OCR API, preserving document structure and extracting images.

Category
访问服务器

README

MCP-PDF2MD

MCP-PDF2MD Service

An MCP-based high-performance PDF to Markdown conversion service powered by the Mistral AI OCR API, supporting batch processing for local files and URL links with structured output.

Key Features

  • Format Conversion: Convert PDF files to structured Markdown format.
  • Multi-source Support: Process both local PDF files and remote PDF URLs.
  • MCP Integration: Seamlessly integrates with LLM clients like Claude Desktop.
  • Structure Preservation: Aims to maintain the original document structure, including headings, paragraphs, and lists.
  • Image Extraction: Automatically extracts images from the PDF and saves them locally.
  • High-Quality Extraction: Leverages Mistral AI's state-of-the-art OCR for high-quality text and layout information extraction.

System Requirements

  • Python 3.10+
  • uv for environment and package management (recommended)

Quick Start

  1. Clone the repository and enter the directory:

    git clone https://github.com/zicez/mcp-pdf2md.git
    cd mcp-pdf2md
    
  2. Install dependencies with uv:

    uv sync
    
  3. Configure environment variables:

    Create a .env file in the project root directory and set your Mistral AI API key:

    MISTRAL_API_KEY=your_mistral_api_key_here
    
  4. Start the service:

    uv run pdf2md
    

Command Line Arguments

The server supports the following command line arguments:

  • --output-dir: Specify the directory to save converted Markdown files and images. Defaults to ./downloads.

Example:

uv run pdf2md --output-dir /path/to/my/output

Claude Desktop Configuration

Add the following configuration in Claude Desktop:

Windows:

{
  "mcpServers": {
    "pdf2md": {
      "command": "uv",
      "args": [
        "--directory",
        "C:\\path\\to\\mcp-pdf2md",
        "run",
        "pdf2md",
        "--output-dir",
        "C:\\path\\to\\output"
      ],
      "env": {
        "MISTRAL_API_KEY": "your_mistral_api_key_here"
      }
    }
  }
}

Linux/macOS:

{
  "mcpServers": {
    "pdf2md": {
      "command": "uv",
      "args": [
        "--directory",
        "/path/to/mcp-pdf2md",
        "run",
        "pdf2md",
        "--output-dir",
        "/path/to/output"
      ],
      "env": {
        "MISTRAL_API_KEY": "your_mistral_api_key_here"
      }
    }
  }
}

Note about API Key Configuration: You can set the API key in two ways:

  1. In the .env file within the project directory (recommended for development).
  2. In the Claude Desktop configuration as shown above (recommended for regular use).

If you set the API key in both places, the one in the Claude Desktop configuration will take precedence.

MCP Tools

The server provides the following MCP tools:

  • convert_pdf_url(url: str): Converts a PDF from a URL to Markdown. Supports single URLs or multiple URLs separated by spaces, commas, or newlines.
  • convert_pdf_file(file_path: str): Converts a local PDF file to Markdown. Supports single or multiple file paths separated by spaces, commas, or newlines.

Getting a Mistral AI API Key

This project relies on the Mistral AI API for PDF content extraction. To obtain an API key:

  1. Visit the Mistral AI Platform and create an account.
  2. Navigate to the "API Keys" section in your workspace.
  3. Create a new secret key.
  4. Copy the generated API key.
  5. Use this key as the value for MISTRAL_API_KEY.

License

MIT License - see the LICENSE file for details.

Credits

This project uses the Mistral AI OCR API.

推荐服务器

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 模型以安全和受控的方式获取实时的网络信息。

官方
精选