dsh-paper2md: Using MinerU to Convert Paper PDFs to Markdown, Then Feeding Them to AI Agents

Introduction

In DSH, when allowing agents to read papers or PDFs, a common approach is to directly open binary files or let the model guess content based on filenames, resulting in unstable results. MinerU can parse PDFs into Markdown with hierarchical headings, tables, LaTeX formulas, and images, but embedding this step into an agent workflow requires handling details like API keys, caching, and arXiv links.

Below, I introduce the community plugin dsh-paper2md (maintainer: yiusnio, category: Network Tools). It wraps MinerU as a DSH tool: the agent calls paper_to_md first, then read the generated .md, and manages the MinerU Key on the settings page, using a local sha256 cache for the same paper to avoid deducting quota repeatedly.

What is this

dsh-paper2md is a “convert paper to Markdown first” plugin for DeepSeek Harness. It exposes four host-side agent tools and adds a “Convert Paper to Markdown” settings page on the browser side. It is implemented as pure ESM with zero third-party dependencies and no build steps.

The DSH ecosystem emphasizes “everything is a plugin”; platforms like SkillHub serve as community directories and have no official affiliation with DeepSeek or Hypersphere.

Core Features

  1. Main Conversion: paper_to_md accepts local paths, http(s) direct links, or arXiv abs/pdf links, converts them to Markdown via MinerU; images are extracted to the images/ subdirectory in the same folder, returning markdownPath and preview.
  2. Caching: Writes to disk based on sha256(content + parameters); reading the same paper repeatedly will not call MinerU again (unless force).
  3. Long Tasks: After submitting with wait:false, paper_task_status can be used to poll the result; it will not rerun.
  4. Indexing and Status: paper_list lists converted papers; paper_config_status checks token, output directory, and default model.
  5. Settings UI: Paste the MinerU API Key, verify and save in DSH settings, view recent conversion records, without needing to modify the config file or restart.

MinerU-side constraints (from original README): Single file ≤ 200 MB, ≤ 200 pages; Daily high-priority quota 1000 pages. When the plugin cannot fetch foreign URLs, it falls back to downloading the file locally and uploading the bytes.

Installation and Activation

Install in the DSH web profile directory (commands from the repository README):

cd $env:USERPROFILE\.dsh\profiles\web
pnpm add git+https://github.com/yiusnio/dsh-paper2md.git

Or from a local source code directory:

pnpm add file:C:/path/to/paper2md-plugin

Append "dsh-paper2md" to the dsh.profile.bundles array in package.json in that directory, restart dsh. After restarting, open Settings → Convert Paper to Markdown, paste the MinerU Key, and you can use it.

Plugin dependencies (e.g., @deepseek-ai/dsh-tools) are provided by the host and do not need to be declared separately in the plugin.

Configuring MinerU Token

Create a token at https://mineru.net/apiManage.

Recommended: Interface Configuration
Settings → Convert Paper to Markdown → Paste Key → Verify and Save. Before saving, it probes the API; 401/403 errors will not be written. After saving, it reads the configuration on every call. The same page shows the Key source, config file path, output directory, and recent records.

There are three other ways to configure, in order of priority (highest to lowest):

  1. Environment variable MINERU_TOKEN (overrides the interface Key, settings page will prompt)
  2. File ~/.dsh/paper2md.json: {"token":"eyJ..."} (permissions become 0600 after writing)
  3. Localhost HTTP API (only 127.0.0.1 / ::1):
Invoke-RestMethod -Uri http://127.0.0.1:3080/api/dsh-paper2md/token -Method POST `
  -ContentType application/json -Body '{"token":"eyJ..."}'

Query status (token not echoed):

Invoke-RestMethod http://127.0.0.1:3080/api/dsh-paper2md/status

Routes also include clear (POST) and papers (GET). Other configurable items: MINERU_BASE_URL, PAPER2MD_DIR (default ~/.dsh/paper2md/papers).

Typical Usage

Recommended flow on the agent side: call paper_to_md on the paper first, then use read to read the returned markdownPath.

Common parameters for paper_to_md (excerpted from README):

Parameter Description
source Required: Local path / URL / arXiv link
model vlm (default) / pipeline / MinerU-HTML
language Default ch, pass en for English papers
pageRanges e.g., "1-20", "2,4-6", only convert specified pages
isOcr Scanned PDF
enableFormula / enableTable Enabled by default
force Ignore cache
wait Default true; returns task.kind / task.id when false

Concept example for async polling: After submitting with wait:false, use paper_task_status passing the corresponding kind/id until it completes.

Output directory structure:

~/.dsh/paper2md/papers/
  <slug>-<hash8>/
    full.md
    images/
    .meta.json
  .pending/

Intermediate JSON artifacts are discarded by default; set keepJson: true to debug the ZIP structure.

Use Cases and Notes

Suitable for: Developers who need to stably read PDFs and arXiv papers in DSH; teams who want to ensure MinerU quota is not consumed by repeated requests.

Notes:

  • The plugin runs with the current dsh process permissions. Please read the source code and MIT license before installing, and evaluate the MinerU token and network outbound risks yourself.
  • Parsing of heading hierarchy may require manual verification (a fixed limitation of MinerU).
  • Common error when token is invalid: MinerU token 无效或权限不足(401), need to rewrite the full Key.
  • Returning pending: true is a normal async state; just continue using paper_task_status.

The repository provides offline/host/browser self-test scripts: node test/selftest.mjs, node test/dryrun.mjs, node test/client-dryrun.mjs.

Conclusion

dsh-paper2md bundles the “PDF / arXiv → Markdown → Agent read” workflow into a set of tools and settings pages, using local sha256 caching to lower MinerU call costs. When you need to do code or solution analysis starting from a paper, you can install the plugin, configure the Key, and then let the agent go through the paper_to_md pipeline.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye