- Home
- MCP servers
- Docxtpl
Docxtpl
- python
1
GitHub Stars
python
Language
6 months ago
First Indexed
2 months ago
Catalog Refreshed
Documentation & install
Readme and setup notes from the catalogue, plus a client-ready config you can copy for your MCP host.
Installation
Add the following to your MCP client configuration file.
Configuration
View docs{
"mcpServers": {
"z1w2r3-doc-mcp": {
"command": "npx",
"args": [
"docxtpl-mcp@latest"
],
"env": {
"DEBUG": "false",
"OUTPUT_DIR": "output",
"TEMPLATE_DIR": "templates",
"MAX_FILE_SIZE_MB": "50"
}
}
}
}This Word document generation server uses the MCP standard to interact with AI models and a powerful template engine to produce customized documents. It integrates with popular template formats and supports dynamic content, making it easy to generate invoices, reports, contracts, and letters from structured data.
How to use
You interact with the server through an MCP client. Start by choosing a template you want to fill and provide the data that template requires. The server will render a final Word document (.docx) according to your template and data, then save or return the output for further use.
Typical workflows include listing available templates, validating a template to see which variables it expects, previewing a template with sample data, and generating documents from real data. Use your MCP client to request these capabilities, and the server will respond with the generated document or structured results.
Key actions you can perform include: list templates, validate a template to expose required variables, generate a document from a named template and a context object, and preview a template with sample data. You can also parse existing documents to extract structured content and metadata for reuse.
How to install
Prerequisites you need to install and run this server successfully are: Node.js 14.0+ and npm for running MCP clients that rely on npx, and Python 3.10+ for running the server backend.
Option 1. Install via Claude Code (recommended) and register this MCP server with Claude:
claude mcp add docxtpl npx docxtpl-mcp@latest
Option 2. Run directly with npx (no installation required):
# Run without installing
npx docxtpl-mcp@latest
Option 3. Global installation and execution:
Global installation
npm install -g docxtpl-mcp
Run
docxtpl-mcp
Option 4. Configure Claude Desktop to run the server via MCP:
{
"mcpServers": {
"docxtpl": {
"command": "npx",
"args": ["docxtpl-mcp@latest"]
}
}
}
If you prefer running the server from source, you can start it with Python (from the source directory):
python -m src.server
Configuration and environment
Configure runtime options and paths using environment variables. Create a local environment file by copying the example and adjusting values:
cp .env.example .env
Possible environment variables include:
- TEMPLATE_DIR: the directory containing your template files (default: templates)
- OUTPUT_DIR: the directory where generated documents are saved (default: output)
- MAX_FILE_SIZE_MB: maximum allowed file size in megabytes (default: 50)
- DEBUG: enable verbose debugging logs (default: false)
Claude Desktop configuration details
On macOS/Linux, the configuration file is at ~/.claude/config.json. On Windows, it is at %APPDATA%\Claude\config.json. You can add the same MCP server configuration inside this file to enable quick launches.
Using npm package (recommended for running via MCP):
{ "mcpServers": { "docxtpl": { "command": "npx", "args": ["docxtpl-mcp@latest"] } } }
Alternatively, you can run directly from source with Python and set startup options and environment values:
{
"mcpServers": {
"docxtpl": {
"command": "python",
"args": ["-m", "src.server"],
"cwd": "/path/to/docxtpl-mcp",
"env": {
"TEMPLATE_DIR": "templates",
"OUTPUT_DIR": "output"
}
}
}
}
Usage tools and capabilities
The server exposes a set of tools to manage templates and documents. You can:
- generate_document to create a Word document from a template and data
- list_templates to see available templates
- validate_template to verify a template and extract required variables
- preview_template to render a template with sample data
- delete_document to remove a generated document
- list_documents to view all generated documents
- parse_docx_document, parse_pdf_document, parse_excel_document, parse_ppt_document to extract structured content from existing files
- extract_text_from_document to pull plain text from documents
- get_document_metadata to retrieve document metadata These tools enable end-to-end document generation and content extraction workflows with MCP clients.
Troubleshooting and notes
If you encounter issues with missing templates or content formatting, verify that the template files are located under the configured templates directory and have the correct .docx extension. Use validate_template to confirm required variables are present in a template.
For large documents or strict size limits, adjust the MAX_FILE_SIZE_MB setting in the environment to accommodate bigger outputs or to enforce tighter limits.
If you need to test locally, you can link the npm package and run a quick test with npx to verify the MCP server workflow end-to-end.
开发与贡献
Contributions are welcome. Follow standard practices for forking, feature branches, and pull requests.
Available tools
generate_document
Create a Word document from a named template using provided data context and optional output name.
list_templates
List all available .docx templates and their metadata.
validate_template
Check a template's syntax and extract required variables for rendering.
preview_template
Render a template with sample data to preview the output without saving.
delete_document
Remove a previously generated document by its ID.
list_documents
Show all documents generated by the server.
parse_docx_document
Parse a DOCX file and extract structured content including text and optional tables.
parse_pdf_document
Parse a PDF file to extract structured content, text, and optional tables.
extract_text_from_document
Extract plain text from documents for quick indexing or search.
get_document_metadata
Retrieve metadata such as author, title, and creation date for a document.
parse_excel_document
Parse an Excel file and extract sheet data, formulas, and cell content.
parse_ppt_document
Parse a PowerPoint file to extract slide content, tables, and images.