SuperAPI AI Directory

doc-extract-mcp

Document extraction tooling: read PDFs, text, CSV and JSON, inspect metadata, chunk long documents, validate against JSON Schema and write JSON/CSV output.

Open website

About this tool

Purpose

doc-extract-mcp is an MCP (Model Context Protocol) server that provides deterministic document processing tools for LLMs, specifically for structured data extraction workflows. Its design philosophy is: the LLM handles reading and extraction reasoning, while the server provides the parts that should never be left to a language model—reliable file access, parsing, chunking, JSON Schema validation, and protected file output.

The project was developed by Koray Nar as a portfolio project for the AI document automation workflows he is building, with the target use case of converting messy PDFs (purchase orders, invoices, reports) into schema-conformant JSON. It works with Claude Code, Claude Desktop, and any other MCP client.

Key Capabilities

The server is designed to eliminate common failure modes of extraction agents:

  • File access is restricted to an allowed root directory (DOC_EXTRACT_ROOT).
  • PDF text arrives with explicit --- page N --- markers, so a reference to "page 3" corresponds to page 3.
  • Long documents are chunked deterministically, with overlap and page hints.
  • Extracted JSON is validated against a JSON Schema (Draft 2020-12), and every error is reported with a JSON Pointer path—not just the first error—so the model can fix all errors at once.
  • Output is written by the server (JSON or CSV), within the same root directory, with verifiable line/byte counts.
  • All path arguments are resolved and rejected if they fall outside the allowed root directory (path traversal protection).glob_pattern parameters are restricted in the same way: absolute patterns and patterns containing .. are rejected, and any matches that resolve outside the root directory (for example via symlinks) are silently dropped from the list. Guard failures are thrown as MCP tool errors, so the calling model can see the actual reason rather than a masked generic error.

Usage

Requires Python 3.11+ and uv.

Run standalone (stdio transport):

uvx doc-extract-mcp

Add to claude_desktop_config.json:

{
  "mcpServers": {
    "doc-extract-mcp": {
      "command": "uvx",
      "args": ["doc-extract-mcp"],
      "env": {
        "DOC_EXTRACT_ROOT": "/path/to/documents"
      }
    }
  }
}

DOC_EXTRACT_ROOT If not set, defaults to the server's working directory. Set it to the folder where your documents are located; nothing outside that folder can be read or written.

Typical workflow:

  1. list_documents(".", "*.pdf") — find the invoice.
  2. document_info("invoice.pdf") — check the page count.
  3. read_document("invoice.pdf", "1-3") or chunk_document(...) — get the text.
  4. The LLM extracts the fields as JSON.
  5. validate_json(data, json_schema) — fix every reported error and re-validate.
  6. save_structured("out/invoice.json", data, "json") — write the result.

Suitable Scenarios

  • Convert PDF invoices, purchase orders, and reports into structured JSON.
  • AI extraction workflows that require deterministic document processing (chunking, validation, output).
  • Use with Claude Code, Claude Desktop, or other MCP clients.

Limitations

  • Only text-based PDFs are supported. Extraction uses pypdf; scanned/image-only PDFs will produce empty text. There is no OCR.
  • Extraction quality varies depending on how the PDF was generated. Complex layouts (multiple columns, many tables) may produce imperfect reading order—this is a pypdf characteristic inherited by the server.
  • .docx / .xlsx are not supported. The supported types are .pdf、.txt、.md、.csv、.json.
  • The server does not perform any extraction reasoning. It does not find your invoice total; it ensures that the model performing extraction works based on real text, and that the results conform to your Schema.
  • This is a working tool, built for the AI automation work the author is building, and released as part of a portfolio—it is new and has no production usage record. It has tests and path restriction safeguards, but beyond that it is not hardened—review it before pointing it at sensitive directories.
  • The test suite builds a small two-page PDF test fixture in memory (a hand-built minimal PDF, with no extra dependencies), covering all six tools, path traversal protection, glob pattern restrictions (including symlink escape), page range errors, multi-error Schema validation, CSV round-trip, and tool registration and error propagation through the MCP server object.

MIT © 2026 Koray Nar