A Model Context Protocol (MCP) server that exposes pattern/prompt content from Fabric and custom directories for direct use by LLMs.
Existing Fabric MCP implementations (like ksylvan/fabric-mcp) execute patterns through Fabric's configured LLM and relay the results back. This defeats the purpose of empowering your current LLM with Fabric's specialized prompts.
What this server does differently:
- Exposes pattern content directly - Returns the actual prompt text instead of executing it
- No middleman execution - Your LLM uses the patterns directly, maintaining context and conversation flow
- Composable - Combine multiple patterns or use parts of them
- Extensible - Easy to add new pattern sources or categories
This approach lets you leverage Fabric's carefully crafted prompts like extract_wisdom, analyze_claims, etc., while keeping the execution within your current LLM session.
- Pattern Management: List, search, and retrieve patterns from both Fabric and custom directories
- Fabric Integration: Automatically discovers and serves patterns from your Fabric installation
- Custom Patterns: Build your own prompt library in
~/.config/custom_patterns/ - Search & Discovery: Find patterns by content, tags, or metadata
- Resource Browsing: Access patterns as browsable resources via MCP
mkdir ~/pattern-mcp-server
cd ~/pattern-mcp-serverSave the Python code as pattern_mcp_server.py
mcp>=0.1.0pip install -r requirements.txt
# or with uv:
uv pip install -r requirements.txtchmod +x pattern_mcp_server.pyVirtual environments provide isolation and prevent dependency conflicts. Here's why and how to use them with the Pattern MCP Server:
Key Benefits:
- Isolation: Keeps MCP dependencies separate from system Python
- Version Control: No conflicts with other projects
- Clean Uninstall: Just delete the folder
- Team Sharing: Others can recreate your exact environment
Setup with virtual environment:
# Create virtual environment
python -m venv venv
# Activate it (Unix/macOS)
source venv/bin/activate
# Install dependencies
pip install -r requirements.txt
# Use the provided run script
./run_pattern_mcp.shWhy use the wrapper script?
The run_pattern_mcp.sh script is required because MCP clients can't activate virtual environments directly. The script:
- Activates the virtual environment
- Launches the Python server
- Ensures dependencies are properly isolated
Alternative: Using UV for virtual environments:
# UV automatically creates .venv
uv venv
# Install dependencies
uv pip install -r requirements.txt
# Update the run script to use .venv instead of venvIf you prefer a different location:
# Put it in a development folder
mkdir ~/Development/pattern-mcp-server
# Or in a tools folder
mkdir ~/.local/tools/pattern-mcp-serverIf you're on Windows:
# PowerShell commands
mkdir $HOME\pattern-mcp-server
cd $HOME\pattern-mcp-server
# For virtual environment on Windows
python -m venv venv
.\venv\Scripts\Activate
pip install -r requirements.txtAdd this to your MCP client configuration (e.g., for Claude Desktop, Cursor, etc.):
{
"pattern-content": {
"command": "python",
"args": ["~/pattern-mcp-server/pattern_mcp_server.py"]
}
}Or if you prefer using the shebang:
{
"pattern-content": {
"command": "~/pattern-mcp-server/pattern_mcp_server.py",
"args": []
}
}Or if using the virtual environment run script (recommended):
{
"pattern-content": {
"command": "/bin/bash",
"args": ["~/pattern-mcp-server/run_pattern_mcp.sh"]
}
}Important Notes:
- The wrapper script approach with
/bin/bashensures proper virtual environment activation before running the server - Tilde (~) expansion may not work in MCP configurations. If you get "No such file or directory" errors, use absolute paths (e.g.,
/Users/yourusername/pattern-mcp-server/) instead of~/pattern-mcp-server/ - Run
echo $HOMEto find your home directory path
The server expects/creates these directories:
~/.config/
├── fabric/
│ └── patterns/ # Fabric patterns (if you have Fabric installed)
│ ├── analyze_claims/
│ │ ├── system.md
│ │ └── user.md
│ └── extract_wisdom/
│ └── system.md
└── custom_patterns/ # Your custom patterns
├── my_prompt.md
├── my_prompt.json # Optional metadata
└── code_review.md
python pattern_mcp_server.pyThe server runs as an MCP stdio server, ready to be connected by MCP clients.
List all available patterns from Fabric and custom directories.
Parameters:
source(optional): Filter by source - "all", "fabric", or "custom" (default: "all")tags(optional): Filter patterns by tags array
Retrieve the content of a specific pattern.
Parameters:
name(required): Name of the pattern to retrieve
Search patterns by content or description.
Parameters:
query(required): Search query stringlimit(optional): Maximum number of results (default: 10)
Create a new custom pattern.
Parameters:
name(required): Name for the new patterncontent(required): The pattern content/promptmetadata(optional): Metadata object (tags, description, etc.)
All patterns are also exposed as MCP resources with URIs like:
pattern://extract_wisdompattern://my_custom_prompt
Ask me: "List all available patterns"
Ask me: "Get the content of the 'extract_wisdom' pattern"
Ask me: "Search for patterns related to 'code review'"
Ask me: "Create a pattern called 'meeting_notes' with this content: [your prompt]"
~/.config/custom_patterns/code_review.md:
You are an expert code reviewer. Analyze the provided code for:
1. Code quality and readability
2. Potential bugs or issues
3. Performance concerns
4. Security vulnerabilities
5. Best practices adherence
Provide specific, actionable feedback with examples.~/.config/custom_patterns/meeting_notes.json:
{
"description": "Extract key points from meeting transcripts",
"tags": ["meetings", "summary", "extraction"],
"author": "Your Name",
"version": "1.0"
}See the examples/ directory for complete example patterns including:
- Blog Analysis - Analyzes blog posts for content quality, structure, and SEO
- Code Security Review - Comprehensive security review focusing on OWASP Top 10
- Zettelkasten Note Analyzer - Analyzes notes for knowledge management best practices
Each example includes both the pattern content (.md) and metadata (.json) files to demonstrate best practices for pattern creation.
Modify the __init__ method to add more pattern directories:
self.team_patterns_dir = Path.home() / ".config" / "team_patterns"
self.project_patterns_dir = Path.home() / "projects" / "prompts"Add validation in the create_pattern method:
def validate_pattern(self, content: str) -> bool:
# Check for required sections, length, etc.
return TrueCreate template patterns that users can customize:
TEMPLATES = {
"code_analysis": "You are an expert...",
"data_extraction": "Extract the following..."
}- Organize with Tags: Use metadata files to tag and categorize your patterns
- Version Control: Consider putting your custom_patterns directory in git
- Team Sharing: Mount a shared directory for team patterns
- Pattern Composition: Create patterns that reference other patterns
-
Server won't start: Check Python version (3.8+) and MCP installation
-
Patterns not found: Ensure directories exist and have correct permissions
-
Can't create patterns: Check write permissions on custom_patterns directory
-
"No such file or directory" error with run script: The tilde (~) isn't being expanded in MCP configurations. Use absolute paths instead:
# Find your home directory echo $HOME
Then update your MCP configuration:
{ "pattern-content": { "command": "/bin/bash", "args": ["/Users/yourusername/pattern-mcp-server/run_pattern_mcp.sh"] } }Alternative: Use the Python binary from the virtual environment directly:
{ "pattern-content": { "command": "/Users/yourusername/pattern-mcp-server/venv/bin/python", "args": ["/Users/yourusername/pattern-mcp-server/pattern_mcp_server.py"] } }
- Python 3.8+
- mcp>=0.1.0
- Install Fabric to get access to its pattern library
- Create your first custom patterns
- Build pattern collections for specific domains
- Share patterns with your team
MIT License - see LICENSE file for details.
Created by James Fishwick to provide direct access to prompt patterns for personal knowledge management and AI workflow optimization.
# If you haven't activated your virtual environment yet:
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dev dependencies if not already installed:
pip install -r requirements-dev.txt
# Now you can run linting:
make lint# Clone the repository
git clone <repository-url>
cd pattern-mcp-server
# Create and activate virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install development dependencies
pip install -r requirements-dev.txt
# Or use make commands after activating venv
make install-dev
# Set up pre-commit hooks
pre-commit install# Run tests
make test
# Run tests with coverage
make test-cov
# View coverage report
open htmlcov/index.html# Run linting
make lint
# Format code
make format
# Run all pre-commit hooks
pre-commit run --all-filesmake install- Install production dependenciesmake install-dev- Install development dependenciesmake lint- Run linting (ruff and mypy)make format- Format code with black and ruffmake test- Run unit testsmake test-cov- Run tests with coverage reportmake clean- Clean up generated filesmake run- Run the MCP servermake setup- Full development environment setup
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests and linting (
make test && make lint) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
- We use Black for code formatting
- Ruff for linting
- MyPy for type checking
- All code must pass the pre-commit hooks
- Maintain test coverage above 80%