Skip to content

Commit 9efc11b

Browse files
committed
feat: upgrade marker/mcp stack and release docs
1 parent 714fb84 commit 9efc11b

13 files changed

Lines changed: 744 additions & 64 deletions

AGENTS.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
<!-- OPENSPEC:START -->
2+
# OpenSpec Instructions
3+
4+
These instructions are for AI assistants working in this project.
5+
6+
Always open `@/openspec/AGENTS.md` when the request:
7+
- Mentions planning or proposals (words like proposal, spec, change, plan)
8+
- Introduces new capabilities, breaking changes, architecture shifts, or big performance/security work
9+
- Sounds ambiguous and you need the authoritative spec before coding
10+
11+
Use `@/openspec/AGENTS.md` to learn:
12+
- How to create and apply change proposals
13+
- Spec format and conventions
14+
- Project structure and guidelines
15+
16+
Keep this managed block so 'openspec update' can refresh the instructions.
17+
18+
<!-- OPENSPEC:END -->
19+
20+
## 项目定位与目标
21+
22+
`any2markdown` 是一个文档转 Markdown 服务,当前实现目标是:
23+
- 同时提供 `MCP``RESTful API` 两种调用方式;
24+
- 支持 `PDF``Word(docx/doc)``Excel(xlsx/xls)` 转换;
25+
- 提供图片提取、文档校验、批量转换、基础结构分析能力;
26+
- 统一由 `src/any2markdown_mcp/` 下处理器与工具层实现核心逻辑。
27+
28+
## 代码结构速览
29+
30+
- `src/any2markdown_mcp/server.py`:FastMCP 入口,注册 MCP 工具与 REST 路由。
31+
- `src/any2markdown_mcp/tools/`:MCP 工具函数层(参数协议、响应组装)。
32+
- `src/any2markdown_mcp/processors/`:文档处理核心逻辑(PDF/Word/Excel)。
33+
- `src/any2markdown_mcp/api/`:REST API Handler 与请求/响应模型。
34+
- `src/any2markdown_mcp/config.py`:环境变量与默认配置。
35+
36+
## 代码规范与工程约束
37+
38+
### Python 与风格
39+
40+
- Python 版本基线:`>=3.10,<3.14`(推荐 `3.13`,见 `pyproject.toml`)。
41+
- 行宽按 `88` 字符控制(Black/isort 配置已定义)。
42+
- 新增或修改函数优先补全类型注解,保持 `mypy` 严格配置兼容。
43+
- 保持异步接口一致性:工具与处理链路使用 `async`
44+
45+
### 功能与接口约束
46+
47+
- 输入文件类型受 `allowed_file_types` 限制:`pdf/docx/doc/xlsx/xls`
48+
- 默认最大文件大小:`100MB``max_file_size`)。
49+
- 默认服务端口:`3000`,MCP 路径:`/mcp`,REST 前缀:`/api/v1`
50+
- 转换接口默认 `include_content=false`,避免在响应中返回大文本正文。
51+
52+
### 资源与运行约束
53+
54+
- 首次 PDF 能力使用可能触发模型下载,依赖 `~/.cache/marker` 与 HuggingFace/Torch 缓存目录。
55+
- 项目当前文档中存在“规划态”和“实现态”混合内容;修改功能时应同步更新文档,避免与实际代码偏离。
56+
- 仓库当前未包含 `tests/` 目录;如新增测试需与现有 `pytest` 配置保持一致。
57+
58+
## 修改原则(给协作代理)
59+
60+
- 优先做“最小可验证改动”,避免无关重构。
61+
- 变更接口或配置项时,至少同步更新以下文档之一:
62+
- `README.md`
63+
- `docs/*.md` 对应专题文档
64+
- `openspec/project.md`(项目约定变更)
65+
- 涉及新增能力、破坏性变更、架构级调整时,先按 `openspec/AGENTS.md` 走 proposal 流程,再实现代码。

Dockerfile

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,10 @@ FROM python:3.11-slim
44
# 设置工作目录
55
WORKDIR /app
66

7-
# 直接配置pip使用阿里云源(避免系统包管理器问题)
8-
RUN pip config set global.index-url https://mirrors.aliyun.com/pypi/simple/ && \
9-
pip config set global.timeout 120 && \
10-
pip config set global.trusted-host mirrors.aliyun.com && \
11-
pip config set install.trusted-host mirrors.aliyun.com
7+
# 构建时可注入依赖源(默认官方 PyPI)
8+
ARG PIP_INDEX_URL=https://pypi.org/simple
9+
RUN pip config set global.index-url ${PIP_INDEX_URL} && \
10+
pip config set global.timeout 120
1211

1312
# 复制依赖文件
1413
COPY requirements-prod.txt ./requirements.txt
@@ -80,4 +79,4 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=60s --retries=3 \
8079
CMD python -c "import requests; requests.get('http://localhost:3000/api/v1/status', timeout=5)" || exit 1
8180

8281
# 使用优化的入口脚本(以root用户运行)
83-
ENTRYPOINT ["./docker-entrypoint.sh"]
82+
ENTRYPOINT ["./docker-entrypoint.sh"]

README-en.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Any2Markdown MCP Server
22

3-
[![Python Version](https://img.shields.io/badge/python-3.9%2B-blue.svg)](https://python.org)
4-
[![MCP Protocol](https://img.shields.io/badge/MCP-1.10%2B-green.svg)](https://modelcontextprotocol.io/)
3+
[![Python Version](https://img.shields.io/badge/python-3.10--3.13-blue.svg)](https://python.org)
4+
[![MCP Protocol](https://img.shields.io/badge/MCP-1.26%2B-green.svg)](https://modelcontextprotocol.io/)
55
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
66
[![Build Status](https://img.shields.io/badge/build-passing-brightgreen.svg)]()
77

@@ -32,7 +32,7 @@ A high-performance document conversion server that supports both **Model Context
3232
## 🚀 Quick Start
3333

3434
### Prerequisites
35-
- Python 3.9+
35+
- Python 3.10 - 3.13 (validated on Python 3.13; 3.14 is not recommended yet)
3636
- 4GB+ RAM (for AI models)
3737
- 10GB+ disk space (for model cache)
3838

@@ -43,12 +43,15 @@ A high-performance document conversion server that supports both **Model Context
4343
git clone https://github.com/WW-AI-Lab/any2markdown.git
4444
cd any2markdown
4545

46-
# Create virtual environment
47-
python -m venv .venv
46+
# Create virtual environment (Python 3.13 recommended)
47+
python3.13 -m venv .venv
4848
source .venv/bin/activate # On Windows: .venv\Scripts\activate
4949

50-
# Install dependencies
51-
pip install -r requirements.txt
50+
# Install dependencies (Huawei mirror by default)
51+
PIP_CONFIG_FILE=.pip/pip.conf pip install -r requirements.txt
52+
53+
# Or use one-command bootstrap
54+
./scripts/setup_venv.sh
5255
```
5356

5457
### Quick Start
@@ -110,8 +113,8 @@ python run_server.py
110113
# Test RESTful API
111114
python test_restful_api.py
112115

113-
# Test MCP Protocol
114-
python test_streamable_client.py
116+
# Test MCP Protocol (official SDK, streamable-http)
117+
python test_streamable_client.py ~/Downloads/测试翻译_1_1_translate.docx
115118

116119
# Check service status
117120
./scripts/deploy.sh status
@@ -349,7 +352,7 @@ pytest --cov=src/any2markdown_mcp --cov-report=html
349352

350353
# Test specific functionality
351354
python test_restful_api.py # REST API tests
352-
python test_streamable_client.py # MCP protocol tests
355+
python test_streamable_client.py ~/Downloads/测试翻译_1_1_translate.docx # MCP protocol tests
353356
```
354357

355358
## 📊 Performance
@@ -432,4 +435,4 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
432435

433436
---
434437

435-
**Made with ❤️ by the Any2Markdown team**
438+
**Made with ❤️ by the Any2Markdown team**

README.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Any2Markdown MCP 服务器
22

3-
[![Python 版本](https://img.shields.io/badge/python-3.9%2B-blue.svg)](https://python.org)
4-
[![MCP 协议](https://img.shields.io/badge/MCP-1.10%2B-green.svg)](https://modelcontextprotocol.io/)
3+
[![Python 版本](https://img.shields.io/badge/python-3.10--3.13-blue.svg)](https://python.org)
4+
[![MCP 协议](https://img.shields.io/badge/MCP-1.26%2B-green.svg)](https://modelcontextprotocol.io/)
55
[![许可证](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
66
[![构建状态](https://img.shields.io/badge/build-passing-brightgreen.svg)]()
77

@@ -32,7 +32,7 @@
3232
## 🚀 快速开始
3333

3434
### 系统要求
35-
- Python 3.9+
35+
- Python 3.10 - 3.13(已验证 Python 3.13,暂不建议 3.14)
3636
- 4GB+ 内存(用于 AI 模型)
3737
- 10GB+ 磁盘空间(用于模型缓存)
3838

@@ -43,15 +43,18 @@
4343
git clone https://github.com/WW-AI-Lab/any2markdown.git
4444
cd any2markdown
4545

46-
# 创建虚拟环境
47-
python -m venv .venv
46+
# 创建虚拟环境(推荐使用 Python 3.13)
47+
python3.13 -m venv .venv
4848
source .venv/bin/activate # Windows: .venv\Scripts\activate
4949

5050
# 准备环境变量文件
5151
cp env.example .env
5252

53-
# 安装依赖
54-
pip install -r requirements.txt
53+
# 安装依赖(默认使用华为镜像)
54+
PIP_CONFIG_FILE=.pip/pip.conf pip install -r requirements.txt
55+
56+
# 或一键安装
57+
./scripts/setup_venv.sh
5558
```
5659

5760
### 快速启动
@@ -113,8 +116,8 @@ python run_server.py
113116
# 测试 RESTful API
114117
python test_restful_api.py
115118

116-
# 测试 MCP 协议
117-
python test_streamable_client.py
119+
# 测试 MCP 协议(官方 SDK,streamable-http)
120+
python test_streamable_client.py ~/Downloads/测试翻译_1_1_translate.docx
118121

119122
# 检查服务状态
120123
./scripts/deploy.sh status
@@ -436,7 +439,7 @@ pytest --cov=src/any2markdown_mcp --cov-report=html
436439

437440
# 测试特定功能
438441
python test_restful_api.py # REST API 测试
439-
python test_streamable_client.py # MCP 协议测试
442+
python test_streamable_client.py ~/Downloads/测试翻译_1_1_translate.docx # MCP 协议测试
440443
```
441444

442445
## dify集成
@@ -516,4 +519,4 @@ pytest
516519
- [ ] 支持 PowerPoint (PPTX) 转换
517520
- [ ] 图片类型PDF转换效果优化
518521
- [ ] Kubernetes 部署清单
519-
- [ ] 云存储集成
522+
- [ ] 云存储集成

docs/README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,13 +135,13 @@ any2markdown/
135135
# 克隆项目
136136
cd any2markdown
137137

138-
# 创建虚拟环境 (Python 3.9+)
139-
python -m venv venv
138+
# 创建虚拟环境 (Python 3.10 - 3.13,推荐 3.13)
139+
python3.13 -m venv venv
140140
source venv/bin/activate # macOS/Linux
141141
# venv\Scripts\activate # Windows
142142

143-
# 安装依赖
144-
pip install -r requirements.txt
143+
# 安装依赖(默认使用华为镜像)
144+
PIP_CONFIG_FILE=.pip/pip.conf pip install -r requirements.txt
145145
```
146146

147147
### 2. 启动服务器
@@ -230,4 +230,4 @@ curl -X POST http://localhost:8080/mcp \
230230

231231
**🎯 目标**: 创建一个高性能、可扩展、标准化的文档转换MCP服务器,提供比传统API更好的开发体验和集成能力。
232232

233-
**🚀 愿景**: 成为MCP生态系统中文档处理的标准解决方案,支持多种文档格式和输出选项。
233+
**🚀 愿景**: 成为MCP生态系统中文档处理的标准解决方案,支持多种文档格式和输出选项。

0 commit comments

Comments
 (0)