Create PDFs from your CastPDF templates or HTML, issue EU e-invoices, and look up documents.
The official Model Context Protocol server for CastPDF. It lets AI agents (Claude, Cursor and other MCP clients) list your PDF templates, create PDFs and EU e-invoices, and look up documents, using your CastPDF API key.
Documents are test documents by default (watermarked, not counted against your plan). The agent only makes a live
document when you explicitly ask for one, and a cpdf_test_... key can never make live documents at all. Start with a
test key.
| Tool | What it does |
|---|---|
list_templates | Lists your saved templates (id, name, version). |
get_template_fields | The data a template expects, read from its sample data (fields and line items). |
create_pdf | Renders a template with data, or raw html, and returns a signed download URL. test defaults to true. |
create_e_invoice | Issues a ZUGFeRD / Factur-X PDF or an XRechnung XML from a structured invoice and returns a download URL. test defaults to true. |
list_documents | Recent documents, newest first, with status and download URLs. |
get_document | One document by id: status, error code, fresh download URL. |
Download links are signed and expire (see expires_at); the agent shares the link, the file itself is not sent
through the conversation.
You need Node.js 20 or newer and a CastPDF API key (dashboard > API keys). The server reads the key from the
CASTPDF_API_KEY environment variable.
Settings > Developer > Edit Config, then add to claude_desktop_config.json:
{
"mcpServers": {
"castpdf": {
"command": "npx",
"args": ["-y", "@castpdf/mcp"],
"env": { "CASTPDF_API_KEY": "cpdf_test_..." }
}
}
}
Restart Claude Desktop. On Windows, if npx is not found, use "command": "cmd" and
"args": ["/c", "npx", "-y", "@castpdf/mcp"].
claude mcp add castpdf --env CASTPDF_API_KEY=cpdf_test_... -- npx -y @castpdf/mcp
Add --scope user to use it in every project. Check it with claude mcp list or /mcp inside Claude Code.
Add to ~/.cursor/mcp.json (all projects) or .cursor/mcp.json (one project):
{
"mcpServers": {
"castpdf": {
"command": "npx",
"args": ["-y", "@castpdf/mcp"],
"env": { "CASTPDF_API_KEY": "cpdf_test_..." }
}
}
}
Do not commit a file that contains your key.
Any MCP client that starts stdio servers works with the command npx -y @castpdf/mcp and the environment variable
CASTPDF_API_KEY.
For clients that connect over HTTP, or to run one shared server:
CASTPDF_API_KEY=cpdf_test_... npx -y @castpdf/mcp --http --port 3000
# MCP endpoint: http://127.0.0.1:3000/mcp health check: http://127.0.0.1:3000/health
Every request to that endpoint uses the server's API key, so:
127.0.0.1 only and accepts only localhost, 127.0.0.1 and [::1] as Host header
(DNS rebinding protection) and no browser Origin.CASTPDF_MCP_AUTH_TOKEN to require Authorization: Bearer <token> on every request. It is required to listen
on any other interface (--host 0.0.0.0). Put a TLS-terminating proxy in front of it, and list the public host name
in CASTPDF_MCP_ALLOWED_HOSTS.Example client config for HTTP (Claude Code):
claude mcp add --transport http castpdf http://127.0.0.1:3000/mcp
| Variable / flag | Default | Meaning |
|---|---|---|
CASTPDF_API_KEY | (required) | Your CastPDF API key. |
CASTPDF_BASE_URL | https://api.castpdf.com | API base URL. |
--http or MCP_TRANSPORT=http | stdio | Serve Streamable HTTP instead of stdio. |
--port or PORT | 3000 | HTTP port. |
--host or HOST | 127.0.0.1 | HTTP interface. |
CASTPDF_MCP_AUTH_TOKEN | none | Bearer token required on HTTP requests. |
CASTPDF_MCP_ALLOWED_HOSTS | localhost names | Comma-separated Host header values to accept. |
CASTPDF_MCP_ALLOWED_ORIGINS | none | Comma-separated browser origins to accept. |
import { createServer } from '@castpdf/mcp';
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
const server = createServer({ apiKey: process.env.CASTPDF_API_KEY! });
await server.connect(new StdioServerTransport());
MIT
Source-derived launch command. Check the maintainer’s required arguments and credentials before running:
npx -y @castpdf/mcpMerge this template into ~/Library/Application Support/Claude/claude_desktop_config.json. Keep existing servers. Add any arguments, credentials, and permissions required by the maintainer; this template has not been install-tested.
{
"mcpServers": {
"io-github-castpdf-castpdf-mcp": {
"command": "npx",
"args": [
"-y",
"@castpdf/mcp"
]
}
}
}Restart Claude Desktop completely for changes to take effect. Confirm the server appears connected in the client’s tool list, then try a read-only example from its documentation.
Claude Desktop setup referenceCastPDF works with any MCP-compatible client. Copy the config snippet from the Configuration section above and add it to the file shown for your client, then restart the application.
~/Library/Application Support/Claude/claude_desktop_config.jsonRestart Claude Desktop completely for changes to take effect.~/.cursor/mcp.jsonRestart Cursor for changes to take effect..vscode/mcp.jsonReload VS Code window for changes to take effect.~/.codeium/windsurf/mcp_config.jsonRestart Windsurf for changes to take effect..mcp.jsonSave at the project root, then start Claude Code in that project and review the MCP server approval prompt. Keep real credentials out of shared files.