|
| 1 | +# Prompts |
| 2 | + |
| 3 | +MCP server includes support for pre-defined prompts that provide structured conversation templates. These |
| 4 | +prompts can serve as starting points for common tasks, code generation, or project-specific workflows. |
| 5 | + |
| 6 | +## How Prompts Work |
| 7 | + |
| 8 | +Prompts are defined in your configuration files and can include: |
| 9 | + |
| 10 | +- Template messages with variable placeholders |
| 11 | +- Input schemas for required and optional parameters |
| 12 | +- Descriptions for better discoverability |
| 13 | + |
| 14 | +When LLM requests a prompt, the MCP server returns the structured conversation template with any variable |
| 15 | +placeholders filled in based on the provided arguments. |
| 16 | + |
| 17 | +## Defining Prompts |
| 18 | + |
| 19 | +```yaml |
| 20 | +prompts: |
| 21 | + - id: generate-controller |
| 22 | + description: "Generate a controller for a specific entity" |
| 23 | + schema: |
| 24 | + properties: |
| 25 | + entityName: |
| 26 | + description: "Name of the entity (e.g. User, Product)" |
| 27 | + required: |
| 28 | + - entityName |
| 29 | + messages: |
| 30 | + - role: system |
| 31 | + content: "You are a PHP code generator specializing in Symfony controllers." |
| 32 | + - role: assistant |
| 33 | + content: "I'll help you generate a controller for your entity. Please provide the entity name." |
| 34 | + - role: user |
| 35 | + content: "Generate a controller for the {{entityName}} entity." |
| 36 | +``` |
| 37 | +
|
| 38 | +Each prompt contains: |
| 39 | +
|
| 40 | +- **id**: Unique identifier for the prompt |
| 41 | +- **description**: Human-readable description |
| 42 | +- **schema** (optional): Defines input parameters with descriptions and required fields |
| 43 | +- **messages**: The sequence of conversation messages that make up the prompt |
| 44 | +
|
| 45 | +## Variable Substitution |
| 46 | +
|
| 47 | +Prompts support variable substitution in message content using the format `{{variableName}}`. When LLM requests a |
| 48 | +prompt with arguments, the MCP server replaces these placeholders with the provided values. |
| 49 | + |
| 50 | +## Available Prompt Tools |
| 51 | + |
| 52 | +When connected via MCP, LLM has access to the following prompt-related tools: |
| 53 | + |
| 54 | +### Prompts Tools |
| 55 | + |
| 56 | +- `prompts.list`: List all available prompts defined in the configuration |
| 57 | +- `prompts.get`: Get a specific prompt by ID |
| 58 | + |
| 59 | +## Example Usage |
| 60 | + |
| 61 | +Here's how LLM might use prompts during a conversation: |
| 62 | + |
| 63 | +1. **Listing available prompts**: |
| 64 | + Claude can request a list of all available prompts to discover what templates are available. |
| 65 | + |
| 66 | +2. **Using a prompt with arguments**: |
| 67 | + Claude can request a specific prompt with arguments, which will return the prompt messages with variables |
| 68 | + substituted. |
| 69 | + |
| 70 | +3. **Custom workflows**: |
| 71 | + Prompts can be designed for specific workflows like code generation, documentation creation, or project analysis. |
| 72 | + |
| 73 | +## Shareable Prompts |
| 74 | + |
| 75 | +Prompts in Context Generator aren't just static templates - they're designed to be shared, imported, and reused across |
| 76 | +projects and teams. This creates an ecosystem where: |
| 77 | + |
| 78 | +- Teams can maintain consistent approaches to common development tasks |
| 79 | +- Best practices can be encoded once and shared widely |
| 80 | +- Specialized domain knowledge can be packaged into reusable templates |
| 81 | +- The community can collaborate on high-quality prompt libraries |
| 82 | + |
| 83 | +Context Generator currently supports basic configuration imports from local filesystem sources. |
| 84 | + |
| 85 | +**Coming soon**, we're extending this functionality to include remote sources, with a particular focus on making MCP |
| 86 | +prompts more accessible and shareable: |
| 87 | + |
| 88 | +### Upcoming Import Capabilities |
| 89 | + |
| 90 | +- **GitHub Repositories**: Import prompts directly from public or private GitHub repos |
| 91 | +- **Composer Packages**: Leverage prompts bundled in PHP Composer packages |
| 92 | +- **Remote URLs**: Reference prompt configurations via direct URLs |
| 93 | +- **Selective Imports**: Import only specific prompts from any source |
| 94 | + |
| 95 | +This will transform how teams work with AI by enabling: |
| 96 | + |
| 97 | +- **Reusability**: Create prompt repositories once, use them across multiple projects |
| 98 | +- **Community Sharing**: Participate in an ecosystem of community-maintained prompt libraries |
| 99 | +- **Standardization**: Promote best practices through shared prompt configurations |
| 100 | +- **Version Control**: Reference specific versions of remote prompt repositories |
| 101 | + |
| 102 | +### Example Remote Import Configuration |
| 103 | + |
| 104 | +```yaml |
| 105 | +import: |
| 106 | + # Local import (current implementation) |
| 107 | + - path: services/api/context.yaml |
| 108 | + type: local # default, can be omitted |
| 109 | +
|
| 110 | + # GitHub import (coming soon) |
| 111 | + - path: butschster/ctx-prompts/prompts/refactoring.yaml |
| 112 | + type: github |
| 113 | + ref: main # optional, defaults to main/master |
| 114 | + token: ${GITHUB_TOKEN} # optional, for private repos |
| 115 | +
|
| 116 | + # Composer package import (coming soon) |
| 117 | + - path: vendor/butschster/ctx-prompts/prompts/refactoring.yaml |
| 118 | + type: composer |
| 119 | +
|
| 120 | + # URL import (coming soon) |
| 121 | + - path: https://example.com/context-configs/api-prompts.yaml |
| 122 | + type: url |
| 123 | + headers: # optional HTTP headers |
| 124 | + Authorization: "Bearer ${API_TOKEN}" |
| 125 | +
|
| 126 | + # Selective import (coming soon, works with any source type) |
| 127 | + - path: butschster/ctx-prompts/prompts/all.yaml |
| 128 | + type: github |
| 129 | + docs: |
| 130 | + - refactoring/extract-method.md |
| 131 | + - refactoring/rename-class.md |
| 132 | +``` |
0 commit comments