mcp prompts
Enables creation, management, and templating of prompts through a simplified SOLID architecture, allowing users to organize prompts by category and fill in templates at runtime.
Enables creation, management, and templating of prompts through a simplified SOLID architecture, allowing users to organize prompts by category and fill in templates at runtime.
An MCP server for managing prompts and templates with project orchestration capabilities. Part of the Model Context Protocol ecosystem.
This server provides a simple way to store, retrieve, and apply templates for AI prompts, making it easier to maintain consistent prompting patterns across your AI applications.
npx -y @sparesparrow/mcp-prompts
npm install -g @sparesparrow/mcp-prompts
docker run -p 3003:3003 -v ~/mcp/data:/app/data sparesparrow/mcp-prompts:latest
After installation, you can verify that the server is working by:
use_mcp_tool({
server_name: "prompt-manager",
tool_name: "list_prompts",
arguments: {}
});
The server can be configured using environment variables:
Environment Variable | Description | Default |
---|---|---|
SERVER_NAME | Server name | MCP Prompts Server |
SERVER_VERSION | Server version | package.json version |
STORAGE_TYPE | Storage type: 'file', 'postgres', or 'mdc' | file |
PROMPTS_DIR | Directory for storing prompts | ~/mcp/data/prompts |
BACKUPS_DIR | Directory for backups | ~/mcp/data/backups |
PORT | Port for HTTP server | 3003 |
LOG_LEVEL | Logging level | info |
HTTP_SERVER | Enable HTTP server | false |
HOST | Host for HTTP server | 0.0.0.0 |
Environment Variable | Description | Default |
---|---|---|
PG_HOST | PostgreSQL host | localhost |
PG_PORT | PostgreSQL port | 5432 |
PG_DATABASE | PostgreSQL database name | mcp_prompts |
PG_USER | PostgreSQL username | postgres |
PG_PASSWORD | PostgreSQL password | |
PG_SSL | Use SSL for PostgreSQL connection | false |
POSTGRES_CONNECTION_STRING | Full PostgreSQL connection string (overrides individual settings) |
Environment Variable | Description | Default |
---|---|---|
MDC_RULES_DIR | Directory for MDC rules | ./.cursor/rules |
In Claude 3 Desktop app, you can configure the MCP Prompts server in your claude_desktop_config.json
:
{
"mcpServers": {
"prompts": {
"command": "npx",
"args": [
"-y",
"@sparesparrow/mcp-prompts"
],
"env": {
"STORAGE_TYPE": "file",
"PROMPTS_DIR": "/path/to/your/prompts/directory",
"LOG_LEVEL": "debug"
}
}
}
}
The MCP Prompts server provides the following tools:
add_prompt
: Add a new promptget_prompt
: Get a prompt by IDupdate_prompt
: Update an existing promptlist_prompts
: List all promptsdelete_prompt
: Delete a prompt by IDapply_template
: Apply variables to a prompt templateTo see what prompts are available:
use_mcp_tool({
server_name: "prompt-manager",
tool_name: "list_prompts",
arguments: {}
});
To filter by tags:
use_mcp_tool({
server_name: "prompt-manager",
tool_name: "list_prompts",
arguments: {
tags: ["development"]
}
});
To retrieve a specific prompt by ID:
use_mcp_tool({
server_name: "prompt-manager",
tool_name: "get_prompt",
arguments: {
id: "development-workflow"
}
});
To apply variables to a template prompt:
use_mcp_tool({
server_name: "prompt-manager",
tool_name: "apply_template",
arguments: {
id: "development-system-prompt",
variables: {
"project_type": "web frontend",
"language": "JavaScript/React",
"project_name": "TaskManager",
"project_goal": "create a task management application with drag-and-drop functionality",
"technical_context": "Using React 18, TypeScript, and Material UI"
}
}
});
To add a new prompt:
use_mcp_tool({
server_name: "prompt-manager",
tool_name: "add_prompt",
arguments: {
name: "Bug Report Template",
description: "Template for submitting bug reports",
content: "## Bug Report
### Description
{{description}}
### Steps to Reproduce
{{steps}}
### Expected Behavior
{{expected}}
### Actual Behavior
{{actual}}
### Environment
{{environment}}",
isTemplate: true,
variables: ["description", "steps", "expected", "actual", "environment"],
tags: ["bug", "template", "documentation"]
}
});
To edit an existing prompt:
use_mcp_tool({
server_name: "prompt-manager",
tool_name: "edit_prompt",
arguments: {
id: "development-workflow",
content: "Updated workflow content here...",
tags: ["development", "workflow", "python", "updated"]
}
});
When starting work on a new feature:
When reviewing code:
A prompt has the following structure:
{
"id": "unique-id",
"name": "Prompt Name",
"description": "Optional description",
"content": "The prompt content with {{variables}}",
"tags": ["tag1", "tag2"],
"isTemplate": true,
"variables": ["variable1", "variable2"],
"metadata": {
"author": "Your Name",
"version": "1.0.0"
}
}
The MCP Prompts Server includes a powerful MutablePrompt
interface that allows prompts to be converted between multiple formats:
The MutablePrompt interface provides methods to convert prompts between these formats:
// Create a mutable prompt
const factory = new MutablePromptFactoryImpl();
const prompt = factory.create({
name: "API Design Guide",
description: "Template for designing RESTful APIs",
content: "# API Design for {{service_name}}
## Endpoints
{{endpoints}}
## Authentication
{{auth_method}}",
isTemplate: true,
variables: ["service_name", "endpoints", "auth_method"],
tags: ["api", "design", "rest", "glob:*.md"]
});
// Convert to MDC format
const mdcContent = prompt.toMdc({
includeVariables: true
});
// Convert to PGAI format with embeddings
const pgaiData = prompt.toPgai({
generateEmbeddings: true,
collection: "prompts",
vectorConfig: {
dimension: 1536,
metric: "cosine"
}
});
// Convert to template format with dollar-style variables
const templateContent = prompt.toTemplate({
delimiterStyle: "dollar"
});
You can easily apply variables to template prompts:
const result = prompt.applyVariables({
service_name: "User Management API",
endpoints: "GET /users, POST /users, GET /users/{id}, PUT /users/{id}, DELETE /users/{id}",
auth_method: "JWT Bearer Token"
});
Extract variables from template content:
const variables = prompt.extractVariables();
// Returns ["service_name", "endpoints", "auth_method"]
You can also create prompts from various formats:
// From MDC format
const mdcContent = `---
description: Template for code reviews
globs: ["*.js", "*.ts"]
---
# Code Review Template
## Context
{{context}}
## Patterns
{{patterns}}
## Variables
- `context`: Description of the code being reviewed
- `patterns`: Common patterns to look for
`;
const promptFromMdc = factory.fromMdc(mdcContent);
// From PGAI format
const pgaiData = {
id: "api-design",
name: "API Design Guide",
content: "# API Design Guide
Use this guide...",
metadata: {
description: "Comprehensive API design guide",
tags: ["api", "rest"],
isTemplate: false
}
};
const promptFromPgai = factory.fromPgai(pgaiData);
The MutablePrompt interface works seamlessly with the existing storage adapters:
// Save a prompt in MDC format
const mdcPrompt = factory.fromMdc(mdcContent);
await fileAdapter.savePrompt(mdcPrompt);
// Save a prompt to PostgreSQL with PGAI format
const pgaiPrompt = factory.fromPgai(pgaiData);
await postgresAdapter.savePrompt(pgaiPrompt);
This flexible format handling enables:
The server supports three types of storage adapters:
Storage types can be configured using the STORAGE_TYPE
environment variable:
STORAGE_TYPE=file # Default
STORAGE_TYPE=postgres # Requires PostgreSQL configuration
STORAGE_TYPE=mdc # For Cursor Rules format
When using PostgreSQL storage, configure the following environment variables:
PG_HOST=localhost
PG_PORT=5432
PG_DATABASE=mcp_prompts
PG_USER=postgres
PG_PASSWORD=your_password
PG_SSL=false
Alternatively, use a connection string:
POSTGRES_CONNECTION_STRING=postgresql://user:password@host:port/database
The MCP Prompts Server offers various Docker Compose configurations for different deployment scenarios:
docker compose up -d
This will deploy the MCP Prompts server using file storage on port 3003.
docker compose -f docker-compose.postgres.yml up -d
This deploys:
- A PostgreSQL database server
- The MCP Prompts server configured for PostgreSQL
- Adminer for database management at http://localhost:8080
docker compose -f docker-compose.dev.yml up -d
This sets up a development environment with hot reloading. It mounts the source code from your local directory and includes Adminer.
docker compose -f docker-compose.test.yml up --build
This creates a dedicated testing environment with:
- A temporary PostgreSQL instance with test data
- An isolated test runner container that executes all tests
- Test results saved to the ./test-results directory
To simplify Docker Compose operations, use the provided management script:
# Start development environment
./scripts/docker-manage.sh start dev
# Run tests in Docker
./scripts/docker-manage.sh test
# View logs from production environment
./scripts/docker-manage.sh logs prod
# Clean up test environment
./scripts/docker-manage.sh clean test
# Show help
./scripts/docker-manage.sh help
The management script supports the following commands:
- start
: Start Docker containers
- stop
: Stop Docker containers
- restart
: Restart Docker containers
- logs
: Show logs from containers
- clean
: Remove containers, networks, and volumes
- build
: Build Docker images
- test
: Run tests in Docker containers
And the following environments:
- dev
: Development environment (default)
- test
: Testing environment
- prod
: Production environment
You can create your own custom Docker Compose configuration by extending the base configurations:
# custom-compose.yml
version: '3.8'
include:
- docker-compose.yml
services:
mcp-prompts:
environment:
- CUSTOM_ENV=value
Then run it with:
docker compose -f custom-compose.yml up -d
Clone the repository
git clone https://github.com/user/mcp-prompt-manager.git
cd mcp-prompt-manager
Install dependencies
npm install
Set up environment variables
Create a .env
file with the necessary configuration.
Start development server with hot reloading
npm run dev
Build the project
npm run build
Run unit tests
npm test
Run integration tests
npm run test:integration
Test build process
npm run test:build
Test Docker build
npm run test:docker
Build Docker image
npm run docker:build
The build process includes several important steps:
TypeScript Compilation
npm run build
Make Entry Point Executable
chmod +x dist/index.js
Run the tests:
npm test
Run the MCP Inspector for testing:
npm run test:inspector
For more advanced testing options, use the provided test script:
# Run all tests (unit and integration)
./scripts/run-tests.sh
# Run only unit tests
./scripts/run-tests.sh --unit
# Run only integration tests
./scripts/run-tests.sh --integration
# Generate test coverage report
./scripts/run-tests.sh --coverage
# Run tests in Docker
./scripts/run-tests.sh --docker
# Clean up Docker resources after testing
./scripts/run-tests.sh --docker --clean
To test the health of Docker containers:
# Run the Docker health check tests
TEST_DOCKER_HEALTH=true npm test -- tests/integration/docker-health.integration.test.ts
This test verifies that the health check endpoint is working correctly when the MCP-Prompts server is running in a Docker container.
The project follows a structured organization to maintain clean separation of concerns:
mcp-prompt-manager/
├── .github/workflows/ # CI/CD workflow configurations
├── dist/ # Built files
├── src/ # Source code
│ ├── adapters.ts # Storage adapters
│ ├── interfaces.ts # Core types and interfaces
│ └── index.ts # Main entry point
├── scripts/ # Maintenance and utility scripts
├── package.json # Project metadata and scripts
└── README.md # Project documentation
package.json
according to semantic versioningnpm publish
)docker/
directoryscripts/build/
directoryscripts/test/
directoryMIT
[
{
"description": "Add a new prompt",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"prompt": {
"additionalProperties": false,
"properties": {
"category": {
"type": "string"
},
"content": {
"type": "string"
},
"description": {
"type": "string"
},
"isTemplate": {
"default": false,
"type": "boolean"
},
"name": {
"type": "string"
},
"tags": {
"items": {
"type": "string"
},
"type": "array"
},
"variables": {
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"name",
"content"
],
"type": "object"
}
},
"required": [
"prompt"
],
"type": "object"
},
"name": "add_prompt"
},
{
"description": "Get a prompt by ID",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"id": {
"type": "string"
}
},
"required": [
"id"
],
"type": "object"
},
"name": "get_prompt"
},
{
"description": "Update an existing prompt",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"id": {
"type": "string"
},
"prompt": {
"additionalProperties": false,
"properties": {
"category": {
"type": "string"
},
"content": {
"type": "string"
},
"description": {
"type": "string"
},
"isTemplate": {
"type": "boolean"
},
"name": {
"type": "string"
},
"tags": {
"items": {
"type": "string"
},
"type": "array"
},
"variables": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
}
},
"required": [
"id",
"prompt"
],
"type": "object"
},
"name": "update_prompt"
},
{
"description": "List all prompts",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"category": {
"type": "string"
},
"isTemplate": {
"type": "boolean"
},
"limit": {
"exclusiveMinimum": 0,
"type": "integer"
},
"offset": {
"minimum": 0,
"type": "integer"
},
"order": {
"enum": [
"asc",
"desc"
],
"type": "string"
},
"search": {
"type": "string"
},
"sort": {
"type": "string"
},
"tags": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"name": "list_prompts"
},
{
"description": "Apply variables to a prompt template",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"id": {
"type": "string"
},
"variables": {
"additionalProperties": {
"type": [
"string",
"number",
"boolean"
]
},
"type": "object"
}
},
"required": [
"id",
"variables"
],
"type": "object"
},
"name": "apply_template"
},
{
"description": "Delete a prompt",
"inputSchema": {
"$schema": "http://json-schema.org/draft-07/schema#",
"additionalProperties": false,
"properties": {
"id": {
"type": "string"
}
},
"required": [
"id"
],
"type": "object"
},
"name": "delete_prompt"
}
]