Awels PDF Processing Server
Enables conversion of PDF files to Markdown format with optional image extraction using docling. Supports batch processing of multiple PDFs with structured output including metadata and processing statistics.
README
Awels MCP Server - PDF Processing Tool
A Model Context Protocol (MCP) server that provides PDF processing capabilities using docling. This server exposes a single tool to convert PDF files to Markdown format with optional image extraction, designed to run in isolated environments to avoid permission issues.
Project Structure
awels-mcp/
├── src/
│ └── awels_mcp/
│ ├── pdf_processor/ # PDF processing functionality
│ │ └── __init__.py # PDFProcessor implementation
│ ├── __init__.py # Package initialization
│ ├── run_server.py # Server entry point
│ └── server.py # MCP server implementation
├── tests/ # Test files
│ ├── artifacts/ # Test artifacts (PDFs, outputs)
│ │ ├── test_output_md/ # Generated markdown files
│ │ ├── test_output_images/# Extracted images
│ │ └── test_pdfs/ # Sample PDFs for testing
│ ├── test_client.py # Test MCP client
│ ├── test_pdf_processor.py # Unit tests for PDF processing
│ └── test_server.py # Server tests
├── .gitignore
├── INSTALL.md # Installation instructions
├── LICENSE
├── PLAN.md
├── README.md # This file
├── pyproject.toml # Project metadata and dependencies
└── requirements.txt # Development dependencies
Features
- PDF to Markdown Conversion: Convert PDF files to clean Markdown format using docling
- Image Extraction: Extract images from PDFs (page images, tables, figures)
- Batch Processing: Process multiple PDF files in a directory (with recursive search)
- Structured Output: Returns detailed JSON results with file metadata and processing statistics
- Isolated Execution: Designed to run with
uvx --isolatedto prevent permission issues - Error Handling: Graceful handling of permission errors and processing failures
Installation
See INSTALL.md for detailed installation instructions using uv.
Quick Start
- Install the package in development mode:
uv venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
uv pip install -e .
- Run the tests to verify the installation:
pytest tests/
- Start the MCP server:
python -m src.awels_mcp.run_server
- In a separate terminal, run the test client:
python tests/test_client.py
Running Tests
The test suite includes:
- Unit tests for the PDF processor
- Integration tests for the MCP server
- End-to-end tests with the client
To run all tests:
pytest tests/
Test artifacts (generated markdown and images) are saved in the tests/artifacts/ directory.
Development
Project Structure
src/awels_mcp/: Main package source codepdf_processor/: PDF processing functionalityserver.py: MCP server implementationrun_server.py: Entry point for the MCP server
Adding New Features
- Create a new branch for your feature
- Add tests for your feature in the appropriate test file
- Implement your feature
- Run tests to ensure everything works
- Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Integration with MCP Clients
Add to your MCP client configuration (e.g., Claude Desktop):
{
"mcpServers": {
"awels-pdf-processor": {
"command": "uvx",
"args": [
"--python=3.12",
"--isolated",
"--from=git+https://github.com/your-org/awels-mcp.git",
"awels-mcp-server"
]
}
}
}
Tool Reference
convert_pdf
Converts PDF files in a directory to Markdown with optional image extraction.
Parameters:
directory(string, required): Directory path to search for PDF filesrecursive(boolean, optional): Whether to search recursively in subdirectories (default: true)markdown_output_path(string, optional): Directory to save markdown filesimages_dir(string, optional): Directory to extract images from PDFs
Returns: Structured JSON with processing results:
{
"summary": {
"total_files": 5,
"successful": 4,
"failed": 1,
"total_pages": 120,
"total_images_extracted": 25
},
"files": {
"/path/to/file1.pdf": {
"filename": "file1.pdf",
"name": "file1.pdf",
"size": 1024000,
"modified": 1640995200.0,
"pages": 10,
"metadata": {
"title": "Document Title",
"author": "Author Name",
"subject": "Document Subject"
},
"extracted_images": [
"/path/to/images/file1-page-1.png",
"/path/to/images/file1-table-1.png"
],
"markdown_file": "/path/to/markdown/file1.md",
"content": "# Document Title\n\nDocument content in markdown..."
},
"/path/to/file2.pdf": {
"error": "Failed to convert PDF: Permission denied"
}
}
}
Usage Examples
Basic PDF Conversion
# Convert all PDFs in a directory to markdown (content returned in response)
convert_pdf(directory="/path/to/pdfs")
Save Markdown Files
# Convert PDFs and save markdown files to disk
convert_pdf(
directory="/path/to/pdfs",
markdown_output_path="/path/to/output/markdown"
)
Extract Images
# Convert PDFs and extract all images
convert_pdf(
directory="/path/to/pdfs",
markdown_output_path="/path/to/output/markdown",
images_dir="/path/to/output/images"
)
Non-Recursive Search
# Only process PDFs in the specified directory (no subdirectories)
convert_pdf(
directory="/path/to/pdfs",
recursive=false
)
Architecture
The server uses:
- FastMCP: High-level MCP server framework for easy tool definition
- docling: Advanced PDF processing library for text and image extraction
- Pydantic: Data validation and structured output
- Isolated execution: Runs in isolated environment to prevent permission issues
Error Handling
The server gracefully handles:
- Permission errors (designed to run in isolated environments)
- Missing directories
- Corrupted PDF files
- Processing failures
- File system errors
All errors are reported in the structured output with detailed error messages.
Development
Project Structure
awels/
├── src/
│ └── awels_mcp/
│ ├── __init__.py
│ ├── server.py # Main MCP server implementation
│ └── pdf_processor.py # PDF processing logic
├── pyproject.toml # Package configuration
├── README.md # This file
└── PLAN.md # Development plan
Running Tests
# Install development dependencies
uv sync --group dev
# Run tests (when available)
uv run pytest
Code Formatting
# Format code
uv run black src/
uv run isort src/
# Type checking
uv run mypy src/
Requirements
- Python 3.10+
- docling and docling-core libraries
- MCP Python SDK
- Sufficient disk space for temporary files and model downloads
License
MIT License - see LICENSE file for details.
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Support
For issues and questions:
- GitHub Issues: https://github.com/your-org/awels-mcp/issues
- Documentation: See PLAN.md for technical details
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。