To let an AI assistant generate real documents, give it the @docmake/mcp server: an npm package that exposes your DocMake templates over the Model Context Protocol. Install it with your API key in the environment, and Claude (or Cursor, or any MCP client) can list your templates, inspect the fields each one needs, and render a finished PDF or DOCX to a local folder.
The whole setup is one command or one JSON block, and nothing about your account changes. The server runs on your machine, over stdio, and talks only to the DocMake REST API over HTTPS with your key. It is MIT licensed and needs Node 18 or newer.
Install it
Claude Code, one command in your terminal:
claude mcp add docmake \
--env DOCMAKE_API_KEY=dm_your_api_key \
-- npx -y @docmake/mcp@latest
Claude Desktop, in Settings, Developer, Edit Config, then restart the app:
{
"mcpServers": {
"docmake": {
"command": "npx",
"args": ["-y", "@docmake/mcp@latest"],
"env": {
"DOCMAKE_API_KEY": "dm_your_api_key"
}
}
}
}
Cursor and other stdio MCP clients use the same block, in .cursor/mcp.json or the equivalent global settings file. The command never changes: run @docmake/mcp through npx with the key in the environment.
Get the key from the app under Settings, API Keys. It is shown once, is prefixed dm_, and the Free plan includes full API access, so you do not need a paid plan to try this.
Configure where files land
Three environment variables, only the first of which is required:
| Variable | Required | Default | Purpose |
|---|---|---|---|
DOCMAKE_API_KEY | yes | Your API key from Settings, API Keys | |
DOCMAKE_OUTPUT_DIR | no | ~/Downloads/DocMake | Where rendered documents are written |
DOCMAKE_API_BASE | no | https://app.docmake.io/api/v1 | API base URL |
Rendered files never overwrite an existing file: a name collision gets a numeric suffix. If you point DOCMAKE_OUTPUT_DIR at a project folder, the assistant can render straight into the repo or the working directory you are already in.
What the assistant can now do
Six tools, and the names matter because you will see them in the tool-call log:
| Tool | Inputs | What it does |
|---|---|---|
list_templates | search, page, per_page | Lists workspace templates with IDs and variable counts |
get_template | template_id, include_schema | The template’s field tree: every variable it expects |
render_document | template_id, data, format, filename, locale, page_size, strict | Renders and saves the file, returns the absolute path |
create_template | name, schema | Creates a template from a document schema JSON |
import_docx | file_path, name | Imports a local Word file as a new template |
get_usage | none | Plan, quota and rate limits for the billing period |
The server also publishes your templates as MCP resources under docmake://templates/... and ships a generate-document prompt for a guided flow, so a client with prompt support can walk a non-technical user through picking a template and filling it.
The conversation, in practice
You type something like:
Generate the invoice for Acme Corp: 12 hours of design at $150, one development sprint at $2,600, due in 30 days.
What the assistant actually does is three tool calls. list_templates with a search for “invoice” to find the ID. get_template to learn that this template wants invoice_number, client_name, issue_date, due_date, an items array with description, qty, unit_price and amount per row, plus total and payment_terms. Then render_document with the mapped payload.
The reply is a file path, the format, the size, and the render time. Open it and it is the same document the invoice template produces through the REST API, because it is the same engine and the same call underneath.
Why it does not hallucinate your fields
This is the part that makes MCP worth using over “ask the model to write a document”. The assistant is not inventing a layout. It is filling a template you designed, and the field contract is enforced by the API, not by the model’s good intentions.
render_document is strict by default. If any variable has no value and no declared default, the render fails and the error hands the assistant the exact list of missing keys, so it comes back and asks you for them instead of producing an invoice with an empty client name. Pass strict: false if you deliberately want fallback text instead.
Variables can also declare a default in the template editor. A defaulted variable never counts as missing: leave it out of the data and the default renders, even in strict mode. get_template shows each field’s default alongside its example, and the distinction matters: example is preview-only sample data that is never injected into a real render.
The result is that the failure mode of an AI-generated document is “the assistant asks you a question”, not “you email a customer a document with a blank where their name should be”.
Two defaults that differ from the REST API
If you use both surfaces, know these:
formatdefaults topdfin the MCP server, and todocxonPOST /api/v1/render.strictdefaults totruein the MCP server, and to false on the REST endpoint.
The MCP defaults are tuned for a conversation, where a PDF is usually what a person means by “the document” and where failing loudly is better than a silent blank. The REST defaults are the historical API behavior. Neither is going to surprise you if you pass both parameters explicitly, which is what we recommend in server code. See how to generate a PDF invoice from JSON with an API for the full REST parameter list.
Bringing your own documents in
import_docx takes an absolute path to a .docx file on your machine and turns it into a template with headings, tables, headers and footers intact. The server refuses anything that is not a .docx and anything over 10 MB before it uploads, so a mistake costs you nothing.
That makes a useful two-step: import the Word file your team has been editing by hand for years, open it once in the visual editor to mark the parts that change as fields, and from then on your assistant can fill it.
What it does not do
Being specific about the limits is more useful than a feature list:
- Variable definitions (types, required flags, defaults) are set in the visual editor, not through the API or MCP.
create_templatetakes a name and a document schema; the typed field contract comes from the editor. - The server has no access to anything on your machine except the output directory it writes to and the file you explicitly pass to
import_docx. - Renders count against the same quota as API renders: 1,000 documents a month on Free, 10,000 on Pro. Ask the assistant to call
get_usageif you want to know where you stand. - Long renders time out at three minutes. In practice a render is a few hundred milliseconds.
Next steps
Setup instructions for every client, the tool reference and an FAQ live on the MCP server page. If you would rather wire documents into your own product instead of your editor, the developers page has the REST equivalent of everything above.