Skip to main content
Glama

Docs Decomposer

English | 简体中文

TypeScript PDF document processor with a token-efficient MCP server.

  • Extracts PDF text with PDF.js and builds a nested section tree from the table of contents and bookmarks.

  • Exposes documents through MCP tools with paged outlines, section search, and capped section reads, so an agent never has to ingest a whole PDF at once.

  • Includes a terminal browser for opening PDFs in docs/ and paging through long section previews.

  • Supports absolute or allowed-root-relative paths, project root registration, and optional resources and prompts.

Quick start

npm install
npm test
npm run build
DOCS_DECOMPOSER_ROOTS="$PWD/docs" npm run mcp
npm run tui

Related MCP server: jdocmunch-mcp

MCP client configuration

This is the form used by the project's .mcp.json:

{
  "mcpServers": {
    "docs-decomposer": {
      "command": "sh",
      "args": ["-c", "exec npm --prefix \"$DOCS_DECOMPOSER_HOME\" run mcp"],
      "env": {
        "DOCS_DECOMPOSER_HOME": "/path/to/docs_Decomposer",
        "DOCS_DECOMPOSER_ROOTS": "/path/to/documents"
      }
    }
  }
}

DOCS_DECOMPOSER_HOME is expanded by sh to locate the project; DOCS_DECOMPOSER_ROOTS is the document directory the server is allowed to read.

A simpler form without the shell wrapper:

{
  "mcpServers": {
    "docs-decomposer": {
      "command": "npm",
      "args": ["--prefix", "/path/to/docs_Decomposer", "run", "mcp"],
      "env": {
        "DOCS_DECOMPOSER_ROOTS": "/path/to/documents"
      }
    }
  }
}

See USAGE.md for tool flows, pagination, resources, prompts, root safety, and the register_root workflow.

Commands

Command

Purpose

npm run process -- docs/<file>.pdf

Print the full Markdown extraction to stdout

npm run mcp

Start the stdio MCP server

npm run tui

Browse docs/, open PDFs, and page through section previews

npm test

Run the test suite

npm run build

Type-check the project

License

MIT

Related MCP Connectors

Related MCP Servers

  • A
    license
    A
    quality
    C
    maintenance
    Enables AI agents to efficiently process large local and online PDFs through selective extraction of text, images, and metadata. It provides tools for content search and document outline navigation to optimize context window usage.
    7
    16
    ISC
  • A
    license
    Not graded
    quality
    C
    maintenance
    Serves read-only tools that let an agent inspect PDFs step by step: outline a document, search for text or figure values, read pages and tables in order, describe figures and chart data, and render page or block images, with every block cited to its page and bounding box. It also lists the PDFs available under a configured root folder, which it never reads outside of.
    MIT