Skip to main content
Glama
asuramama-hue

file-analyzer-mcp

file-analyzer-mcp

Python Protocol Scope Tests

A personal stdio MCP server that extracts only text/structure from PDF, DOCX, PPTX, SVG, and PNG files in a local folder. It does not summarize or interpret — reading the extracted results and summarizing them is the job of the host LLM (such as Claude Code) that calls this tool.

What it does / What it doesn't do

Does

Doesn't

Extracts text/structure from documents under the specified root folder

Summarize or interpret (handled by the host LLM)

Aggregates folder tree and file count/size by extension

Write, delete, or move files (read-only)

Extracts OCR text from PNGs

Understand the visual meaning of images (figures, charts)

Handles timeouts for large/corrupted files

Change the analysis target folder while the server is running

Related MCP server: Docalyze

Example run

> read_document("quarterly-report.pdf")
{
  "type": "pdf",
  "num_pages": 12,
  "text": "Q3 Revenue Summary\n..."
}

> read_document("../../etc/passwd")
{ "error": "'../../etc/passwd' resolves outside the allowed root folder" }

Quick start

git clone https://github.com/asuramama-hue/fileanalyzer_mcp_testmonial.git
cd fileanalyzer_mcp_testmonial
python3 -m venv .venv && source .venv/bin/activate
pip install -e .
brew install tesseract   # PNG OCR용 (한국어는 brew install tesseract-lang 추가)

Register with Claude Code:

claude mcp add file-analyzer --env FILE_ANALYZER_ROOT=/분석할/폴더 -- \
  "$(pwd)/.venv/bin/python" "$(pwd)/server.py"
claude mcp list   # ✔ Connected 확인

After registration, in a new session, ask "summarize the documents in this folder" and Claude will call the 3 tools below directly.

Tools

Tool

Description

list_directory(subpath=".", recursive=True)

Folder tree, file count/size by extension

read_document(relative_path)

Text/structure extraction — .pdf .docx .pptx .svg .png

get_file_metadata(relative_path)

Size, modification time, page/slide count, image resolution, etc.

Project structure

server.py                    # FastMCP 앱 진입점, 툴 등록, 루트 폴더 검증
file_analyzer/
  security.py                #  경로 격리(resolve_safe_path), 크기 제한
  timeout.py                 #  추출 작업 하드 타임아웃
  audit.py                   #  로컬 감사 로그(logs/audit.jsonl)
  tree.py, metadata.py       #  list_directory / get_file_metadata 로직
  extractors/                #  pdf · docx · pptx · svg · image(OCR) 추출기
tests/                       # pytest 회귀 스위트
AGENTS.md                    # 호출 에이전트(Claude Code)를 위한 운영 지침

Security & constraints

Item

Policy

Path isolation

Only accessible under FILE_ANALYZER_ROOT../, absolute path injection, and symlink escapes are all blocked

File size

Returns an error without reading if larger than 50MB

Timeout

Aborts with an error if extraction/metadata parsing exceeds 30 seconds

Supported extensions

.pdf .docx .pptx .svg .png.ppt (legacy format), .jpg, etc. are not supported

Image interpretation

Only OCR text is extracted; the visual meaning of figures/charts cannot be understood

Analysis target folder

Fixed once at server startup; cannot be changed while running

Observability — audit log

Every tool call is recorded locally, one line at a time, in logs/audit.jsonl (no external transmission).

{"timestamp": "2026-08-26T06:03:35Z", "tool": "read_document", "params": {"relative_path": "report.pdf"}, "status": "ok", "duration_ms": 251.3}

To clear the log, delete logs/audit.jsonl.

Development

pip install -e ".[dev]"
pytest -q

tests/ covers path escape and absolute path injection blocking, the 5 extractors, timeouts, audit logging, and server integration. At this project's scale, I judged that local pytest runs alone are sufficient for regression validation without a CI pipeline, and have kept it that way.

Why I designed it this way

  • No summarization feature — To work without a separate LLM API key, I chose a minimal structure where the server handles extraction and the host handles summarization.

  • PNG uses OCR, not vision passthrough — Instead of passing the image to the host as base64, I extract only text to reduce response size and implementation complexity (the visual meaning of figures is not visible).

  • Local pytest only, no git/CI — For a single-person local tool of this scale, CI infrastructure seemed excessive.

Known limitations

  • The timeout is thread-based, so the background thread of an exceeded call may keep running to completion even after the response is returned.

  • .ppt is not supported — convert to .pptx before use.

License

A personal project with no separate license file.

Related MCP Connectors

Related MCP Servers

  • A
    license
    Not graded
    quality
    C
    maintenance
    MCP server that reads PDFs and exposes them as structured Markdown, metadata, outlines, images, and tables to LLM consumers via tools like pdf_read_markdown and pdf_info.
    Apache 2.0
  • A
    license
    B
    quality
    D
    maintenance
    An MCP server that lets AI assistants read and visually analyze local documents — PDFs, Excel spreadsheets, CSV files, Word documents, PowerPoint presentations, and images.
    4
    42 npm
    53 PyPI
    MIT
  • A
    license
    Not graded
    quality
    D
    maintenance
    Local MCP server that indexes folders of documents into a hybrid vector + keyword search index for Claude Desktop, with support for PDFs, Office files, and images via OCR.
    MIT
  • A
    license
    Not graded
    quality
    C
    maintenance
    MCP server for indexing, semantic search, and generation of multi-format documents. Exposes 13 tools over JSON-RPC 2.0 so an LLM can search your local PDF, Excel, and Word files, and create or edit Excel and Word documents.
    AGPL 3.0