jinja2
Jinja2 3.1.*版本的模板转换功能的mcp服务,便于在AI 工作流或Agent中接入实现自动化的模板转换
claude mcp add --transport stdio ww-ai-lab-jinja2-mcp-server python run_server.py --transport stdio
How to use
This MCP server provides a Jinja2-based template rendering service exposed via the MCP protocol. It supports rendering templates with complex JSON data, file-based templates, and safe sandboxed execution to prevent misuse. The server implements dual transport modes: standard input/output (stdio) for direct integration with MCP clients, and HTTP-like streamable transport for debugging or testing scenarios. Core tools include render_template for in-memory template rendering, render_template_file for rendering using template files, validate_template to check syntax and usage, list_filters to enumerate Jinja2 filters, and get_template_info to analyze templates and performance characteristics. You can connect clients (such as AI models or automation bots) that supply a template and variables, and receive the rendered output or structured validation results.
How to install
Prerequisites:
- Python 3.8+ (recommended 3.12+)
- Git
-
Clone the repository git clone https://github.com/WW-AI-Lab/jinja2-mcp-server.git cd jinja2-mcp-server
-
Create and activate a virtual environment python -m venv .venv
Linux/macOS
source .venv/bin/activate
Windows
.venv\Scripts\activate
-
Install dependencies pip install -r requirements.txt
-
Run the server (stdio transport for MCP clients) python run_server.py --transport stdio
-
(Optional) Run HTTP/streamable transport for debugging python run_server.py --transport streamable-http --port 8123
Additional notes
Notes and tips:
- The server uses a sandboxed environment for template execution and enforces execution timeout and loop limits to prevent resource abuse.
- You can configure the server further via the JSON configuration options described in the docs (jinja, security, logging, etc.).
- If you plan to expose an HTTP transport, ensure proper security measures are in place (authentication, TLS in production).
- Environment variables like JINJA_AUTOESCAPE, SECURITY_MAX_LOOP_ITERATIONS, and LOGGING_LEVEL can influence behavior; refer to the documentation for recommended values.
- When testing with MCP Inspector, start the HTTP transport and connect to http://localhost:8123 to visualize requests and responses.
Related MCP Servers
mcp-vegalite
MCP server from isaacwasserman/mcp-vegalite-server
github-chat
A Model Context Protocol (MCP) for analyzing and querying GitHub repositories using the GitHub Chat API.
nautex
MCP server for guiding Coding Agents via end-to-end requirements to implementation plan pipeline
pagerduty
PagerDuty's official local MCP (Model Context Protocol) server which provides tools to interact with your PagerDuty account directly from your MCP-enabled client.
futu-stock
mcp server for futuniuniu stock
mcp -boilerplate
Boilerplate using one of the 'better' ways to build MCP Servers. Written using FastMCP