Your AI coding agent can read your repo, run your tests, and refactor a module. But ask it to "add a PDF invoice to this app" and it does what you'd do: reaches for Puppeteer, writes code that won't deploy, and hands you a layout it can't actually see or test.

The Model Context Protocol fixes that by giving the agent a real tool to call. Install the Leafwright MCP server and your agent can render PDFs, manage templates, and debug failures from logs — directly, while it works.

Install

Connect to the hosted server and sign in with OAuth:

# Claude Code
claude mcp add --transport http leafwright https://leafwright.co/mcp
# Then run /mcp inside Claude Code to authenticate.

# Codex
codex mcp add leafwright --url https://leafwright.co/mcp
codex mcp login leafwright

Claude Code can also install the PDF commands and skill from the public GitHub marketplace:

/plugin marketplace add Tactic-Systems/leafwright-claude-plugin
/plugin install leafwright@leafwright

Run /mcp to authenticate after installing. The Claude and OpenAI directory submissions are awaiting approval (last checked October 10, 2026); these direct installation options are available while review is pending.

For local stdio, Node.js and npm are required. Claude Code’s project .mcp.json and Cursor’s ~/.cursor/mcp.json use this configuration:

{
  "mcpServers": {
    "leafwright": {
      "command": "npx",
      "args": ["-y", "@leafwright/mcp"]
    }
  }
}

Codex uses TOML in ~/.codex/config.toml instead:

[mcp_servers.leafwright]
command = "npx"
args = ["-y", "@leafwright/mcp"]

Restart the client, call leafwright_login, approve browser access, then call leafwright_auth_status. A project API key is an alternative for automation. See the MCP setup guide for ChatGPT custom MCP, Claude custom connectors, and one-click Cursor installation.

What the agent can now do

The server exposes the Leafwright API as tools the agent can call on its own:

  • Generate a PDF from HTML or a URL
  • Render a template with JSON data
  • Create and update templates (drafts only — humans still publish)
  • Read render jobs and logs to see exactly why a render failed
  • Estimate usage cost before running a batch

So a prompt like "generate a PDF invoice for order #1024 and give me the link" becomes a tool call that returns a real, signed URL — not a code suggestion you have to wire up and deploy yourself.

The part that actually matters: it can debug its own output

A code-only agent is flying blind on layout. It writes print CSS, can't see the result, and guesses. With Leafwright it doesn't have to:

  1. Agent renders the template → the render fails or looks wrong.
  2. Agent calls get render logs → reads the real failure: a font that 404'd, an asset that timed out, a CSS rule that overflowed the page.
  3. Agent calls fix-from-logs → gets a corrected template, re-renders, confirms it's clean.

That's a closed feedback loop. The agent fixes the document the same way it fixes code — by reading the error and trying again — instead of handing you something broken.

Safe by design

The MCP server only calls the public Leafwright API. It runs no shell commands from agent input, supports a read-only mode, and uses scoped authentication. AI drafts and revises templates; publishing always requires a human. You get the speed of an agent without handing it a footgun.

Try it

If your agent already lives in your editor, this is the fastest way to give it a capability it's missing:

npx -y @leafwright/mcp

→ Get an API key — free, 100 PDFs/month · MCP setup docs