A Model Control Protocol (MCP) server for managing and serving dynamic prompt templates using elegant and powerful text template engine. Create reusable, logic-driven prompts with variables, partials, and conditionals that can be served to any compatible MCP client like Claude Code, Claude Desktop, Gemini CLI, VSCode with Copilot, etc. - MCP Compatible: Works out-of-the-box with any MCP client tha
Add this skill
npx mdskills install vasayxtx/mcp-prompt-engineComprehensive MCP server for dynamic prompt templating with Go templates, excellent docs and hot-reload
1# MCP Prompt Engine23[](https://goreportcard.com/report/github.com/vasayxtx/mcp-prompt-engine)4[](https://github.com/vasayxtx/mcp-prompt-engine/releases)5[](https://opensource.org/licenses/MIT)6[](https://pkg.go.dev/github.com/vasayxtx/mcp-prompt-engine)78A Model Control Protocol (MCP) server for managing and serving dynamic prompt templates using elegant and powerful text template engine.9Create reusable, logic-driven prompts with variables, partials, and conditionals that can be served to any [compatible MCP client](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/docs/clients.mdx) like Claude Code, Claude Desktop, Gemini CLI, VSCode with Copilot, etc.1011## Key Features1213- **MCP Compatible**: Works out-of-the-box with any [MCP client](https://github.com/modelcontextprotocol/modelcontextprotocol/blob/main/docs/clients.mdx) that supports [prompts](https://modelcontextprotocol.io/docs/concepts/prompts).14- **Powerful Go Templates**: Utilizes the full power of Go [text/template](https://pkg.go.dev/text/template) syntax, including variables, conditionals, loops, and more.15- **Reusable Partials**: Define common components in partial templates (e.g., `_header.tmpl`) and reuse them across your prompts.16- **Prompt Arguments**: All template variables are automatically exposed as MCP prompt arguments, allowing dynamic input from clients.17- **Hot-Reload**: Automatically detects changes to your prompt files and reloads them without restarting the server.18- **Rich CLI**: A modern command-line interface to list, validate, and render templates for easy development and testing.19- **Smart Argument Handling**:20 - Automatically parses JSON arguments (booleans, numbers, arrays, objects).21 - Injects environment variables as fallbacks for template arguments.22- **Containerized**: Full Docker support for easy deployment and integration.2324## Getting Started2526### 1. Installation2728Install using Go:29```bash30go install github.com/vasayxtx/mcp-prompt-engine@latest31```32(For other methods like Docker or pre-built binaries, see the [Installation section](#installation) below.)3334### 2. Create a Prompt3536Create a `prompts` directory and add a template file. Let's create a prompt to help write a Git commit message.3738First, create a reusable partial named `prompts/_git_commit_role.tmpl`:3940 ```go41 {{ define "_git_commit_role" }}42 You are an expert programmer specializing in writing clear, concise, and conventional Git commit messages.43 Commit message must strictly follow the Conventional Commits specification.4445 The final commit message you generate must be formatted exactly as follows:4647 ```48 <type>: A brief, imperative-tense summary of changes4950 [Optional longer description, explaining the "why" of the change. Use dash points for clarity.]51 ```52 {{ if .type -}}53 Use {{.type}} as a type.54 {{ end }}55 {{ end }}56 ```5758Now, create a main prompt `prompts/git_stage_commit.tmpl` that uses this partial:59 ```go60 {{- /* Commit currently staged changes */ -}}6162 {{- template "_git_commit_role" . -}}6364 Your task is to commit all currently staged changes.65 To understand the context, analyze the staged code using the command: `git diff --staged`66 Based on that analysis, commit staged changes using a suitable commit message.67 ```6869### 3. Validate Your Prompt7071Validate your prompt to ensure it has no syntax errors:72```bash73mcp-prompt-engine validate git_stage_commit74✓ git_stage_commit.tmpl - Valid75```7677### 4. Connect MCP Server to Your Client7879Add MCP Server to your MCP client. See [Connecting to Clients](#connecting-to-clients) for configuration examples.8081### 5. Use Your Prompt8283Your `git_stage_commit` prompt will now be available in your client!8485For example, in Claude Desktop, you can select the `git_stage_commit` prompt, provide the `type` MCP Prompt argument and get a generated prompt that will help you to do a commit with a perfect message.8687In Claude Code or Gemini CLI, you can start typing `/git_stage_commit` and it will suggest the prompt with the provided arguments that will be executed after you select it.8889---9091## Installation9293### Pre-built Binaries9495Download the latest release for your OS from the [GitHub Releases page](https://github.com/vasayxtx/mcp-prompt-engine/releases).9697### Build from Source9899```bash100git clone https://github.com/vasayxtx/mcp-prompt-engine.git101cd mcp-prompt-engine102make build103```104105### Docker106107A pre-built Docker image is available. Mount your local `prompts` and `logs` directories to the container.108109```bash110# Pull and run the pre-built image from GHCR111docker run -i --rm \112 -v /path/to/your/prompts:/app/prompts:ro \113 -v /path/to/your/logs:/app/logs \114 ghcr.io/vasayxtx/mcp-prompt-engine115```116117You can also build the image locally with `make docker-build`.118119---120121## Usage122123### Creating Prompt Templates124125Create a directory to store your prompt templates. Each template should be a `.tmpl` file using Go's [text/template](https://pkg.go.dev/text/template) syntax with the following format:126127```go128{{/* Brief description of the prompt */}}129Your prompt text here with {{.template_variable}} placeholders.130```131132The first line comment (`{{/* description */}}`) is used as the prompt description, and the rest of the file is the prompt template.133134Partial templates should be prefixed with an underscore (e.g., `_header.tmpl`) and can be included in other templates using `{{template "partial_name" .}}`.135136### Template Syntax137138The server uses Go's `text/template` engine, which provides powerful templating capabilities:139140- **Variables**: `{{.variable_name}}` - Access template variables141- **Built-in variables**:142 - `{{.date}}` - Current date and time143- **Conditionals**: `{{if .condition}}...{{end}}`, `{{if .condition}}...{{else}}...{{end}}`144- **Logical operators**: `{{if and .condition1 .condition2}}...{{end}}`, `{{if or .condition1 .condition2}}...{{end}}`145- **Loops**: `{{range .items}}...{{end}}`146- **Template inclusion**: `{{template "partial_name" .}}` or `{{template "partial_name" dict "key" "value"}}`147148See the [Go text/template documentation](https://pkg.go.dev/text/template) for more details on syntax and features.149150### JSON Argument Parsing151152The server automatically parses argument values as JSON when possible, enabling rich data types in templates:153154- **Booleans**: `true`, `false` → Go boolean values155- **Numbers**: `42`, `3.14` → Go numeric values156- **Arrays**: `["item1", "item2"]` → Go slices for use with `{{range}}`157- **Objects**: `{"key": "value"}` → Go maps for structured data158- **Strings**: Invalid JSON falls back to string values159160This allows for advanced template operations like:161```go162{{range .items}}Item: {{.}}{{end}}163{{if .enabled}}Feature is enabled{{end}}164{{.config.timeout}} seconds165```166167To disable JSON parsing and treat all arguments as strings, use the `--disable-json-args` flag for the `serve` and `render` commands.168169### CLI Commands170171The CLI is your main tool for managing and testing templates.172By default, it looks for templates in the `./prompts` directory, but you can specify a different directory with the `--prompts` flag.173174**1. List Templates**175```bash176# See a simple list of available prompts177mcp-prompt-engine list178179# See a detailed view with descriptions and variables180mcp-prompt-engine list --verbose181```182183**2. Render a Template**184185Render a prompt directly in your terminal, providing arguments with the `-a` or `--arg` flag.186It will automatically inject environment variables as fallbacks for any missing arguments. For example, if you have an environment variable `TYPE=fix`, it will be injected into the template as `{{.type}}`.187188```bash189# Render the git commit prompt, providing the 'type' variable190mcp-prompt-engine render git_stage_commit --arg type=feat191```192193**3. Validate Templates**194195Check all your templates for syntax errors. The command will return an error if any template is invalid.196```bash197# Validate all templates in the directory198mcp-prompt-engine validate199200# Validate a single template201mcp-prompt-engine validate git_stage_commit202```203204**4. Start the Server**205206Run the MCP server to make your prompts available to clients.207```bash208# Run with default settings (looks for ./prompts)209mcp-prompt-engine serve210211# Specify a different prompts directory and a log file212mcp-prompt-engine --prompts /path/to/prompts serve --log-file ./server.log213```214215---216217## Connecting to Clients218219To use this engine with any client that supports MCP Prompts, add a new entry to its MCP servers configuration.220221Global configuration locations (MacOS):222- Claude Code: `~/.claude.json` (`mcpServers` section)223- Claude Desktop: `~/Library/Application\ Support/Claude/claude_desktop_config.json` (`mcpServers` section)224- Gemini CLI: `~/.gemini/settings.json` (`mcpServers` section)225226**Example for a local binary:**227```json228{229 "prompts": {230 "command": "/path/to/your/mcp-prompt-engine",231 "args": [232 "--prompts", "/path/to/your/prompts",233 "serve",234 "--quiet"235 ]236 }237}238```239240**Example for Docker:**241```json242{243 "mcp-prompt-engine-docker": {244 "command": "docker",245 "args": [246 "run", "-i", "--rm",247 "-v", "/path/to/your/prompts:/app/prompts:ro",248 "-v", "/path/to/your/logs:/app/logs",249 "ghcr.io/vasayxtx/mcp-prompt-engine"250 ]251 }252}253```254255## License256257This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.258
Full transparency — inspect the skill content before installing.