关于 FileToPDF
FileToPDF 是通过 FileToPDF API 将文件、HTML 和 Markdown 转为 PDF 的 MCP 服务。支持本地或托管连接,并可将 PDF 作为资源返回或保存到磁盘。
主要功能
- 01将公共 URL 文件转换为 PDF
- 02渲染带 CSS 和版式选项的 HTML
- 03渲染带 CSS 和版式选项的 Markdown
- 04检查 API 密钥和剩余额度
- 05将 PDF 作为资源返回或保存到磁盘
适用场景
- 01将发票和办公文档转为 PDF
- 02从 HTML 页面生成 PDF
- 03将 Markdown 报告导出为 PDF
MCP 相关
向 MCP 客户端提供转换和账户查询工具。可通过本地 stdio 或托管 Streamable HTTP 端点连接,并使用 FileToPDF API 密钥。
配置
远程服务无需本地安装。选择你使用的客户端,复制配置或使用一键安装。
https://api.filetopdf.dev/mcpclaude mcp add --transport http dev-filetopdf-filetopdf https://api.filetopdf.dev/mcp{"mcpServers":{"dev-filetopdf-filetopdf":{"type":"http","url":"https://api.filetopdf.dev/mcp"}}}在 Cursor 中打开{"servers":{"dev-filetopdf-filetopdf":{"type":"http","url":"https://api.filetopdf.dev/mcp"}}}在 VS Code 中打开{"mcpServers":{"dev-filetopdf-filetopdf":{"type":"http","url":"https://api.filetopdf.dev/mcp"}}}{"mcpServers":{"dev-filetopdf-filetopdf":{"serverUrl":"https://api.filetopdf.dev/mcp"}}}命令在终端中运行;JSON 粘贴到对应客户端的 MCP 配置后重启。需要授权的服务会在首次连接时提示登录。
https://api.filetopdf.dev/mcp需要授权工具
4此工具无需参数。
详细介绍
FileToPDF MCP 服务
这是一个适用于 FileToPDF 的 Model Context Protocol 服务。它让任何 MCP 客户端——Claude Desktop、Claude Code、Cursor、Cline、VS Code、ChatGPT、n8n、Make,或你自己的 Agent——都能通过自然语言将文件、HTML 和 Markdown 转换为 PDF:发票、报告、文档、DOCX/XLSX/PPTX、图片、网页等。
使用你自己的 API 密钥——访问 https://filetopdf.dev,一键免费获取(免费转换 10 次,无需注册)。
工具
| 工具 | 功能 |
|---|---|
get_account | 检查 API 密钥并显示套餐和剩余额度。免费,不消耗额度。 |
convert_file | 将公共 URL中的文件(DOCX、XLSX、PPTX、图片、HTML、MD、PDF……)转换为 PDF。 |
convert_html | 通过 Chromium 将原始 HTML 字符串(可选 CSS 和布局选项)渲染为像素级精确的 PDF。 |
convert_markdown | 将原始 Markdown 字符串(可选 CSS 和布局选项)渲染为整洁的 PDF。 |
每个转换工具都会返回元数据摘要,并且将 PDF 作为嵌入式 application/pdf 资源(base64)返回,因此支持此功能的客户端可以保存文件。设置 FILETOPDF_OUTPUT_DIR 环境变量,或传入 save_path,也可以将 PDF 写入磁盘。
布局选项(landscape、paperWidth/Height、边距、scale、pdfa、密码等)适用于 Pro、Scale 和免费试用版;Starter/Basic 套餐使用这些选项会返回升级错误。每次成功转换消耗 1 个额度;失败不收费。
快速开始(本地 / stdio)
Cursor——一键安装: 添加到 Cursor (然后将占位符替换为你的密钥)。
Claude Desktop / Cline / 任意 stdio 客户端——添加到 MCP 配置中
(claude_desktop_config.json、cline_mcp_settings.json 等):
{
"mcpServers": {
"filetopdf": {
"command": "npx",
"args": ["-y", "filetopdf-mcp"],
"env": { "FILETOPDF_API_KEY": "sk_live_YOUR_API_KEY" }
}
}
}
Claude Code:
claude mcp add filetopdf -e FILETOPDF_API_KEY=sk_live_YOUR_API_KEY -- npx -y filetopdf-mcp
VS Code(.vscode/mcp.json 或通过 MCP: Add Server):
{
"servers": {
"filetopdf": {
"type": "stdio",
"command": "npx",
"args": ["-y", "filetopdf-mcp"],
"env": { "FILETOPDF_API_KEY": "sk_live_YOUR_API_KEY" }
}
}
}
托管 / 远程(Streamable HTTP)——无需安装
托管端点地址为 https://api.filetopdf.dev/mcp。通过 x-api-key 请求头、Authorization: Bearer 请求头或 ?apiKey= 查询参数,使用你自己的密钥进行身份验证。
{
"mcpServers": {
"filetopdf": {
"type": "streamable-http",
"url": "https://api.filetopdf.dev/mcp",
"headers": { "x-api-key": "sk_live_YOUR_API_KEY" }
}
}
}
这也是可粘贴到任何包含 MCP 客户端步骤的平台中的 URL——n8n(MCP Client Tool)、Make(MCP Client)、Zapier(MCP Client beta)、Relay.app(Call MCP tool)、Flowise、Langflow、Dify、LibreChat、AnythingLLM,或 Agent 框架(OpenAI Agents SDK、LangChain、CrewAI、Vercel AI SDK)。
如需改为自托管:
npm run build && npm run start:http # listens on $PORT (default 8080) at /mcp
其中包含用于容器托管的 Dockerfile(Smithery、Fly、Render、Cloud Run)。
开发与测试
npm install
npm run build # tsc -> dist/
npm test # spawns the built stdio server, runs a live conversion
npm test 会读取 FILETOPDF_API_KEY,或从被 git 忽略的 .env 文件中读取 API_KEY=。
链接
- 网站和即时免费 API 密钥:https://filetopdf.dev
- API 文档:https://filetopdf.dev/documentation
- 官方 MCP 注册表名称:
dev.filetopdf/filetopdf-mcp
许可证
评论
一个开放协议,规定了 AI 应用如何以统一方式连接外部工具与数据源。客户端负责与模型对话,MCP 服务负责提供工具、资源和提示模板,两者通过标准消息通信,同一个服务可以被不同客户端复用。