Skip to content

Using Claude Code to Create Templates

You can integrate the MCP server with Claude Code, so that your agent can access your Papermill account. It can generate documents, create and update templates, and learn about the Press document language.

This is a minimal quickstart and a few tips on using Claude. For a more detailed deep-dive, check out this blog article.

Setup

Papermill API Key

Set the $PAPERMILL_API_KEY environmental variable in your shell if you haven't already:

export PAPERMILL_API_KEY="your-actual-key-here"

You can create a new API Key from your Papermill settings.

Add MCP to Claude:

claude mcp add papermill https://mcp.papermill.io --transport http --scope user --header 'x-api-key: ${PAPERMILL_API_KEY}'

Verify the install:

claude mcp list
claude mcp get papermill

Getting the most from Claude Code

Like pretty much all things AI-based, working with Claude and Papermill works best if you follow a few patterns.

Use Auto Mode

If you value convenience over security, consider using Auto Mode - Warning! This may have serious security consequences and we always recommend running Claude Code within an isolated environment, such as a Docker Container.

Start from an Example PDF

If you have an existing document - such as from an existing system or a design file - you can provide this to Claude and ask it to replicate using Papermill. This tends to work reasonably well for the documents we've tried, and gets you about 80% of the way there.

Please recreate the attached PDF as a Papermill template.

Please ensure you parameterise the template, using a JSON <data> tag in Press, and flows for the main text sections.

Start with a Payload

Alternatively, or in tandem, you can begin with the payload. Provide a JSON object to Claude and say "I want to visualise this data" and let it design a template around that. Or provide the payload to help with parameterisation of a design inferred from an example PDF.

Ask Claude to look for Inspiration

Something we've found useful is to ask Claude to go look around the web for inspiration. It might find certain types of colour palettes are associated with a given industry, for example.

Update the template with a design refresh. Look up good practice in typesetting for the creation of scientific briefings, and also use the NASA website for inspiration.

Point Claude at your Website

Your own website is usually the easiest resource to get Claude started:

markdown
Please visit https://papermill.io and use the website to infer brand guidelines, such as fonts, colour schemes, and imagery. Apply those to
the template.

Ask Claude to use SVGs

Papermill supports both inline and file SVGs. You can ask Claude to generate SVGs to add some visual flair to the template. Claude is pretty good at generating SVGs, so it's always fun to try.

Do quick tweaks in the editor

Rather than ask Claude to change headings to blue, it can be quicker to dive into the template editor via the URL given by Claude. You can then make minor edits more quickly than waiting for Claude to overthink things.

Just be careful to ask Claude to re-retrieve the remote template if it's using a local working copy.

I've updated the template in Papermill - please grab the latest copy so we can continue to collaborate on it.