feat: support single file input (input_file) alongside directory mode

This commit is contained in:
Tony
2026-05-09 15:02:56 +08:00
parent 4a48ded39e
commit df11f4e79b
3 changed files with 74 additions and 21 deletions

View File

@@ -5,19 +5,35 @@ Python MCP Server for PDF OCR batch processing.
## Features
- **Batch OCR** - Process multiple PDF files and save results as Markdown
- **Single File OCR** - Process a single PDF file directly
## Tool
### `batch_ocr_pdf`
Batch process all PDF files in a directory using the OCR API.
OCR process PDF file(s) using the OCR API. Supports both single file and directory modes.
**Parameters:**
- `input_dir`: Directory containing PDF files
- `output_dir`: Directory to save Markdown results
- `input_file`: Path to a single PDF file to process (mutually exclusive with `input_dir`)
- `input_dir`: Directory containing PDF files to process (mutually exclusive with `input_file`)
- `output_dir`: Directory to save Markdown results (auto-created if not provided)
- `api_key`: OCR API key (optional, reads from `OCR_API_KEY` env var)
- `base_url`: OCR API base URL (default: `https://agent.imqimacau.com`)
**Usage Modes:**
1. **Single File Mode**: Provide `input_file` only
```
input_file: /path/to/document.pdf
```
2. **Batch Mode**: Provide `input_dir` only
```
input_dir: /path/to/pdf_directory
```
**Note:** `input_file` and `input_dir` are mutually exclusive. At least one must be provided.
**Returns:** JSON with processing results (success/fail counts per file)
## Setup