PDF Tools MCP Server

0.1.4 · active · verified Mon Apr 13

pdf-tools-mcp is a FastAPI-based server for reading and manipulating PDF documents. It provides a RESTful API for common PDF operations like splitting, merging, extracting pages, adding content, watermarking, converting, compression, and OCR. The current version is 0.1.4, and its release cadence is irregular, driven by feature additions and maintenance.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to install and run the `pdf-tools-mcp` server, and how to perform a basic health check using `curl` or a Python `requests` client. Remember to run the `python -m pdf_tools_mcp.main` command in a separate terminal to start the server before making API requests. The server typically runs on `http://127.0.0.1:8000` by default.

# 1. Install the library
pip install pdf-tools-mcp

# 2. Run the PDF tools server
# In your terminal, run:
# python -m pdf_tools_mcp.main

# 3. Access the API (e.g., using curl in another terminal)
# curl http://127.0.0.1:8000/api/v1/health

# Expected output for health check (after server starts):
# {"status":"ok"}

# Example Python client interaction (requires 'requests')
import requests

BASE_URL = "http://127.0.0.1:8000/api/v1"

try:
    response = requests.get(f"{BASE_URL}/health")
    response.raise_for_status() # Raise an exception for HTTP errors
    print(f"Health check: {response.json()}")

    # Example: Upload a PDF (assuming you have 'example.pdf' locally)
    # with open('example.pdf', 'rb') as f:
    #     files = {'file': ('example.pdf', f, 'application/pdf')}
    #     upload_response = requests.post(f"{BASE_URL}/pdf/split", files=files,
    #                                     params={'pages': '1'})
    #     upload_response.raise_for_status()
    #     print(f"Upload/Split response: {upload_response.json()}")

except requests.exceptions.ConnectionError:
    print("Error: Could not connect to the pdf-tools-mcp server. Is it running?")
except requests.exceptions.RequestException as e:
    print(f"An error occurred: {e}")

view raw JSON →