3 Commits

Author SHA1 Message Date
e087a3b7a0 Add MCP resource URIs for extracted PDF images
Implement proper MCP resource protocol for image access, eliminating the need
for clients to handle local file paths and enabling seamless image integration.

Key Features:
• MCP Resource Endpoint: pdf-image://{image_id} for direct image access
• extract_images(): Returns resource_uri field with MCP resource links
• pdf_to_markdown(): Embeds resource URIs in markdown image references
• Automatic MIME type detection (image/png, image/jpeg)
• Seamless client integration without file path handling

Benefits:
 Direct image access via MCP resource protocol
 No local file path dependencies for MCP clients
 Proper MIME type handling for image display
 Clean markdown with working image links
 Standards-compliant MCP resource implementation

Response Format Enhancement:
+ "resource_uri": "pdf-image://page_1_image_0"
+ Works in markdown: \![Image](pdf-image://page_1_image_0)
+ MIME Type: image/png or image/jpeg
+ Direct client access without file system dependencies

This resolves the limitation where extracted images were only available
as local file paths, making them truly accessible to MCP clients
through the standardized resource protocol.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-20 11:42:46 -06:00
374339a15d 🔧 Fix verbose base64 output in image extraction functions
Resolve MCP client context overflow by saving images to files instead of
returning base64-encoded data that fills client message windows.

Key Changes:
• extract_images(): Save images to CACHE_DIR with file paths in response
• pdf_to_markdown(): Save embedded images to files with path references
• Add format_file_size() utility for human-readable file sizes
• Update function descriptions to clarify file-based output

Benefits:
 Prevents context message window overflow in MCP clients
 Returns clean, concise metadata with file paths
 Maintains full image access through saved files
 Improves user experience with readable file sizes
 Reduces memory usage and response payload sizes

Response Format Changes:
- Remove: "data": "<base64_string>" (verbose)
+ Add: "file_path": "/tmp/mcp-pdf-processing/image.png"
+ Add: "filename": "page_1_image_0.png"
+ Add: "size_bytes": 12345
+ Add: "size_human": "12.1 KB"

This resolves the issue where image extraction caused excessive verbose
output that overwhelmed MCP client interfaces.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-20 11:34:42 -06:00
c902e81e4d Initial commit: Complete MCP PDF Tools server implementation
Features:
- 8 comprehensive PDF processing tools with intelligent fallbacks
- Text extraction (PyMuPDF, pdfplumber, pypdf with auto-selection)
- Table extraction (Camelot → pdfplumber → Tabula fallback chain)
- OCR processing with Tesseract and preprocessing options
- Document analysis (structure, metadata, scanned detection)
- Image extraction with filtering capabilities
- PDF to markdown conversion with metadata
- Built on FastMCP framework with full MCP protocol support
- Comprehensive error handling and user-friendly messages
- Docker support and cross-platform compatibility
- Complete test suite and examples

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-10 16:36:21 -06:00