@noedgeai-org/doc2x-mcp 0.1.3-dev.5.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,29 +1,47 @@
1
1
  # Doc2x MCP Server
2
2
 
3
+ [![CI](https://github.com/NoEdgeAI/doc2x-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/NoEdgeAI/doc2x-mcp/actions/workflows/ci.yml)
4
+ [![Publish](https://github.com/NoEdgeAI/doc2x-mcp/actions/workflows/publish.yml/badge.svg)](https://github.com/NoEdgeAI/doc2x-mcp/actions/workflows/publish.yml)
5
+ [![npm version](https://img.shields.io/npm/v/%40noedgeai-org%2Fdoc2x-mcp)](https://www.npmjs.com/package/@noedgeai-org/doc2x-mcp)
6
+
3
7
  简体中文 | [English](./README_EN.md)
4
8
 
5
- 本项目提供一个基于 stdio 的 MCP Server,把 Doc2x v2 的 PDF/图片接口封装成语义化 tools。
9
+ Doc2x v2 PDF/图片能力封装为基于 stdio 的 MCP Server,提供稳定、可组合的语义化 tools。
10
+
11
+ ## 目录
12
+
13
+ - [项目定位](#项目定位)
14
+ - [版本与环境](#版本与环境)
15
+ - [快速开始](#快速开始)
16
+ - [配置参考](#配置参考)
17
+ - [Tool API 总览](#tool-api-总览)
18
+ - [常见工作流](#常见工作流)
19
+ - [本地开发](#本地开发)
20
+ - [CI / 发布流水线](#ci--发布流水线)
21
+ - [如何发布](#如何发布)
22
+ - [安装本仓库 Skill(可选)](#安装本仓库-skill可选)
23
+ - [安全与排错](#安全与排错)
24
+ - [问题反馈](#问题反馈)
25
+ - [License](#license)
6
26
 
7
- ## 1) 运行环境
27
+ ## 项目定位
8
28
 
9
- - Node.js >= 18
29
+ - 面向 MCP 客户端(Codex CLI / Claude Code / 自定义 Agent)提供 Doc2x 能力。
30
+ - 以 submit/status/wait 统一异步任务模型,便于自动化编排。
31
+ - 提供可控超时、轮询、下载白名单等运行时安全边界。
10
32
 
11
- ## 2) 配置
33
+ ## 版本与环境
12
34
 
13
- 通过环境变量配置:
35
+ - 本地运行:Node.js `>=18` 即可。
36
+ - CI 校验:Node.js `18`、`20` 都会跑构建。
37
+ - 发布环境:GitHub Actions 中发布任务使用 Node.js `24`。
38
+ - 包管理器:统一用 pnpm(锁文件 `pnpm-lock.yaml`)。
14
39
 
15
- - `DOC2X_API_KEY`:必填(形如 `sk-xxx`)
16
- - `DOC2X_BASE_URL`:可选,默认 `https://v2.doc2x.noedgeai.com`
17
- - `DOC2X_HTTP_TIMEOUT_MS`:可选,默认 `60000`
18
- - `DOC2X_POLL_INTERVAL_MS`:可选,默认 `2000`
19
- - `DOC2X_MAX_WAIT_MS`:可选,默认 `600000`
20
- - `DOC2X_PARSE_PDF_MAX_OUTPUT_CHARS`:可选,默认 `5000`;限制 `doc2x_parse_pdf_wait_text` 返回文本的最大字符数,避免大模型上下文超限(设为 `0` 表示不限制)
21
- - `DOC2X_PARSE_PDF_MAX_OUTPUT_PAGES`:可选,默认 `10`;限制 `doc2x_parse_pdf_wait_text` 合并的最大页数(设为 `0` 表示不限制)
22
- - `DOC2X_DOWNLOAD_URL_ALLOWLIST`:可选,默认 `".amazonaws.com.cn,.aliyuncs.com,.noedgeai.com"`;设为 `*` 可允许任意 host(不推荐)
40
+ ## 快速开始
23
41
 
24
- ## 3) 启动
42
+ ### 方式 A:通过 npx(推荐)
25
43
 
26
- ### 方式 A:通过 npx
44
+ MCP client 配置中添加:
27
45
 
28
46
  ```json
29
47
  {
@@ -40,11 +58,13 @@
40
58
 
41
59
  ```bash
42
60
  cd doc2x-mcp
43
- npm install
44
- npm run build
45
- DOC2X_API_KEY=sk-xxx npm start
61
+ pnpm install --frozen-lockfile
62
+ pnpm run build
63
+ DOC2X_API_KEY=sk-xxx pnpm start
46
64
  ```
47
65
 
66
+ MCP client 指向本地构建产物:
67
+
48
68
  ```json
49
69
  {
50
70
  "command": "node",
@@ -56,27 +76,34 @@ DOC2X_API_KEY=sk-xxx npm start
56
76
  }
57
77
  ```
58
78
 
59
- ## 4) Tools
60
-
61
- - `doc2x_parse_pdf_submit`
62
- - `doc2x_parse_pdf_status`
63
- - `doc2x_parse_pdf_wait_text`
64
- - `doc2x_convert_export_submit`
65
- - `doc2x_convert_export_result`
66
- - `doc2x_convert_export_wait`
67
- - `doc2x_download_url_to_file`
68
- - `doc2x_parse_image_layout_sync`
69
- - `doc2x_parse_image_layout_submit`
70
- - `doc2x_parse_image_layout_status`
71
- - `doc2x_parse_image_layout_wait_text`
72
- - `doc2x_materialize_convert_zip`
73
- - `doc2x_debug_config`
79
+ ## 配置参考
80
+
81
+ | 环境变量 | 必填 | 默认值 | 说明 |
82
+ | --- | --- | --- | --- |
83
+ | `DOC2X_API_KEY` | 是 | - | Doc2x API Key(`sk-xxx`) |
84
+ | `DOC2X_BASE_URL` | 否 | `https://v2.doc2x.noedgeai.com` | Doc2x API 基础地址 |
85
+ | `DOC2X_HTTP_TIMEOUT_MS` | 否 | `60000` | 单次 HTTP 超时(毫秒) |
86
+ | `DOC2X_POLL_INTERVAL_MS` | 否 | `2000` | 轮询间隔(毫秒) |
87
+ | `DOC2X_MAX_WAIT_MS` | 否 | `600000` | wait 类工具最大等待时长(毫秒) |
88
+ | `DOC2X_PARSE_PDF_MAX_OUTPUT_CHARS` | 否 | `5000` | `doc2x_parse_pdf_wait_text` 最大返回字符数;`0`=不限制 |
89
+ | `DOC2X_PARSE_PDF_MAX_OUTPUT_PAGES` | 否 | `10` | `doc2x_parse_pdf_wait_text` 最大合并页数;`0`=不限制 |
90
+ | `DOC2X_DOWNLOAD_URL_ALLOWLIST` | 否 | `.amazonaws.com.cn,.aliyuncs.com,.noedgeai.com` | 下载 URL 白名单;`*` 允许任意 host(不推荐) |
91
+
92
+ ## Tool API 总览
93
+
94
+ | 阶段 | Tools | 说明 |
95
+ | --- | --- | --- |
96
+ | PDF 解析 | `doc2x_parse_pdf_submit` / `doc2x_parse_pdf_status` / `doc2x_parse_pdf_wait_text` | 提交任务、查询状态、等待并取文本 |
97
+ | 结果导出 | `doc2x_convert_export_submit` / `doc2x_convert_export_result` / `doc2x_convert_export_wait` | 发起导出、查结果、等待导出完成 |
98
+ | 下载落盘 | `doc2x_download_url_to_file` / `doc2x_materialize_convert_zip` | 下载 URL 到本地、解包 convert zip |
99
+ | 图片版面解析 | `doc2x_parse_image_layout_sync` / `doc2x_parse_image_layout_submit` / `doc2x_parse_image_layout_status` / `doc2x_parse_image_layout_wait_text` | 同步/异步图片 OCR 与版面解析 |
100
+ | 诊断 | `doc2x_debug_config` | 返回配置解析与 API key 来源,便于排错 |
74
101
 
75
102
  ### PDF 解析模型(`doc2x_parse_pdf_submit` / `doc2x_parse_pdf_wait_text`)
76
103
 
77
104
  - 可选参数:`model`
78
- - 可选值:仅 `v3-2026`(最新模型)
79
- - 说明:不传 `model` 时默认使用 `v2`;若想体验最新模型,传:
105
+ - 可选值:`v3-2026`(最新模型)
106
+ - 不传时默认 `v2`
80
107
 
81
108
  ```json
82
109
  {
@@ -87,19 +114,84 @@ DOC2X_API_KEY=sk-xxx npm start
87
114
  ### 导出公式参数(`doc2x_convert_export_submit` / `doc2x_convert_export_wait`)
88
115
 
89
116
  - 必选参数:`formula_mode`(`normal` / `dollar`)
90
- - 可选参数:`formula_level`(`int32`,仅源解析任务为 `model=v3-2026` 时生效,`v2` 下无效)
117
+ - 可选参数:`formula_level`(仅源解析任务为 `model=v3-2026` 时生效)
91
118
  - 取值说明:
92
- - `0`:不退化公式(保留原始 Markdown)
93
- - `1`:行内公式变为普通文本(退化 `\\(...\\)` 和 `$...$`)
94
- - `2`:全部公式变为普通文本(退化 `\\(...\\)`、`$...$`、`\\[...\\]`、`$$...$$`)
119
+ - `0`:保留公式
120
+ - `1`:仅退化行内公式(`\\(...\\)`、`$...$`)
121
+ - `2`:退化全部公式(`\\(...\\)`、`$...$`、`\\[...\\]`、`$$...$$`)
95
122
 
96
- ## 5) 协议
123
+ ## 常见工作流
97
124
 
98
- MIT License,详见 `LICENSE`。
125
+ ### 工作流 1:PDF -> Markdown 本地文件
126
+
127
+ 1. `doc2x_parse_pdf_submit` 提交 PDF 解析。
128
+ 2. `doc2x_convert_export_wait` 等待导出(`to=md`,并指定 `formula_mode`)。
129
+ 3. `doc2x_convert_export_result` 获取下载 URL。
130
+ 4. `doc2x_download_url_to_file` 下载到目标路径。
131
+
132
+ ### 工作流 2:图片版面 OCR 快速结果
133
+
134
+ 1. `doc2x_parse_image_layout_sync` 直接同步解析。
135
+ 2. 若需要稳态轮询,改用 submit/status/wait 组合。
136
+
137
+ ## 本地开发
138
+
139
+ ### 环境要求
140
+
141
+ - Node.js `>=18`
142
+ - pnpm(与仓库锁文件一致)
143
+
144
+ ### 常用命令
145
+
146
+ ```bash
147
+ pnpm install --frozen-lockfile
148
+ pnpm run build
149
+ pnpm run test
150
+ pnpm run format:check
151
+ ```
152
+
153
+ 运行服务:
154
+
155
+ ```bash
156
+ DOC2X_API_KEY=sk-xxx pnpm start
157
+ ```
158
+
159
+ ## CI / 发布流水线
160
+
161
+ 仓库使用 GitHub Actions:
162
+
163
+ - CI:`.github/workflows/ci.yml`
164
+ - 触发:`push` 到 `main`、`pull_request`、`workflow_dispatch`、每周一 UTC `03:17`
165
+ - 文档-only 变更(`**/*.md`、`LICENSE`)自动跳过
166
+ - 任务:
167
+ - `dependency-review`(仅 PR)
168
+ - `build`(Node.js `18/20` 矩阵)
169
+ - `package-smoke`(`npm pack --dry-run`)
170
+ - `security-audit`(仅手动/定时)
171
+
172
+ - Publish:`.github/workflows/publish.yml`
173
+ - `dev` 分支 push:发布 npm `dev` tag
174
+ - `v*.*.*` tag push:发布 npm `latest`
175
+ - 发布前校验 tag 版本与 `package.json` 版本一致
176
+ - 发布命令:`npm publish --provenance`
177
+
178
+ 建议提交前本地对齐:
179
+
180
+ ```bash
181
+ pnpm install --frozen-lockfile
182
+ pnpm run build
183
+ npm pack --dry-run
184
+ pnpm audit --prod --audit-level high
185
+ ```
99
186
 
100
- ## 6) 安装本仓库 Skill(可选)
187
+ ## 如何发布
101
188
 
102
- 用于给 Codex CLI / Claude Code 增加一个“教大模型如何使用 doc2x-mcp tools 的 Skill”(便于按固定工作流调用 tools、导出与下载、以及排错)。
189
+ - 开发预发布(`dev`):push `dev` 分支后自动发布到 npm `dev` tag。版本会自动改成 `x.y.z-dev.<run>.<attempt>`。
190
+ - 正式发布(`latest`):push `v*.*.*` tag 后发布到 npm `latest`。tag 版本必须和 `package.json` 版本一致。
191
+
192
+ ## 安装本仓库 Skill(可选)
193
+
194
+ 用于给 Codex CLI / Claude Code 增加一个“教大模型如何使用 doc2x-mcp tools 的 Skill”。
103
195
 
104
196
  不需要 clone 仓库的一键安装(推荐):
105
197
 
@@ -107,28 +199,35 @@ MIT License,详见 `LICENSE`。
107
199
  curl -fsSL https://raw.githubusercontent.com/NoEdgeAI/doc2x-mcp/main/scripts/install-skill.sh | sh
108
200
  ```
109
201
 
110
- 重复执行同一条命令即可覆盖安装(默认会覆盖已存在目录)。
111
-
112
202
  在本仓库源码目录安装:
113
203
 
114
204
  ```bash
115
- npm run skill:install
205
+ pnpm run skill:install
116
206
  ```
117
207
 
118
- 默认安装到:
208
+ 默认安装目录:
119
209
 
120
- 脚本默认安装到:
121
-
122
- - Codex CLI:`~/.codex/skills/public/doc2x-mcp`(用 `CODEX_HOME` 覆盖)
123
- - Claude Code:`~/.claude/skills/doc2x-mcp`(用 `CLAUDE_HOME` 覆盖)
210
+ - Codex CLI:`~/.codex/skills/public/doc2x-mcp`(可用 `CODEX_HOME` 覆盖)
211
+ - Claude Code:`~/.claude/skills/doc2x-mcp`(可用 `CLAUDE_HOME` 覆盖)
124
212
 
125
213
  说明:
126
214
 
127
- - `--target auto`(默认)会同时安装到 Codex + Claude;如只想装其中一个,用 `--target codex|claude`。
128
- - PowerShell 7+ 一键安装:`irm https://raw.githubusercontent.com/NoEdgeAI/doc2x-mcp/main/scripts/install-skill.ps1 | iex`
129
- - Windows PowerShell 5.1 一键安装:`irm https://raw.githubusercontent.com/NoEdgeAI/doc2x-mcp/main/scripts/install-skill-winps.ps1 | iex`
215
+ - `--target auto`(默认)会同时安装到 Codex + Claude
216
+ - PowerShell 7+:`irm https://raw.githubusercontent.com/NoEdgeAI/doc2x-mcp/main/scripts/install-skill.ps1 | iex`
217
+ - Windows PowerShell 5.1:`irm https://raw.githubusercontent.com/NoEdgeAI/doc2x-mcp/main/scripts/install-skill-winps.ps1 | iex`
218
+
219
+ ## 安全与排错
130
220
 
131
- 覆盖安装目录示例:
221
+ - 不要在仓库提交真实 `DOC2X_API_KEY`。
222
+ - 白名单默认限制下载域名;如需放开,评估风险后再使用 `DOC2X_DOWNLOAD_URL_ALLOWLIST=*`。
223
+ - 配置异常时优先调用 `doc2x_debug_config` 定位环境变量来源与解析结果。
132
224
 
133
- - mac/linux:`CODEX_HOME=/custom/.codex curl -fsSL https://raw.githubusercontent.com/NoEdgeAI/doc2x-mcp/main/scripts/install-skill.sh | sh -s -- --target codex`
134
- - Windows:`$env:CODEX_HOME="C:\\path\\.codex"; irm https://raw.githubusercontent.com/NoEdgeAI/doc2x-mcp/main/scripts/install-skill.ps1 | iex`
225
+ ## 问题反馈
226
+
227
+ - 使用问题或缺陷反馈:GitHub Issues
228
+ [https://github.com/NoEdgeAI/doc2x-mcp/issues](https://github.com/NoEdgeAI/doc2x-mcp/issues)
229
+ - 建议在 issue 中附上最小复现输入、触发的 tool 名称、以及 `doc2x_debug_config` 结果(可脱敏)。
230
+
231
+ ## License
232
+
233
+ MIT License,详见 `LICENSE`。
package/README_EN.md CHANGED
@@ -1,34 +1,52 @@
1
1
  # Doc2x MCP Server
2
2
 
3
+ [![CI](https://github.com/NoEdgeAI/doc2x-mcp/actions/workflows/ci.yml/badge.svg)](https://github.com/NoEdgeAI/doc2x-mcp/actions/workflows/ci.yml)
4
+ [![Publish](https://github.com/NoEdgeAI/doc2x-mcp/actions/workflows/publish.yml/badge.svg)](https://github.com/NoEdgeAI/doc2x-mcp/actions/workflows/publish.yml)
5
+ [![npm version](https://img.shields.io/npm/v/%40noedgeai-org%2Fdoc2x-mcp)](https://www.npmjs.com/package/@noedgeai-org/doc2x-mcp)
6
+
3
7
  English | [简体中文](./README.md)
4
8
 
5
- This project provides a stdio-based MCP Server that wraps Doc2x v2 PDF/image APIs into semantic tools.
9
+ A stdio-based MCP Server that wraps Doc2x v2 PDF/image capabilities into stable, composable semantic tools.
10
+
11
+ ## Table of Contents
12
+
13
+ - [Project Scope](#project-scope)
14
+ - [Runtime Quick Facts](#runtime-quick-facts)
15
+ - [Quick Start](#quick-start)
16
+ - [Configuration Reference](#configuration-reference)
17
+ - [Tool API Overview](#tool-api-overview)
18
+ - [Common Workflows](#common-workflows)
19
+ - [Local Development](#local-development)
20
+ - [CI / Release Pipelines](#ci--release-pipelines)
21
+ - [Publishing Flow](#publishing-flow)
22
+ - [Install Repo Skill (Optional)](#install-repo-skill-optional)
23
+ - [Security and Troubleshooting](#security-and-troubleshooting)
24
+ - [Getting Help](#getting-help)
25
+ - [License](#license)
6
26
 
7
- ## 1) Requirements
27
+ ## Project Scope
8
28
 
9
- - Node.js >= 18
29
+ - Exposes Doc2x capabilities to MCP clients (Codex CLI / Claude Code / custom agents).
30
+ - Uses a unified async contract (`submit/status/wait`) for predictable automation.
31
+ - Provides runtime safety boundaries (timeouts, polling controls, download allowlist).
10
32
 
11
- ## 2) Configuration
33
+ ## Runtime Quick Facts
12
34
 
13
- Configure via environment variables:
35
+ - Local run: Node.js `>=18` is enough.
36
+ - CI checks: builds run on Node.js `18` and `20`.
37
+ - Release environment: publish jobs run on Node.js `24` in GitHub Actions.
38
+ - Package manager: pnpm with lockfile `pnpm-lock.yaml`.
14
39
 
15
- - `DOC2X_API_KEY`: required (e.g. `sk-xxx`)
16
- - `DOC2X_BASE_URL`: optional, default `https://v2.doc2x.noedgeai.com`
17
- - `DOC2X_HTTP_TIMEOUT_MS`: optional, default `60000`
18
- - `DOC2X_POLL_INTERVAL_MS`: optional, default `2000`
19
- - `DOC2X_MAX_WAIT_MS`: optional, default `600000`
20
- - `DOC2X_PARSE_PDF_MAX_OUTPUT_CHARS`: optional, default `5000`; limit the returned text size of `doc2x_parse_pdf_wait_text` (set `0` for unlimited)
21
- - `DOC2X_PARSE_PDF_MAX_OUTPUT_PAGES`: optional, default `10`; limit merged pages of `doc2x_parse_pdf_wait_text` (set `0` for unlimited)
22
- - `DOC2X_DOWNLOAD_URL_ALLOWLIST`: optional, default `".amazonaws.com.cn,.aliyuncs.com,.noedgeai.com"`; set to `*` to allow any host (not recommended)
40
+ ## Quick Start
23
41
 
24
- ## 3) Run
42
+ ### Option A: via npx (recommended)
25
43
 
26
- ### Option A: via npx
44
+ Add this in your MCP client config:
27
45
 
28
46
  ```json
29
47
  {
30
48
  "command": "npx",
31
- "args": ["-y", "@noedgeai-org/doc2x-mcp"],
49
+ "args": ["-y", "@noedgeai-org/doc2x-mcp@latest"],
32
50
  "env": {
33
51
  "DOC2X_API_KEY": "sk-xxx",
34
52
  "DOC2X_BASE_URL": "https://v2.doc2x.noedgeai.com"
@@ -40,11 +58,13 @@ Configure via environment variables:
40
58
 
41
59
  ```bash
42
60
  cd doc2x-mcp
43
- npm install
44
- npm run build
45
- DOC2X_API_KEY=sk-xxx npm start
61
+ pnpm install --frozen-lockfile
62
+ pnpm run build
63
+ DOC2X_API_KEY=sk-xxx pnpm start
46
64
  ```
47
65
 
66
+ Point MCP client to your local build output:
67
+
48
68
  ```json
49
69
  {
50
70
  "command": "node",
@@ -56,27 +76,34 @@ DOC2X_API_KEY=sk-xxx npm start
56
76
  }
57
77
  ```
58
78
 
59
- ## 4) Tools
60
-
61
- - `doc2x_parse_pdf_submit`
62
- - `doc2x_parse_pdf_status`
63
- - `doc2x_parse_pdf_wait_text`
64
- - `doc2x_convert_export_submit`
65
- - `doc2x_convert_export_result`
66
- - `doc2x_convert_export_wait`
67
- - `doc2x_download_url_to_file`
68
- - `doc2x_parse_image_layout_sync`
69
- - `doc2x_parse_image_layout_submit`
70
- - `doc2x_parse_image_layout_status`
71
- - `doc2x_parse_image_layout_wait_text`
72
- - `doc2x_materialize_convert_zip`
73
- - `doc2x_debug_config`
79
+ ## Configuration Reference
80
+
81
+ | Environment Variable | Required | Default | Description |
82
+ | --- | --- | --- | --- |
83
+ | `DOC2X_API_KEY` | Yes | - | Doc2x API key (`sk-xxx`) |
84
+ | `DOC2X_BASE_URL` | No | `https://v2.doc2x.noedgeai.com` | Doc2x API base URL |
85
+ | `DOC2X_HTTP_TIMEOUT_MS` | No | `60000` | Per-request HTTP timeout in ms |
86
+ | `DOC2X_POLL_INTERVAL_MS` | No | `2000` | Polling interval in ms |
87
+ | `DOC2X_MAX_WAIT_MS` | No | `600000` | Max wait duration for wait tools in ms |
88
+ | `DOC2X_PARSE_PDF_MAX_OUTPUT_CHARS` | No | `5000` | Max returned chars for `doc2x_parse_pdf_wait_text`; `0` = unlimited |
89
+ | `DOC2X_PARSE_PDF_MAX_OUTPUT_PAGES` | No | `10` | Max merged pages for `doc2x_parse_pdf_wait_text`; `0` = unlimited |
90
+ | `DOC2X_DOWNLOAD_URL_ALLOWLIST` | No | `.amazonaws.com.cn,.aliyuncs.com,.noedgeai.com` | URL host allowlist for downloads; `*` allows any host (not recommended) |
91
+
92
+ ## Tool API Overview
93
+
94
+ | Stage | Tools | Purpose |
95
+ | --- | --- | --- |
96
+ | PDF parse | `doc2x_parse_pdf_submit` / `doc2x_parse_pdf_status` / `doc2x_parse_pdf_wait_text` | Submit parse tasks, check status, wait and fetch text |
97
+ | Export | `doc2x_convert_export_submit` / `doc2x_convert_export_result` / `doc2x_convert_export_wait` | Start export, read export result, wait for completion |
98
+ | Download | `doc2x_download_url_to_file` / `doc2x_materialize_convert_zip` | Download export URL to local path, materialize convert zip |
99
+ | Image layout parse | `doc2x_parse_image_layout_sync` / `doc2x_parse_image_layout_submit` / `doc2x_parse_image_layout_status` / `doc2x_parse_image_layout_wait_text` | Sync/async OCR and layout parse for images |
100
+ | Diagnostics | `doc2x_debug_config` | Show resolved config and API key source |
74
101
 
75
102
  ### PDF Parse Model (`doc2x_parse_pdf_submit` / `doc2x_parse_pdf_wait_text`)
76
103
 
77
104
  - Optional parameter: `model`
78
- - Supported values: only `v3-2026` (latest model)
79
- - Notes: omit `model` to use default `v2`; to try the latest model, pass:
105
+ - Supported value: `v3-2026` (latest model)
106
+ - Default (when omitted): `v2`
80
107
 
81
108
  ```json
82
109
  {
@@ -86,20 +113,85 @@ DOC2X_API_KEY=sk-xxx npm start
86
113
 
87
114
  ### Export Formula Parameters (`doc2x_convert_export_submit` / `doc2x_convert_export_wait`)
88
115
 
89
- - Required parameter: `formula_mode` (`normal` / `dollar`)
90
- - Optional parameter: `formula_level` (`int32`, effective only when the source parse task uses `model=v3-2026`; ignored by `v2`)
116
+ - Required: `formula_mode` (`normal` / `dollar`)
117
+ - Optional: `formula_level` (effective only when source parse used `model=v3-2026`)
91
118
  - Value mapping:
92
- - `0`: keep formulas as-is (preserve original Markdown)
93
- - `1`: degrade inline formulas to plain text (`\\(...\\)` and `$...$`)
94
- - `2`: degrade all formulas to plain text (`\\(...\\)`, `$...$`, `\\[...\\]`, `$$...$$`)
119
+ - `0`: keep formulas
120
+ - `1`: degrade inline formulas (`\\(...\\)`, `$...$`)
121
+ - `2`: degrade all formulas (`\\(...\\)`, `$...$`, `\\[...\\]`, `$$...$$`)
95
122
 
96
- ## 5) License
123
+ ## Common Workflows
97
124
 
98
- MIT License. See `LICENSE`.
125
+ ### Workflow 1: PDF -> Markdown local file
126
+
127
+ 1. Submit parse via `doc2x_parse_pdf_submit`.
128
+ 2. Wait export via `doc2x_convert_export_wait` (`to=md` and `formula_mode` required).
129
+ 3. Read result URL via `doc2x_convert_export_result`.
130
+ 4. Download to local path via `doc2x_download_url_to_file`.
131
+
132
+ ### Workflow 2: Fast image OCR/layout result
133
+
134
+ 1. Use `doc2x_parse_image_layout_sync` for direct parse.
135
+ 2. For robust polling behavior, switch to submit/status/wait flow.
136
+
137
+ ## Local Development
138
+
139
+ ### Requirements
140
+
141
+ - Node.js `>=18`
142
+ - pnpm (aligned with lockfile)
143
+
144
+ ### Common commands
145
+
146
+ ```bash
147
+ pnpm install --frozen-lockfile
148
+ pnpm run build
149
+ pnpm run test
150
+ pnpm run format:check
151
+ ```
152
+
153
+ Run server:
154
+
155
+ ```bash
156
+ DOC2X_API_KEY=sk-xxx pnpm start
157
+ ```
158
+
159
+ ## CI / Release Pipelines
160
+
161
+ This repository uses GitHub Actions:
162
+
163
+ - CI: `.github/workflows/ci.yml`
164
+ - Triggers: `push` to `main`, `pull_request`, `workflow_dispatch`, weekly on Monday at UTC `03:17`
165
+ - Doc-only changes (`**/*.md`, `LICENSE`) are skipped
166
+ - Jobs:
167
+ - `dependency-review` (PR only)
168
+ - `build` (Node.js `18/20` matrix)
169
+ - `package-smoke` (`npm pack --dry-run`)
170
+ - `security-audit` (manual/scheduled only)
171
+
172
+ - Publish: `.github/workflows/publish.yml`
173
+ - Push to `dev`: publish npm package with `dev` tag
174
+ - Push tag `v*.*.*`: publish npm package as `latest`
175
+ - Verifies tag version matches `package.json` version before publish
176
+ - Publish command: `npm publish --provenance`
177
+
178
+ Recommended local parity checks before pushing:
179
+
180
+ ```bash
181
+ pnpm install --frozen-lockfile
182
+ pnpm run build
183
+ npm pack --dry-run
184
+ pnpm audit --prod --audit-level high
185
+ ```
99
186
 
100
- ## 6) Install Repo Skill (Optional)
187
+ ## Publishing Flow
101
188
 
102
- Installs a tool-use skill for Codex CLI / Claude Code (teaches the LLM how to use doc2x-mcp tools with a standard workflow: submit/status/wait/export/download).
189
+ - Dev pre-release (`dev`): push to `dev` branch to publish npm `dev` tag. Version is auto rewritten to `x.y.z-dev.<run>.<attempt>`.
190
+ - Production release (`latest`): push `v*.*.*` tag to publish npm `latest`. Tag version must match `package.json`.
191
+
192
+ ## Install Repo Skill (Optional)
193
+
194
+ Installs a reusable skill for Codex CLI / Claude Code to guide tool usage with the standard `submit/status/wait/export/download` workflow.
103
195
 
104
196
  One-command install without cloning (recommended):
105
197
 
@@ -107,28 +199,35 @@ One-command install without cloning (recommended):
107
199
  curl -fsSL https://raw.githubusercontent.com/NoEdgeAI/doc2x-mcp/main/scripts/install-skill.sh | sh
108
200
  ```
109
201
 
110
- Re-run the same command to overwrite (default behavior overwrites an existing destination directory).
111
-
112
202
  Install from this repo source directory:
113
203
 
114
204
  ```bash
115
- npm run skill:install
205
+ pnpm run skill:install
116
206
  ```
117
207
 
118
- Default destination:
208
+ Default destinations:
119
209
 
120
- The script installs to:
121
-
122
- - Codex CLI: `~/.codex/skills/public/doc2x-mcp` (override via `CODEX_HOME`)
123
- - Claude Code: `~/.claude/skills/doc2x-mcp` (override via `CLAUDE_HOME`)
210
+ - Codex CLI: `~/.codex/skills/public/doc2x-mcp` (override with `CODEX_HOME`)
211
+ - Claude Code: `~/.claude/skills/doc2x-mcp` (override with `CLAUDE_HOME`)
124
212
 
125
213
  Notes:
126
214
 
127
- - `--target auto` (default) installs to both Codex + Claude; use `--target codex|claude` to install only one.
128
- - PowerShell 7+ one-command install: `irm https://raw.githubusercontent.com/NoEdgeAI/doc2x-mcp/main/scripts/install-skill.ps1 | iex`
129
- - Windows PowerShell 5.1 one-command install: `irm https://raw.githubusercontent.com/NoEdgeAI/doc2x-mcp/main/scripts/install-skill-winps.ps1 | iex`
215
+ - `--target auto` (default) installs to both Codex + Claude.
216
+ - PowerShell 7+: `irm https://raw.githubusercontent.com/NoEdgeAI/doc2x-mcp/main/scripts/install-skill.ps1 | iex`
217
+ - Windows PowerShell 5.1: `irm https://raw.githubusercontent.com/NoEdgeAI/doc2x-mcp/main/scripts/install-skill-winps.ps1 | iex`
218
+
219
+ ## Security and Troubleshooting
130
220
 
131
- Override install dir examples:
221
+ - Never commit real `DOC2X_API_KEY` to the repository.
222
+ - The download allowlist is restrictive by default; evaluate risk before using `DOC2X_DOWNLOAD_URL_ALLOWLIST=*`.
223
+ - Use `doc2x_debug_config` first when diagnosing config/environment issues.
132
224
 
133
- - mac/linux: `CODEX_HOME=/custom/.codex curl -fsSL https://raw.githubusercontent.com/NoEdgeAI/doc2x-mcp/main/scripts/install-skill.sh | sh -s -- --target codex`
134
- - Windows: `$env:CODEX_HOME="C:\\path\\.codex"; irm https://raw.githubusercontent.com/NoEdgeAI/doc2x-mcp/main/scripts/install-skill.ps1 | iex`
225
+ ## Getting Help
226
+
227
+ - Usage questions or bug reports: GitHub Issues
228
+ [https://github.com/NoEdgeAI/doc2x-mcp/issues](https://github.com/NoEdgeAI/doc2x-mcp/issues)
229
+ - Include minimal reproduction input, affected tool name, and sanitized `doc2x_debug_config` output when possible.
230
+
231
+ ## License
232
+
233
+ MIT License. See `LICENSE`.
@@ -3,7 +3,6 @@ function parseDoc2xApiKey(raw) {
3
3
  const v = String(raw).trim();
4
4
  if (!v)
5
5
  return '';
6
- // Common misconfig: Alma/Codex passes literal "${DOC2X_API_KEY}" without expansion.
7
6
  if (v.includes('${') && v.includes('}'))
8
7
  return '';
9
8
  const bearerPrefix = /^bearer\s+/i;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@noedgeai-org/doc2x-mcp",
3
- "version": "0.1.3-dev.5.1",
3
+ "version": "0.1.3",
4
4
  "description": "Doc2x MCP server (stdio, MCP SDK).",
5
5
  "license": "MIT",
6
6
  "engines": {
@@ -21,7 +21,8 @@ description: 使用 Doc2x MCP 工具完成文档解析与转换:对 PDF/扫描
21
21
  `doc2x_parse_pdf_submit.pdf_path` 必须以 `.pdf` 结尾;图片解析使用 `png/jpg`。
22
22
 
23
23
  3. 不要并发重复提交导出
24
- 同一个 `uid` 对同一种导出配置(`to + formula_mode + formula_level (+ filename + filename_mode + merge_cross_page_forms...)`)不要并行重复 submit。
24
+ 同一个 `uid` 对同一种导出配置(`to + formula_mode + formula_level (+ filename + filename_mode + merge_cross_page_forms...)`)不要并行重复 submit。
25
+ 补充:同一 `uid + to` 的导出结果可能会被后一次覆盖;做“多档对比”(如 `formula_level=0/1/2`)时,必须按 **导出成功 → 立即下载落盘 → 再导出下一档** 的顺序执行。
25
26
 
26
27
  4. 不要泄露密钥
27
28
  永远不要回显/记录 `DOC2X_API_KEY`。排错只用 `doc2x_debug_config` 的 `apiKeyLen/apiKeyPrefix/apiKeySource`。
@@ -38,7 +39,7 @@ description: 使用 Doc2x MCP 工具完成文档解析与转换:对 PDF/扫描
38
39
  - 可选 `model: "v3-2026"`;不传则默认 `v2`。
39
40
  - `doc2x_convert_export_submit` / `doc2x_convert_export_wait`
40
41
  - `formula_mode`:`"normal"` 或 `"dollar"`(关键参数,建议总是显式传入)。
41
- - `formula_level`:`0 | 1 | 2`(可选)
42
+ - `formula_level`:`0 | 1 | 2`(可选,**数字类型**,不要传字符串 `"0"|"1"|"2"`)
42
43
  - `0`:不退化公式(保留原始 Markdown)
43
44
  - `1`:行内公式退化为普通文本(`\(...\)`、`$...$`)
44
45
  - `2`:行内 + 块级公式全部退化为普通文本(`\(...\)`、`$...$`、`\[...\]`、`$$...$$`)
@@ -91,6 +92,7 @@ description: 使用 Doc2x MCP 工具完成文档解析与转换:对 PDF/扫描
91
92
  - 需要做公式退化时显式传 `formula_level`(`0/1/2`);若不需要退化,建议显式传 `0`,避免调用端默认值歧义
92
93
  - `filename`/`filename_mode` 主要用于 `md/tex`:传不带扩展名的 basename,并配合 `filename_mode: "auto"`(避免 `name.md.md` / `name.tex.tex`)
93
94
  - 对同一个 `uid` 做多格式导出时,先确定顺序(例如先 md 再 docx),逐个完成再进行下一个格式
95
+ - 对同一个 `uid` 的同一格式做“多档参数对比”(如 `formula_level`),每一档都要先下载再进行下一档,避免覆盖导致误判
94
96
 
95
97
  **批量下载(并行)**
96
98
 
@@ -138,12 +140,14 @@ description: 使用 Doc2x MCP 工具完成文档解析与转换:对 PDF/扫描
138
140
 
139
141
  如果返回包含截断提示(`[doc2x-mcp] Output truncated ...`),应切换到“工作流 B”导出 md 获取完整内容。
140
142
 
141
- ### 工作流 D:PDF LaTeX / DOCX
143
+ ### 工作流 D:PDF 导出格式(MD / TEX / DOCX
142
144
 
143
- - LaTeX:把 `to` 设为 `"tex"`
144
- - Word:把 `to` 设为 `"docx"`
145
- - 调用链同“工作流 A / B”(先解析 → 再导出 → 再下载),仅替换 `to`(以及必要时调整 `formula_mode/formula_level/filename`)
145
+ - Markdown:`to="md"`(完整 Markdown 导出优先参考“工作流 B”)
146
+ - LaTeX:`to="tex"`
147
+ - Word:`to="docx"`
148
+ - 调用链同“工作流 A / B”(先解析 → 再导出 → 再下载),按目标格式调整 `to`(并按需设置 `formula_mode/formula_level/filename`)
146
149
  - 注意:`doc2x_convert_export_submit.formula_mode` 必填(`"normal"` 或 `"dollar"`);`formula_level` 可选(`0/1/2`)
150
+ - 若需要对比不同 `formula_level`,请按顺序执行并在每次导出成功后立即下载,再进行下一档,避免后一次结果覆盖前一次。
147
151
 
148
152
  ### 工作流 E:图片 → Markdown(版面解析)
149
153