Paperless文档助手
启用与Paperless-NGX API服务器的交互,支持通过自然语言接口进行文档管理、标记和元数据操作。
MCP 服务配置
复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用
{
"mcpServers": {
"paperless": {
"args": [
"paperless-mcp",
"http://your-paperless-instance:8000",
"your-api-token"
],
"command": "npx"
}
}
}
该服务需要配置环境变量:PAPERLESS_API_TOKEN、PAPERLESS_URL
可用工具 (17 个)
该服务在 MCP 协议中暴露的工具,AI 可按需调用
bulk_edit_documents 13 个参数 需填 2 项
Perform bulk operations on documents
必填参数:documents、method
post_document 10 个参数 需填 2 项
Upload a new document to Paperless-NGX
必填参数:file、filename
list_documents 2 个参数
List all documents
该工具无需必填参数,直接调用即可
get_document 1 个参数 需填 1 项
Get a specific document by ID
必填参数:id
search_documents 1 个参数 需填 1 项
Search documents using full-text query
必填参数:query
download_document 2 个参数 需填 1 项
Download a document by ID
必填参数:id
list_tags
List all tags
该工具无需必填参数,直接调用即可
create_tag 4 个参数 需填 1 项
Create a new tag
必填参数:name
update_tag 5 个参数 需填 2 项
Update an existing tag
必填参数:id、name
delete_tag 1 个参数 需填 1 项
Delete a tag
必填参数:id
bulk_edit_tags 5 个参数 需填 2 项
Bulk edit tags (set permissions or delete)
必填参数:tag_ids、operation
list_correspondents
List all correspondents
该工具无需必填参数,直接调用即可
create_correspondent 3 个参数 需填 1 项
Create a new correspondent
必填参数:name
bulk_edit_correspondents 5 个参数 需填 2 项
Bulk edit correspondents (set permissions or delete)
必填参数:correspondent_ids、operation
list_document_types
List all document types
该工具无需必填参数,直接调用即可
create_document_type 3 个参数 需填 1 项
Create a new document type
必填参数:name
bulk_edit_document_types 5 个参数 需填 2 项
Bulk edit document types (set permissions or delete)
必填参数:document_type_ids、operation
服务介绍
Paperless-NGX MCP 服务器
这是一个用于与 Paperless-NGX API 服务器交互的 MCP(Model Context Protocol)服务器。该服务器提供了管理文档、标签、通信者和文档类型的工具。
快速开始
通过 Smithery 安装
要通过 Smithery 自动安装 Paperless NGX MCP 服务器到 Claude 桌面版:
npx -y @smithery/cli install @nloui/paperless-mcp --client claude
手动安装
- 安装 MCP 服务器:
npm install -g paperless-mcp
- 将其添加到你的 Claude 的 MCP 配置中:
对于 VSCode 扩展,编辑 ~/Library/Application Support/Code/User/globalStorage/saoudrizwan.claude-dev/settings/cline_mcp_settings.json:
{
"mcpServers": {
"paperless": {
"command": "npx",
"args": ["paperless-mcp", "http://your-paperless-instance:8000", "your-api-token"]
}
}
}
对于 Claude 桌面应用程序,编辑 ~/Library/Application Support/Claude/claude_desktop_config.json:
{
"mcpServers": {
"paperless": {
"command": "npx",
"args": ["paperless-mcp", "http://your-paperless-instance:8000", "your-api-token"]
}
}
}
-
获取你的 API 令牌:
- 登录到你的 Paperless-NGX 实例
- 点击右上角的用户名
- 选择 "我的资料"
- 点击循环箭头按钮生成一个新的令牌
-
替换 MCP 配置中的占位符:
- 将
http://your-paperless-instance:8000替换为你的 Paperless-NGX URL - 将
your-api-token替换为你刚刚生成的令牌
- 将
完成!现在你可以让 Claude 帮助你管理 Paperless-NGX 文档了。
使用示例
这里有一些你可以要求 Claude 做的事情:
- "显示所有标记为 'Invoice' 的文档"
- "搜索包含 'tax return' 的文档"
- "创建一个名为 'Receipts' 的新标签,颜色为 #FF0000"
- "下载文档 #123"
- "列出所有通信者"
- "创建一个名为 'Bank Statement' 的新文档类型"
可用工具
文档操作
list_documents
获取分页的所有文档列表。
参数:
- page (可选): 页码
- page_size (可选): 每页的文档数量
list_documents({
page: 1,
page_size: 25
})
get_document
通过 ID 获取特定文档。
参数:
- id: 文档 ID
get_document({
id: 123
})
search_documents
在文档中进行全文搜索。
参数:
- query: 搜索查询字符串
search_documents({
query: "invoice 2024"
})
download_document
通过 ID 下载文档文件。
参数:
- id: 文档 ID
- original (可选): 如果为 true,则下载原始文件而不是归档版本
download_document({
id: 123,
original: false
})
bulk_edit_documents
对多个文档执行批量操作。
参数:
- documents: 文档ID数组
- method: 以下之一:
- set_correspondent: 为文档设置联系人
- set_document_type: 为文档设置文档类型
- set_storage_path: 为文档设置存储路径
- add_tag: 为文档添加标签
- remove_tag: 从文档中移除标签
- modify_tags: 添加和/或移除多个标签
- delete: 删除文档
- reprocess: 重新处理文档
- set_permissions: 设置文档权限
- merge: 合并多个文档
- split: 将一个文档拆分为多个文档
- rotate: 旋转文档页面
- delete_pages: 从文档中删除特定页面
- 基于method的附加参数:
- correspondent: 用于set_correspondent的ID
- document_type: 用于set_document_type的ID
- storage_path: 用于set_storage_path的ID
- tag: 用于add_tag/remove_tag的ID
- add_tags: 用于modify_tags的标签ID数组
- remove_tags: 用于modify_tags的标签ID数组
- permissions: 用于set_permissions的对象,包含所有者、权限和合并标志
- metadata_document_id: 用于指定元数据来源的ID
- delete_originals: 用于merge/split的布尔值
- pages: 用于split "[1,2-3,4,5-7]" 或 delete_pages "[2,3,4]" 的字符串
- degrees: 用于rotate的角度(90, 180, 或 270)
示例:
// Add a tag to multiple documents
bulk_edit_documents({
documents: [1, 2, 3],
method: "add_tag",
tag: 5
})
// Set correspondent and document type
bulk_edit_documents({
documents: [4, 5],
method: "set_correspondent",
correspondent: 2
})
// Merge documents
bulk_edit_documents({
documents: [6, 7, 8],
method: "merge",
metadata_document_id: 6,
delete_originals: true
})
// Split document into parts
bulk_edit_documents({
documents: [9],
method: "split",
pages: "[1-2,3-4,5]"
})
// Modify multiple tags at once
bulk_edit_documents({
documents: [10, 11],
method: "modify_tags",
add_tags: [1, 2],
remove_tags: [3, 4]
})
post_document
向Paperless-NGX上传新文档。
参数:
- file: Base64编码的文件内容
- filename: 文件名
- title (可选): 文档标题
- created (可选): 文档创建日期时间(例如 "2024-01-19" 或 "2024-01-19 06:15:00+02:00")
- correspondent (可选): 联系人的ID
- document_type (可选): 文档类型的ID
- storage_path (可选): 存储路径的ID
- tags (可选): 标签ID数组
- archive_serial_number (可选): 归档序列号
- custom_fields (可选): 自定义字段ID数组
post_document({
file: "base64_encoded_content",
filename: "invoice.pdf",
title: "January Invoice",
created: "2024-01-19",
correspondent: 1,
document_type: 2,
tags: [1, 3],
archive_serial_number: "2024-001"
})
标签操作
list_tags
获取所有标签。
list_tags()
create_tag
创建新标签。
参数:
- name: 标签名称
- color (可选): 十六进制颜色代码(例如 "#ff0000")
- match (可选): 匹配的文本模式
- matching_algorithm (可选): 以下之一:"any", "all", "exact", "regular expression", "fuzzy"
create_tag({
name: "Invoice",
color: "#ff0000",
match: "invoice",
matching_algorithm: "fuzzy"
})
联系人操作
list_correspondents
获取所有联系人。
list_correspondents()
create_correspondent
创建新联系人。
参数:
- name: 联系人名称
- match (可选): 匹配的文本模式
- matching_algorithm (可选): 以下之一:"any", "all", "exact", "regular expression", "fuzzy"
create_correspondent({
name: "ACME Corp",
match: "ACME",
matching_algorithm: "fuzzy"
})
文档类型操作
list_document_types
获取所有文档类型。
list_document_types()
create_document_type
创建新文档类型。
参数:
- name: 文档类型名称
- match (可选): 匹配的文本模式
- matching_algorithm (可选): 以下之一:"any", "all", "exact", "regular expression", "fuzzy"
create_document_type({
name: "Invoice",
match: "invoice total amount due",
matching_algorithm: "any"
})
错误处理
如果发生以下情况,服务器将显示清晰的错误消息:
- Paperless-NGX 的 URL 或 API 令牌不正确
- Paperless-NGX 服务器无法访问
- 请求的操作失败
- 提供的参数无效
开发
想要贡献代码或修改服务器?以下是你需要知道的内容:
- 克隆仓库
- 安装依赖项:
npm install
- 对
server.js进行修改 - 本地测试:
node server.js http://localhost:8000 your-test-token
该服务器使用以下技术构建:
API 文档
此 MCP 服务器实现了 Paperless-NGX REST API 的端点。有关底层 API 的更多详细信息,请参阅官方文档。