Token导航 LogoToken导航TokenDH.com
File MCP Python logo
文档知识stdio官方级别未说明来源级核验

File MCP Python

MCP Server

一个基于Pandoc的文档转换服务器,支持多种格式之间的文件创建和转换。

工具数

2

提示词数

0

GitHub Stars

0

资源数

0
文档转换多格式支持Python文件处理

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

作者 / 组织

lequan310

提供方

lequan310

最后核验

2026/5/17 20:23

运行时

Python

快速接入

先看主来源和安装命令,再打开仓库或文档;下面只保留这个条目的关键接入事实。

命令预览

uv run server.py

详细介绍

File MCP

A Model Context Protocol (MCP) server for document conversion using Pandoc. This server provides tools to create and convert files between various document formats through the FastMCP framework.

Features

  • Create files from text content: Convert markdown or HTML content to various document formats
  • Convert existing files: Transform documents between different formats
  • Multiple format support: Handle 10+ document formats including PDF, DOCX, HTML, Markdown, LaTeX, and more
  • Advanced Pandoc features: Support for reference documents, custom filters, and defaults files
  • Intelligent path resolution: Automatic filter path resolution from multiple locations

Supported Formats

  • Text: .txt, .md (Markdown)
  • Web: .html, .htm
  • Office: .docx, .doc, .odt
  • PDF: .pdf (requires TeX Live with xelatex)
  • Publishing: .epub, .latex, .tex, .rst
  • Notebooks: .ipynb (Jupyter Notebook)

Installation

This project uses uv for dependency management.

Prerequisites

  • Python 3.13 or higher
  • Pandoc must be installed and available in your PATH
  • For PDF generation: TeX Live or similar LaTeX distribution

Setup

# Clone the repository
git clone 
cd file-mcp

# Install dependencies with uv
uv sync

# Or manually install dependencies
uv add fastmcp pypandoc-binary pyyaml

Usage

Running the Server

# Using uv
uv run server.py

# Or with Python directly
python server.py

Available Tools

1. create_file

Create a new file from text content (markdown or HTML).

Parameters:

  • content (str): The text content to convert (markdown or HTML)
  • output_file (str): Complete path where to save the file (including extension)
  • input_format (str): Source format of the content (markdown or html)
  • reference_doc (str, optional): Path to a reference DOCX file for styling (docx output only)
  • filters (list[str], optional): List of Pandoc filter paths to apply
  • defaults_file (str, optional): Path to a Pandoc defaults YAML file

Example:

# Convert markdown content to PDF
create_file(
    content="# Hello World\n\nThis is a test document.",
    output_file="D:/documents/hello.pdf",
    input_format="markdown"
)

# Convert HTML to DOCX with custom styling
create_file(
    content="
Report

Content here
",
    output_file="/home/user/report.docx",
    input_format="html",
    reference_doc="/templates/corporate.docx"
)

2. convert_file

Convert an existing file from one format to another.

Parameters:

  • input_file (str): Complete path to the input file to convert (including extension)
  • output_file (str): Complete path where to save the converted file (including extension)
  • reference_doc (str, optional): Path to a reference DOCX file for styling (docx output only)
  • filters (list[str], optional): List of Pandoc filter paths to apply
  • defaults_file (str, optional): Path to a Pandoc defaults YAML file

Example:

# Convert DOCX to PDF
convert_file(
    input_file="D:/documents/report.docx",
    input_format="docx",
    output_file="D:/documents/report.pdf"
)

# Convert Markdown to HTML with custom filters
convert_file(
    input_file="/home/user/notes.md",
    input_format="markdown",
    output_file="/home/user/notes.html",
    filters=["custom-filter.py"],
    defaults_file="/config/pandoc-defaults.yaml"
)

Advanced Features

Pandoc Filters

The server supports custom Pandoc filters for advanced document processing. Filters are searched in multiple locations:

  1. Relative to the current working directory
  2. Relative to the defaults file directory (if provided)
  3. In ~/.pandoc/filters/ directory

Filters must be executable. The server will attempt to make them executable automatically if needed.

Defaults Files

You can provide a Pandoc defaults YAML file to configure conversion options. The defaults file should be a valid YAML dictionary containing Pandoc options.

Example defaults file:

variables:
  geometry: margin=1in
  fontsize: 12pt
pdf-engine: xelatex
number-sections: true

Reference Documents

For DOCX output, you can provide a reference document that defines styles, fonts, and formatting. This allows you to maintain consistent branding and styling across generated documents.

PDF Generation

PDF generation requires a LaTeX engine (xelatex is used by default). The server automatically adds:

  • --pdf-engine=xelatex
  • -V geometry:margin=1in

Ensure you have TeX Live or a similar LaTeX distribution installed.

Development

Project Structure

file-mcp/
├── server.py    # Main MCP server with conversion tools
├── pyproject.toml       # Project dependencies and metadata
├── ruff.toml           # Ruff linter configuration
└── README.md           # This file

Dependencies

  • fastmcp: Framework for building MCP servers
  • pypandoc-binary: Python wrapper for Pandoc (includes Pandoc binary)
  • pyyaml: YAML parser for defaults files

Development Tools

# Install development dependencies
uv add --dev ruff

# Run linter
uv run ruff check .

# Format code
uv run ruff format .

Error Handling

The server provides detailed error messages for common issues:

  • Missing files: Clear messages when input files or reference documents don't exist
  • Invalid formats: Validation of input/output format compatibility
  • Filter errors: Helpful messages when filters are not found or not executable
  • Pandoc errors: Detection and reporting of Pandoc-specific issues
  • Defaults file errors: Validation of YAML structure and content

Environment Variables

  • PANDOC_OUTPUT_DIR: Automatically set to the output file directory during conversion

License

[Add your license here]

Contributing

[Add contribution guidelines here]

Support

For issues and questions:

  • Check that Pandoc is installed: pandoc --version
  • For PDF issues, verify TeX Live installation: xelatex --version
  • Review Pandoc documentation: https://pandoc.org/MANUAL.html

目录标签

目录标签

文档转换多格式支持Python文件处理本地部署Pandoc集成自动化工具

接入字段

传输方式(transport,传输协议)

stdio

鉴权方式(authType,认证方式)

none

运行时(runtime,运行环境)

Python

工具数量(toolCount,工具数)

2

资源数量(resourceCount,资源数)

0

提示词数量(promptCount,提示词数)

0

权限和风险

stdionone部署方式未说明

接入前请确认传输方式、认证方式和部署位置,并根据实际工具能力限制访问范围。

安装前确认

不要直接授予不必要的文件、网络或账号权限;先核对安装命令和配置内容。

来源信息

继续浏览同类 MCP