Skip to main content
Glama
file-analysis-mcp

file-analysis-mcp

file-analysis-mcp

"Read all the pdf/docx/pptx/svg/png documents in this folder and summarize them." A personal MCP server that lets you ask Claude Code to do this with a single sentence.

Python 3.11+ MCP read--only tests

Point it at a folder and it opens the documents inside and returns just the raw text. Summarizing and interpreting is done by the Claude that calls this server during the conversation — not by the server itself. So it runs fully locally and privately, with no separate LLM API key.


Table of Contents


Related MCP server: file-analyzer

How it actually works

This is the result of asking Claude Code to look at a real folder (a folder containing internal PRD documents).

Me: Summarize the documents in the docs folder and analyze the file structure

Claude calls analyze_folder_structure → analyze_folder in sequence, then answers based on the raw text it received.

[analyze_folder_structure] pdf 2개, 총 455KB, 최대 파일 prd.pdf(231KB)
[analyze_folder]           2개 파일 모두 추출 성공 (succeeded: 2, failed: 0)

→ Claude의 요약:
두 문서는 같은 프로젝트("ParameterCheck")의 서로 다른 산출물입니다.
- proposal.pdf: RF솔루션 파트의 CAB 파라미터 검증 자동화 기획서
- prd.pdf: 같은 아이디어의 정식 PRD. 목표는 검증 시간 10분→5분 단축,
  MVP는 "파라미터 엑셀 입력 시 집계시트 자동 생성 + 오류 빨강 표시"
공통점: 사람 검토·승인은 항상 최종 단계로 남겨둔다는 원칙이 두 문서 모두에 명시됨.

The server only passed the text — every sentence in the summary above was written by Claude. That is the division of labor this project aims for.

Quick start

# 1) 의존성 설치 (uv 사용)
uv sync --extra dev

# 2) 확인
uv run pytest                        # 유닛테스트
uv run python scripts/smoke_stdio.py # 실제 MCP 프로토콜로 서버를 띄워보는 스모크 테스트

If you need OCR (PNG analysis), install Tesseract-OCR separately — instructions are in the earlier part of Registering with Claude Code below. The other 4 tools work fine even before you install it.

The 5 tools

Tool

Description

Guardrail

scan_folder

Returns the list of target files in a folder (path/size/modified date) and counts by extension

If max_files (default 300) is exceeded, sets list_truncated=True

analyze_folder_structure

Returns the tree structure including subfolders, statistics by extension, size, and the list of largest files

Only the tree is capped by max_files (statistics are always based on the full set)

read_document

Extracts the text of a single pdf/docx/pptx/svg document

Truncates at max_chars and marks it explicitly with truncated=True

read_image_text

Reads a single png image via OCR and extracts the text

Same as above + if OCR returns nothing, explains why via next_actions

analyze_folder

Extracts all target files in a folder at once and returns them as a report (no need to call multiple times)

If max_files (default 50) is exceeded, states the count via skipped_due_to_limit

All tools are read-only and never modify or delete files. Even when a limit (max_files) is hit, files are not silently dropped — the response records exactly how many were skipped, and status becomes PARTIAL so you can tell right away.

Registering with Claude Code

Installing the OCR engine (only needed for PNG analysis)

pytesseract is just a Python binding for the Tesseract-OCR engine; the engine itself must be installed separately.

  1. Download the UB-Mannheim Tesseract installer and install it on Windows. (If you need Korean recognition, check Korean under "Additional language data" during installation.)

  2. Add the install path (default C:\Program Files\Tesseract-OCR) to your system PATH.

  3. Verify the installation with tesseract --version.

Registering the server

This repository already has a .mcp.json prepared at the root. Running Claude Code from the file-analysis-mcp folder (or a parent folder) will pick it up automatically. After restarting, check that the 5 file-analysis tools appear in the /mcp command or the tool list.

To register manually:

claude mcp add file-analysis -- uv --directory "C:\Users\20223\Desktop\file-analysis-mcp" run python src/file_analysis_mcp/server.py

Recommended flow: first understand the structure with analyze_folder_structure → batch-extract all document text with analyze_folder → Claude summarizes based on the extracted text.

Project structure

file-analysis-mcp/
├── pyproject.toml
├── .mcp.json
├── src/file_analysis_mcp/
│   ├── server.py        # FastMCP 서버, 도구 5개
│   ├── harness.py        # 응답/오류 계약 (BaseResponse, ToolFailure 등)
│   ├── scanner.py         # 폴더 스캔/구조 분석
│   └── extractors/        # pdf/docx/pptx/svg/image 텍스트 추출기
├── scripts/smoke_stdio.py
├── tests/
│   ├── test_scanner.py           # 도메인 로직(순수 함수) 유닛테스트
│   ├── test_extractors.py        # 포맷별 추출기 유닛테스트
│   └── test_server_contract.py   # 하네스 규약(도구 계약) 테스트
└── data/sample_docs/       # 테스트용 샘플 문서

Design principle: harness engineering

This server prioritizes making it so the model can tell from the response alone what to do next over "adding more features." Of the principles introduced in awesome-harness-engineering, it selectively applies only the ones that actually fit this project's nature — local, single-user, read-only. (OpenTelemetry observability, prompt-injection sandboxing, and mcp-guardian-style scope-approval gating are meant for multi-user, long-running agents, so they would be overkill for a personal tool of this scale and were not applied.)

What was applied

Its form in this project

Clear tool boundaries

Each tool docstring states its purpose + Returns + "use / don't use" examples, so the model picks the right one among the 5 tools

Next-action guidance

Every response includes status + next_actions. For each situation (success / partial success / empty result, etc.) it concretely suggests which tool to call next and why

Actionable errors

ToolFailure enforces a cause code + recovery method + selectable values. E.g. unsupported extension → the list of supported extensions

Context economy (per response)

read_document/read_image_text/analyze_folder truncate at max_chars (per file) and mark it with truncated

Context economy (guardrails)

scan_folder/analyze_folder_structure/analyze_folder cap the file count (max_files) so a single call never grows unbounded even if the folder has a huge number of files

Keeping useful failures in context

analyze_folder does not abort the batch when a single file fails; it records success/failure per file so the next step can be decided from it

No silent loss

Even when a limit is exceeded, files are not quietly skipped — list_truncated/skipped_due_to_limit record exactly how many were not seen

Tool contract tests

tests/test_server_contract.py verifies in code that "every tool has a description/annotations", "argument schemas are flat", "all tools are read-only", and "guardrails actually work"

Deliberately not applied

  • Summarization/grounding features: This server is designed to "extract only" (summarizing is the host model's job), so these do not apply.

  • Line-number citation anchors (L12 | ...): Without a separate tool that verifies cited evidence, this would only clutter the text, so it was not applied. If it ever becomes necessary, it can be added by reusing harness.number_lines().

  • Approval-token-based save workflows: This server does not write files, so it does not apply.

Available Tools

5 tools
analyze_folderA
Read-onlyIdempotent

폴더 안의 모든 대상 파일(pdf/docx/pptx/svg/png)을 한 번에 추출해 리포트로 반환합니다.

파일마다 read_document/read_image_text를 따로 호출하지 않아도 되는 배치 도구입니다. 한 파일이 실패해도 나머지 파일 처리는 계속되며, 실패 이유는 파일별로 남습니다. 파일 수가 max_files를 넘으면 앞쪽부터 max_files개만 처리하고, 넘겨받지 못한 개수는 skipped_due_to_limit로 투명하게 알려줍니다(조용히 누락되지 않습니다).

Returns: AnalyzeFolderResponse: reports[]의 각 항목은 status(OK/ERROR)와 함께 text 또는 error를 담습니다. status가 PARTIAL이면 일부 실패했거나(failed>0) 상한 때문에 스킵된 파일(skipped_due_to_limit>0)이 있다는 뜻입니다.

Examples: - 사용: "이 폴더 문서들 다 요약해줘", "폴더 구조 분석하고 내용도 정리해줘" - 사용하지 않음: 파일 목록만 필요할 때 → scan_folder - 사용하지 않음: 특정 파일 하나만 자세히 → read_document / read_image_text

Inputs: folder_path (required), max_files, recursive, extensions, +1 more. Returns: failed, folder, status, reports, +5 more

analyze_folder_structureA
Read-onlyIdempotent

폴더의 하위 디렉터리 트리와 확장자별 통계, 용량, 최대 파일을 분석합니다.

scan_folder보다 한 단계 더 깊은 "구조" 파악용 도구입니다. 폴더가 어떻게 구성돼 있는지(하위 폴더별 파일 분포, 가장 큰 파일 등)를 먼저 감 잡고 싶을 때 사용하세요.

Returns: FolderStructureResponse: tree는 {"하위폴더명": {...}, "_files": [...]} 형태의 중첩 딕셔너리입니다. 파일이 max_files보다 많으면 tree에는 앞쪽 max_files개만 반영되고 list_truncated=True가 되지만, total_files/ by_extension/total_size_bytes 등 통계는 항상 전체 파일 기준입니다.

Examples: - 사용: "이 폴더 구조 좀 분석해줘", "가장 큰 파일이 뭐야?" - 사용하지 않음: 파일 목록만 빠르게 보고 싶을 때 → scan_folder

Inputs: folder_path (required), max_files, extensions. Returns: tree, folder, status, max_depth, +6 more

read_documentA
Read-onlyIdempotent

문서 파일(pdf/docx/pptx/svg) 하나의 텍스트를 추출합니다. 요약은 하지 않습니다.

scan_folder/analyze_folder에서 찾은 파일 중 하나를 더 자세히 보고 싶을 때, 또는 analyze_folder의 일괄 요약이 잘렸을 때(truncated=True) 이어서 읽을 때 씁니다.

Returns: ReadDocumentResponse: text에 원문(잘렸으면 앞부분)이 담깁니다. truncated=True면 max_chars를 늘려 다시 호출해 나머지를 볼 수 있습니다.

Examples: - 사용: "이 pdf 파일 내용 좀 자세히 보여줘" - 사용하지 않음: png 이미지 → read_image_text - 사용하지 않음: 폴더 전체를 한 번에 훑고 싶을 때 → analyze_folder

Inputs: file_path (required), max_chars. Returns: path, text, status, metadata, +3 more

read_image_textA
Read-onlyIdempotent

PNG 이미지 하나를 OCR로 읽어 텍스트를 추출합니다(Tesseract-OCR 필요).

스크린샷, 스캔한 메모, 다이어그램에 박힌 라벨처럼 이미지 안의 문자를 읽어야 할 때 사용하세요. 순수 그림/사진처럼 텍스트가 없는 이미지는 빈 결과가 나올 수 있습니다(비전 해석이 아니라 OCR이므로 그림 자체의 의미는 파악하지 못합니다).

Returns: ReadImageTextResponse: text에 인식된 문자열이 담깁니다. 결과가 비어 있으면 next_actions에서 그 이유를 안내합니다.

Examples: - 사용: "이 스크린샷에 뭐라고 적혀 있어?" - 사용하지 않음: pdf/docx/pptx/svg 문서 → read_document

Inputs: file_path (required), max_chars. Returns: path, text, status, metadata, +2 more

scan_folderA
Read-onlyIdempotent

폴더 안의 대상 파일(pdf/docx/pptx/svg/png) 목록과 확장자별 개수를 조회합니다.

문서 내용을 읽지 않고 메타데이터(경로/크기/수정일)만 가볍게 훑어보는 도구입니다. 폴더 안에 어떤 파일이 몇 개 있는지 빠르게 확인하고 싶을 때 사용하세요.

Returns: ScanFolderResponse: files[]에 경로/이름/확장자/크기/수정일이 담깁니다. 파일이 max_files보다 많으면 list_truncated=True이고, by_extension의 개수는 상한과 무관하게 항상 전체 매칭 파일 기준입니다.

Examples: - 사용: "이 폴더에 어떤 문서들이 있어?", "pdf 몇 개야?" - 사용하지 않음: 파일 내용까지 요약하고 싶을 때 → analyze_folder - 사용하지 않음: 하위 폴더 구조/통계까지 보고 싶을 때 → analyze_folder_structure

Inputs: folder_path (required), max_files, recursive, extensions. Returns: files, folder, status, total_files, +4 more

Tool Schema Changelog

Recent tool additions, removals, and schema changes observed during successful MCP inspections.

Loading tool schema changelog…

    TDQS

    A4.5/5.0

    Scored across 5 tools

    Disambiguation5/5

    Each tool has a clearly distinct purpose: read_document handles individual text documents, scan_folder lists metadata, analyze_folder_structure provides hierarchical stats, read_image_text does OCR, and analyze_folder batch-processes all files. Descriptions explicitly state what not to use each tool for, reinforcing boundaries.

    Naming Consistency5/5

    All tool names follow a consistent snake_case verb_noun pattern (read_document, scan_folder, analyze_folder_structure, read_image_text, analyze_folder). The verbs are distinct and descriptive, and the pattern is uniform across the set.

    Tool Count5/5

    With 5 tools, the server is well-scoped for file and folder analysis. Each tool covers a distinct aspect (single read, metadata scan, structure analysis, OCR, batch processing) without redundancy or missing essentials, making the count ideal for its purpose.

    Completeness5/5

    The tool surface covers the full lifecycle of file analysis: listing, detailed reading (both text and OCR), structural analysis, and batch processing. Error handling and truncation are addressed. No obvious gaps for the stated domain, such as missing file deletion or modification, which are out of scope.

    Maintenance

    ActivityStale
    ResponsivenessOutdated data

    Related MCP Connectors

    Related MCP Servers

    • A
      license
      A
      quality
      F
      maintenance
      Provides LLMs with secure, read-only access to local documentation by scanning directories, extracting content from PDF, DOCX, Markdown, and text files, and performing keyword searches.
      3
      5 npm
      MIT
    • F
      license
      A
      quality
      C
      maintenance
      Enables read-only analysis of local unstructured documents by scanning a folder, extracting text and structural metadata, and passing content with truncation and error-awareness to an LLM for summarization.
      9
      1
      -
    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables local, read-only extraction of text and structure from PDF, DOCX, PPTX, SVG, and PNG files, including OCR for images, directory tree and metadata reporting, with strict path isolation and audit logging.
      -
    • F
      license
      Not graded
      quality
      C
      maintenance
      Enables local folder analysis of unstructured documents (PDF, DOCX, PPTX, TXT, SVG, PNG, CSV, XLSX) by extracting structure, reading content, and generating reports, with a strict approval gate before any save operation.
      -