EPUB解析器

kala51773/epub-parser-mcp
0 Stars 89 次浏览 2 更新于 2026-08-23

一个基于TypeScript的模型上下文协议(MCP)服务器,用于解析EPUB文件并通过AI辅助提取内容。它支持元数据提取、目录解析、文本内容提取、高级搜索和资源访问。

MCP 服务配置

复制以下 JSON 到 OPClaw 或其他 MCP 客户端的配置文件中即可使用

{
  "mcpServers": {
    "epub-parser": {
      "args": [
        "-m",
        "epub_parser_mcp"
      ],
      "autoApprove": [],
      "command": "python",
      "disabled": false,
      "timeout": 60,
      "type": "stdio",
      "workingDirectory": "epub-parser-mcp"
    }
  }
}

服务介绍

EPUB 解析器 MCP 服务器 📚

TypeScript
MCP

Node.js

一个强大的基于 TypeScript 的模型上下文协议 (MCP) 服务器,用于解析 EPUB 文件并借助 AI 提取内容。专为与 Claude Desktop 等 AI 助手无缝集成而构建。

✨ 特性

  • 📄 元数据提取 - 提取 EPUB 元数据(标题、作者、出版商、语言等)
  • 📑 目录解析 - 解析分层的目录结构
  • 📖 文本内容提取 - 从章节中提取干净的文本,并提供格式化选项
  • 🔍 高级搜索 - 在 EPUB 文件中进行大小写敏感的文本搜索
  • 🌐 资源访问 - 通过 URI 模板访问 EPUB 资源
  • 🚀 TypeScript - 使用 TypeScript 构建,以确保类型安全和更好的开发体验
  • 高性能 - 优化的 EPUB 解析算法
  • 🔧 MCP 标准 - 完全符合 Model Context Protocol 标准

🚀 快速开始

前提条件

  • Node.js 18 或更高版本
  • npm 或 yarn

安装


# Clone the repository

git clone https://github.com/your-username/epub-parser-mcp.git

cd epub-parser-mcp



# Install dependencies

npm install



# Build the project

npm run build

与 Claude Desktop 配合使用

将以下配置添加到您的 Claude Desktop 配置中:


{

  "mcpServers": {

    "epub-parser": {

      "command": "node",

      "args": ["/path/to/epub-parser-mcp/build/index.js"]

    }

  }

}

📖 使用示例

获取 EPUB 信息

{
  "filePath": "/path/to/book.epub"
}

提取目录

{
  "filePath": "/path/to/book.epub"
}

提取文本内容

{
  "filePath": "/path/to/book.epub",
  "chapterIds": ["chapter-1", "chapter-2"],
  "maxLength": 5000
}

在 EPUB 中搜索

{
  "filePath": "/path/to/book.epub",
  "query": "artificial intelligence",
  "caseSensitive": false
}

🔧 可用工具

1. epub_info

获取包括元数据和结构在内的全面 EPUB 文件信息。

参数:

  • filePath (string): EPUB 文件路径

2. epub_toc

解析并显示目录结构。

参数:

  • filePath (string): EPUB 文件路径

3. epub_extract_text

从指定章节中提取文本内容。

参数:

  • filePath (string): EPUB 文件路径
  • chapterIds (array, optional): 要提取的章节 ID 列表
  • maxLength (number, optional): 最大文本长度限制

在 EPUB 文件中搜索文本。

参数:

  • filePath (string): EPUB 文件路径
  • query (string): 搜索查询
  • caseSensitive (boolean, optional): 大小写敏感搜索(默认:false)

🌐 资源模板

通过 URI 访问 EPUB 资源:

  • epub://{file}/metadata - JSON 格式的 EPUB 元数据
  • epub://{file}/toc - 目录结构
  • epub://{file}/chapter/{id} - 特定章节内容

🛠️ 开发

项目结构

epub-parser-mcp/
├── src/
│   ├── index.ts          # MCP server implementation
│   ├── epub-parser.ts    # EPUB parsing core
│   └── types.ts          # TypeScript type definitions
├── build/                # Compiled JavaScript
├── package.json
└── README.md

从源代码构建

# Install dependencies
npm install

# Build the project
npm run build

# Start the server
npm start

测试

# Run tests (if available)
npm test

📊 性能

  • 快速解析:优化的 EPUB 容器和内容解析
  • 内存高效:针对大型 EPUB 文件的流式处理
  • 并发安全:支持多个并发请求

🤝 贡献

我们欢迎贡献!请随时提交问题、功能请求或拉取请求。

开发设置

  1. 分叉仓库
  2. 创建特性分支:git checkout -b feature/amazing-feature
  3. 提交更改:git commit -m 'Add amazing feature'
  4. 推送到分支:git push origin feature/amazing-feature
  5. 打开拉取请求

代码风格

  • 使用 TypeScript 以确保类型安全
  • 遵循现有的代码格式
  • 添加适当的注释和文档

📄 许可证

本项目根据 GPL 许可证发布 - 详情请参阅 LICENSE 文件。

🙏 致谢

赋能 AI 助手阅读和理解 EPUB 文档

相关 MCP 服务