Skip to main content
Glama
marc-hanheide

PDF Redaction MCP Server

usage_example.py2.53 kB
"""Example usage of the PDF Redaction MCP Server.""" import asyncio from pathlib import Path from fastmcp import Client # Server URL (adjust based on how you're running the server) # For stdio: Use subprocess or direct import # For HTTP: Use the HTTP URL async def main(): """Demonstrate PDF redaction workflow.""" # Example assumes you have a PDF at this path pdf_path = "/path/to/your/document.pdf" # Connect to the server (HTTP example) # For local testing, run the server with: fastmcp run redact_mcp.server:mcp --transport http --port 8000 client = Client("http://localhost:8000/mcp") async with client: print("=" * 60) print("PDF Redaction MCP Server - Example Usage") print("=" * 60) # Step 1: Load the PDF print("\n1. Loading PDF...") result = await client.call_tool("load_pdf", {"pdf_path": pdf_path}) print(f"PDF Content:\n{result.content[0].text[:500]}...") # Show first 500 chars # Step 2: List loaded PDFs print("\n2. Listing loaded PDFs...") result = await client.call_tool("list_loaded_pdfs", {}) print(result.content[0].text) # Step 3: Redact specific text print("\n3. Redacting sensitive text...") result = await client.call_tool("redact_text", { "pdf_path": pdf_path, "text_to_redact": "confidential", "fill_color": (0, 0, 0) # Black }) print(result.content[0].text) # Step 4: Redact a specific area (optional) print("\n4. Redacting a specific area...") result = await client.call_tool("redact_area", { "pdf_path": pdf_path, "page_number": 1, "x0": 100, "y0": 100, "x1": 300, "y1": 150, "fill_color": (0, 0, 0) }) print(result.content[0].text) # Step 5: Save the redacted PDF print("\n5. Saving redacted PDF...") result = await client.call_tool("save_redacted_pdf", { "pdf_path": pdf_path }) print(result.content[0].text) # Step 6: Close the PDF print("\n6. Closing PDF...") result = await client.call_tool("close_pdf", {"pdf_path": pdf_path}) print(result.content[0].text) print("\n" + "=" * 60) print("Example completed successfully!") print("=" * 60) if __name__ == "__main__": asyncio.run(main())

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/marc-hanheide/redact_mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server