AI agents + PDF
PDF MCP Server
Give Claude, GPT-4, or any AI agent the ability to generate, store, and deliver PDFs from plain HTML. The MCP server exposes the full PDFPipe API as native tool calls, so your agent never needs to write HTTP boilerplate.
Add to Claude Desktop in 30 seconds
Install the server globally with npx and add your API key. The next time Claude Desktop starts, it picks up the server automatically.
// Add to claude_desktop_config.json
{
"mcpServers": {
"pdfpipe": {
"command": "npx",
"args": ["-y", "pdfpipe-mcp-server"],
"env": {
"PDFPIPE_API_KEY": "pp_live_..."
}
}
}
}Once connected, Claude can generate PDFs in plain English:
You: "Generate a professional invoice for Acme Corp for $4,200,
styled with our brand colors (#d23a1d header, clean table layout,
legal footer). Return the download link."
Claude: [calls pdfpipe_generate_pdf with rendered HTML]
→ "Here's your invoice: https://api.pdfpipe.xyz/v1/documents/aB3x..."Available tools
The server registers three tools. Any MCP client discovers them automatically on connect.
// Available MCP tools (auto-discovered by any MCP client)
pdfpipe_generate_pdf // HTML or URL -> PDF saved to disk (optionally archived)
pdfpipe_list_documents // List archived documents with metadata
pdfpipe_get_document // Download an archived document by its document_id| Tool | Description |
|---|---|
pdfpipe_generate_pdf | Generate a PDF from HTML or a public URL and save it to disk. Optionally archive it and return a document URL and metadata. |
pdfpipe_list_documents | List PDFs archived under the current API key, with metadata. |
pdfpipe_get_document | Download a previously archived PDF by its document_id and save it to disk. |
LangChain agent (Python)
Use the MCP adapter for LangChain to wire the tools into any chain or agent. Works with Claude, GPT-4, or any model that supports tool use.
from langchain_anthropic import ChatAnthropic
from langchain_mcp_adapters.tools import load_mcp_tools
from mcp import ClientSession, StdioServerParameters
from mcp.client.stdio import stdio_client
server_params = StdioServerParameters(
command="npx",
args=["-y", "pdfpipe-mcp-server"],
env={"PDFPIPE_API_KEY": "pp_live_..."},
)
async def generate_invoice(invoice_data: dict) -> str:
async with stdio_client(server_params) as (read, write):
async with ClientSession(read, write) as session:
await session.initialize()
tools = await load_mcp_tools(session)
model = ChatAnthropic(model="claude-opus-4-5").bind_tools(tools)
response = await model.ainvoke([
{"role": "user", "content": f"Generate an invoice PDF for: {invoice_data}. Return the download URL."}
])
return response.contentCursor integration
Add the server to Cursor's MCP config and your coding agent can generate PDFs from documentation, reports, and HTML artifacts without leaving the IDE.
// .cursor/mcp.json — add PDFPipe to Cursor's MCP tool palette
{
"mcpServers": {
"pdfpipe": {
"command": "npx",
"args": ["-y", "pdfpipe-mcp-server"],
"env": {
"PDFPIPE_API_KEY": "pp_live_..."
}
}
}
}
// Now your Cursor agent can call:
// "Generate a README as a PDF and give me the download link"
// "Turn this HTML report into a PDF stored for 30 days"OpenAI function calling (Node.js)
Not using MCP? Wire the API directly as a tool definition for GPT-4 or any OpenAI-compatible model. The same JSON schema works across providers.
import OpenAI from "openai";
const client = new OpenAI();
// Tool definition for OpenAI function calling
const tools = [
{
type: "function" as const,
function: {
name: "generate_pdf",
description: "Generate a PDF from HTML content and return a download URL",
parameters: {
type: "object",
properties: {
html: { type: "string", description: "HTML content to render" },
filename: { type: "string", description: "Name for the PDF file" },
store: { type: "boolean", description: "Store the PDF for later retrieval" },
},
required: ["html"],
},
},
},
];
async function agentGeneratePdf(prompt: string) {
const messages = [{ role: "user" as const, content: prompt }];
const response = await client.chat.completions.create({
model: "gpt-4o",
messages,
tools,
});
const toolCall = response.choices[0].message.tool_calls?.[0];
if (toolCall?.function.name === "generate_pdf") {
const args = JSON.parse(toolCall.function.arguments);
const pdfRes = await fetch("https://api.pdfpipe.xyz/v1/pdf", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.PDFPIPE_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({ ...args, store: true }),
});
const { document_url } = await pdfRes.json();
return document_url;
}
}Why a dedicated PDF tool for agents?
AI agents that try to run a headless browser locally hit memory limits, timeout errors, and missing font issues almost immediately. PDFPipe moves the render step to a managed API: your agent sends HTML, gets a document URL back. No infrastructure, no dependencies, no browser lifecycle to manage.
- CSS grid, flexbox, custom fonts, and @page rules all render correctly
- Rendered PDFs are stored and accessible via a permanent URL
- The tool call completes in under 3 seconds on average
- Usage is metered per document, not per token or compute minute
- Works with any MCP-compatible host: Claude Desktop, Cursor, Claude.ai, Zed
MCP server package
| npm package | pdfpipe-mcp-server |
| Install | npx -y pdfpipe-mcp-server (no global install needed) |
| Transport | stdio (compatible with all MCP clients) |
| Auth | PDFPIPE_API_KEY environment variable |
| Source | Open source on GitHub: pdfpipe-libraries |