MCP Server

The Model Context Protocol (MCP) server lets AI-enabled tools — like Cursor, Claude Desktop, and other MCP clients — interact with your PDF Generator workspace programmatically. You can list, create, update, and delete templates, variables, and files directly from your AI coding environment.

What Is MCP?

MCP is an open protocol that standardizes how AI applications communicate with external tools and data sources. PDF Generator exposes its template management capabilities as MCP tools, resources, and prompts — making your entire template workspace available to AI assistants.

Connecting an MCP Client

Prerequisites

  • An MCP client (Cursor, Claude Desktop, etc.)
  • Your MCP token (generate from Profile → MCP Settings)

Configuration

Add the PDF Generator MCP server to your client's configuration. The server runs at:

https://app.generator.rest/mcp

Cursor

Add to your Cursor MCP configuration:

{
  "mcpServers": {
    "pdf-generator": {
      "url": "https://app.generator.rest/mcp",
      "headers": {
        "Authorization": "Bearer YOUR_MCP_TOKEN"
      }
    }
  }
}

Claude Desktop

Add to your Claude Desktop configuration file (claude_desktop_config.json):

{
  "mcpServers": {
    "pdf-generator": {
      "command": "npx",
      "args": [
        "-y",
        "@anthropic/client-mcp-transport",
        "https://app.generator.rest/mcp",
        "--header",
        "Authorization: Bearer YOUR_MCP_TOKEN"
      ]
    }
  }
}

Authentication

Two authentication methods are supported simultaneously:

  • Bearer TokenAuthorization: Bearer YOUR_MCP_TOKEN header
  • Query ParameterPOST /mcp?mcpToken=YOUR_MCP_TOKEN

Generate your MCP token from Profile → MCP Settings.

Available Tools

ToolDescription
list_templatesList/search templates by name or type
get_templateGet single template metadata
create_templateCreate a new template (name required; defaults: type=simple, renderer=itext)
update_templateUpdate template metadata
list_template_variablesList variables, optionally filter by template
create_template_variableCreate a new variable
update_template_variableUpdate a variable
delete_template_variableDelete a variable
list_template_filesList files for a template
get_template_fileGet HTML content of a file
save_template_fileSave HTML content (emits SSE event for preview refresh)

Resources

Resources provide structured access to your data. MCP clients can read resources using the mcp:// URI scheme:

Resource URIDescription
mcp://templatesList all templates
mcp://templates/{id}Get a specific template
mcp://templates/{id}/filesList files for a template
mcp://templates/{id}/files/{name}Get a specific file's content
mcp://template-variablesList all variables
mcp://template-variables/{id}Get a specific variable

Prompts

Prompts are pre-built templates that help AI assistants generate HTML content and suggest variable structures:

PromptPurpose
generate_html_templateStructured prompt for generating HTML template content
suggest_template_variablesPrompt for suggesting relevant variables based on template content
improve_html_stylingPrompt for improving CSS styling in existing templates

Use prompts by invoking them through your MCP client — they return structured LLM instructions that guide the AI in creating better templates.

SSE Notifications

The MCP server supports Server-Sent Events (SSE) for real-time notifications. When you save a template file, the server broadcasts a template-saved event. MCP clients subscribed to the SSE stream receive these notifications and can trigger automatic refreshes.

  • POST /mcp — All MCP operations (initialize, list tools, call tool, etc.)
  • GET /mcp — SSE stream for server notifications
  • DELETE /mcp — Session termination

Example: Creating a Template via MCP

Here's an example of what an AI assistant can do through the MCP server when you ask "Create an invoice template with common variables":

  1. Calls create_template with { name: "Invoice", type: "full", pageSize: "A4" }
  2. Calls create_template_variable for each needed variable (invoiceNumber, customerName, lineItems, etc.)
  3. Calls save_template_file to write the HTML body with proper variable placeholders
  4. Calls save_template_file for header and footer content

All through natural language — no API calls to write manually.

Next Steps