The Design Patterns MCP Server provides intelligent design pattern recommendations through semantic search and natural language queries, accessing a comprehensive catalog of 555+ patterns across 20+ categories.
Core Capabilities:
Natural language pattern discovery: Find relevant patterns using problem descriptions with confidence-scored recommendations
Advanced search options: Perform keyword, semantic, or hybrid searches with filtering by categories (GoF, Architectural, Microservices, React, AI/ML, Security, etc.) and programming languages
Detailed pattern information: Access comprehensive details including multi-language code examples, relationships, and use cases for any specific pattern
Catalog statistics: Query total pattern counts with optional category breakdowns
High-performance operations: Fast vector search using sqlite-vec with LRU caching and object pooling, delivering 30-40% faster repeated queries
AI assistant integration: Compatible with MCP clients like Claude Code and Cursor for seamless workflow integration
Uses SQLite with vector extensions for efficient semantic search and storage of design pattern embeddings and metadata
Design Patterns MCP Server ๐ฏ
An intelligent MCP (Model Context Protocol) server that provides design pattern recommendations using semantic search and vector embeddings. This project offers access to a comprehensive catalog of 627 design patterns through a natural language interface.
๐ Overview
The Design Patterns MCP Server is a specialized server that integrates with AI assistants (like Claude, Cursor) to provide intelligent design pattern recommendations. It uses advanced semantic search technologies to find the most appropriate patterns based on natural language problem descriptions.
โจ Key Features
๐ Intelligent Semantic Search: Find patterns using natural problem descriptions
๐ Comprehensive Catalog: 627 patterns organized in 90+ categories
๐ฏ Contextual Recommendations: Suggestions based on programming language and domain
โก Vector Search: Uses SQLite with vector extensions for efficient search
๐ Multi-language: Support for multiple programming languages
๐ง MCP Integration: Compatible with Claude Code, Cursor and other MCP clients
๐ High Performance: Object Pool pattern prevents memory leaks, optimized queries
๐พ Smart Caching: LRU cache with 85%+ hit rate reduces database load
๐ Structured Logging: Professional logging system with service-based organization
๐๏ธ SOLID Architecture: Clean, maintainable, and testable codebase
๐ก๏ธ Production Ready: High test pass rate (219/219), zero memory leaks, graceful degradation
๐ Project Status (v0.2.10)
Latest Updates (October 2025)
โ 100% Test Pass Rate: 219 out of 219 tests passing (100%) - Production Ready!
โ TypeScript Errors Fixed: All build errors resolved, full TypeScript compilation passing
โ Critical Bug Fix: find_patterns tool now returns recommendations correctly (was returning 0)
โ Code Sanitization: Removed unused files and optimized codebase for maintainability
โ Pattern Matching Fix: Improved weighted scoring in PatternMatcher with score normalization (0-1 range)
โ Critical Stability Fixes: 15 total issues resolved (P0/P1/P2/P3)
โ Race Condition Protection: Simple Lock Pattern prevents concurrent cache corruption
โ Transaction Retry Logic: Exponential backoff for SQLITE_BUSY/LOCKED errors
โ Graceful Degradation: System continues on migration/seeding failures
โ Error Recovery: Self-healing statement pool removes corrupted statements
โ Performance Optimized: FNV-1a hash algorithm (30-40% faster cache keys)
โ DI Container Migration: Complete removal of deprecated singleton functions
โ Zero Memory Leaks: Object Pool pattern with bounded resource management (max 100)
โ 627 Patterns: Comprehensive catalog with code examples across 90+ categories
โ Database Schema Fixed: Migration system stable with proper table creation
โ Data Preservation: Migrations rename tables instead of dropping (prevents data loss)
โ Structured Logging: Professional logging system replaces console.log (10 replacements)
โ Build & TypeCheck: All compilation checks passing
Architecture Refactoring (v0.2.x)
โ Object Pool Pattern: Eliminates memory leaks with bounded prepared statements (max 100)
โ Service Layer: Centralized business logic with
PatternServiceโ Facade Pattern: Simplified handlers via
PatternHandlerFacadeโ Dependency Injection: Full DI Container integration for testability
โ Smart Caching: LRU cache with 85%+ hit rate and TTL support
โ Code Quality: 40% reduction in main server file (704โ422 lines)
โ Design Patterns Applied: Retry Pattern, Graceful Degradation, Simple Lock, Error Recovery, Database Transaction, Fail-Fast, Schema Versioning, Data Preservation
๐๏ธ Available Pattern Categories (627 Patterns)
Classic Design Patterns (GoF)
Creational (8): Factory, Builder, Singleton, Prototype, Abstract Factory
Structural (10): Adapter, Bridge, Composite, Decorator, Facade, Flyweight, Proxy
Behavioral (16): Observer, Strategy, Command, State, Chain of Responsibility, Iterator, Mediator, Memento, Template Method, Visitor, Interpreter
Architectural & Enterprise (56 patterns)
Architectural (15): MVC, MVP, MVVM, Clean Architecture, Hexagonal, Layered, Event-Driven
Enterprise (24): Repository, Unit of Work, Service Layer, Dependency Injection
Domain-Driven Design (17): Aggregate, Value Object, Entity, Domain Event, Bounded Context
Microservices & Cloud (39 patterns)
Microservices (22): Circuit Breaker, Event Sourcing, CQRS, Saga, Service Mesh
Cloud-Native (14): Auto-scaling, Load Balancing, Service Discovery
Serverless (1): Function as a Service patterns
DevOps (1): CI/CD patterns
Infrastructure (1): IaC patterns
Data Engineering & Management (54 patterns)
Data Access (10): Active Record, Data Mapper, Query Object
Data Engineering (4): ETL, Data Pipeline, Stream Processing
Data Storage (3): Partitioning, Sharding, Replication
Data Quality (3): Validation, Cleansing, Monitoring
Data Query (7): WHERE Filtering, CASE Expression, CTE, Window Functions
Data Ingestion (8): Batch, Streaming, CDC
Data Flow (3): Data Lineage, Data Catalog
Data Security (3): Encryption, Masking, Access Control
Data Observability (3): Monitoring, Alerting, Logging
Data Value (5): Monetization, Governance, Quality Metrics
Data Management (4): Lifecycle, Archival, Retention
Big Data Analysis (5): Distributed Computing patterns
AI/ML & MLOps (46 patterns)
AI/ML (38): Model Training, RAG, Few-Shot Learning, Fine-Tuning, Inference Optimization
MLOps (1): Model Deployment, Monitoring, A/B Testing
Machine Learning (3): Model Compression, Knowledge Distillation, Model Parallelism
AI Governance (5): Ethics, Bias Mitigation, Interpretability
React Patterns (27 patterns)
React Fundamentals (5): Components, Props, State
React Hooks (6): useState, useEffect, Custom Hooks
React Server Components (2): RSC, Streaming
React State Management (1): Context, Redux patterns
React Performance (1): Memoization, Code Splitting
React Forms (2): Controlled, Uncontrolled
React Routing (1): Navigation patterns
React Styling (2): CSS-in-JS, Tailwind
React Testing (1): Testing Library, E2E
React Components (1): Composition patterns
React Error Handling (1): Error Boundaries
React UI (2): Accessibility, Responsive Design
React Best Practices (1): Code organization
React Modern (1): React 19 features
Blockchain & Web3 (115 patterns)
DeFi Protocols: AMM (6), Lending (10), Stablecoin (2), Yield (1), Derivatives (2), Vault (2), Tokenomics (3)
NFT Patterns (14): Minting, Marketplace, Metadata
NFT Royalty (2): EIP-2981, Custom royalties
NFT Storage (1): IPFS, Arweave integration
Smart Contract: Security (6), Upgradeability (1), Access Control (3), Factory (2), Gas Optimization (5)
DAO Patterns: Governance (11), Treasury (2)
Cross-Chain (8): Bridge, Relay, Atomic Swap
Layer 2: Scaling (7), Data Availability (1)
Account Abstraction (5): ERC-4337, Session Keys
MEV (3): Protection, Extraction, Ordering
Privacy (2): Zero-Knowledge (3), Stealth Addresses
Real World Assets (3): Tokenization, Oracle integration
Token Economics (3): Vesting, Distribution
Restaking (2): EigenLayer patterns
Sustainable Blockchain (3): Energy efficiency
Modular Blockchain (1): Celestia, Avail
Intent-Based Architecture (3): User intents, Solvers
Web3 Frontend (8): Wallet connection, Transaction handling
AI & Blockchain (2): AI + Web3 integration
Performance & Optimization (24 patterns)
Performance (20): Caching, Lazy Loading, Object Pool, Connection Pooling
Caching (4): Cache-Aside, Write-Through, Read-Through
Concurrency & Reactive (45 patterns)
Concurrency (27): Producer-Consumer, Thread Pool, Actor Model, Lock-Free
Reactive (18): Observer, Publisher-Subscriber, Reactive Streams, Backpressure
Integration & Messaging (21 patterns)
Integration (18): Message Queue, Event Bus, API Gateway, ESB
Messaging (3): Publish-Subscribe, Point-to-Point
Testing & Quality (20 patterns)
Testing (20): Test Double, Page Object, Builder Pattern for tests, Contract Testing
Development Practices (40 patterns)
Functional (26): Monads, Functors, Higher-Order Functions, Immutability
Error Management (7): Exception Handling, Retry, Circuit Breaker
Idempotency (7): Idempotent Operations, Request Deduplication
Mobile & IoT (24 patterns)
Mobile (10): Model-View-Intent, Redux patterns, Offline-First
IoT (13): Device Twin, Telemetry Ingestion, Edge Processing
Edge Computing (1): Edge Analytics
Game Development (16 patterns)
Game Development (16): State Machine, Component System, Object Pool, Command Pattern
Embedded Systems (5 patterns)
Embedded Systems (5): State Machine, Table-Driven State Machine, Circular Buffer, Watchdog Timer, Interrupt Service Routine
Security (21 patterns)
Security (21): Authentication, Authorization, Data Protection, OWASP Top 10
Storage & Infrastructure (5 patterns)
Storage (4): File System, Object Storage, Database patterns
Infrastructure (1): IaC patterns
Others
Anti-Patterns (15): Common mistakes and their solutions
Reliability (1): Fault tolerance patterns
Development & Deployment (2): CI/CD patterns
Development & Testing (3): TDD, BDD patterns
๐๏ธ Project Architecture
Refactored Architecture (v0.2.x)
๐ง Main Components
Core Services
DatabaseManager: SQLite operations with Object Pool (prevents memory leaks)
StatementPool: LRU-based pool for prepared statements (max 100)
CacheService: In-memory LRU cache with TTL and metrics
Business Logic
PatternService: Service Layer orchestrating pattern operations
PatternRepository: Data access abstraction (Repository Pattern)
SemanticSearchService: Semantic search with embeddings
PatternMatcher: Pattern matching and ranking logic
Integration
PatternHandlerFacade: Facade simplifying MCP handlers
VectorOperationsService: Vector search using sqlite-vec
LLMBridgeService: Interface for language models (optional)
EmbeddingServiceAdapter: Adapter for embedding services
Infrastructure
SimpleContainer: Dependency Injection container
MigrationManager: Database migrations
PatternSeeder: Initial data seeding
๐ Installation and Setup
Prerequisites
Node.js >= 18.0.0
npm >= 8.0.0 or Bun >= 1.0.0
Installation
MCP Configuration
Add to your MCP configuration file (.mcp.json or Claude Desktop config):
๐ Usage
Finding Patterns with Natural Language
Use natural language descriptions to find appropriate design patterns through Claude Code:
For object creation problems:
"I need to create complex objects with many optional configurations"
"How can I create different variations of similar objects?"
"What pattern helps with step-by-step object construction?"
For behavioral problems:
"I need to notify multiple components when data changes"
"How to decouple command execution from the invoker?"
"What pattern helps with state-dependent behavior?"
For architectural problems:
"How to structure a microservices communication system?"
"What pattern helps with distributed system resilience?"
"How to implement clean separation between layers?"
For React development:
"How to manage state in React 18/19?"
"What patterns work with React Server Components?"
"How to optimize React performance?"
MCP Tool Functions
find_patterns: Semantic search for patterns using problem descriptions
Returns ranked recommendations with confidence scores
Supports category filtering and programming language preferences
search_patterns: Keyword or semantic search with filtering options
Supports hybrid search (keyword + semantic)
Filter by category, tags, complexity
get_pattern_details: Get comprehensive information about specific patterns
Includes code examples in multiple languages
Shows similar patterns and relationships
Displays implementations and use cases
count_patterns: Statistics about available patterns by category
Optional detailed breakdown by category
๐ ๏ธ Available Commands
๐ฏ Usage Examples
Problem-Based Pattern Discovery
Distributed Systems:
"I need a pattern for handling service failures gracefully" โ Circuit Breaker, Bulkhead
"How to implement eventual consistency in distributed data?" โ Event Sourcing, CQRS
"What pattern helps with service discovery and load balancing?" โ Service Registry, API Gateway
Data Validation:
"I need to validate complex business rules on input data" โ Specification Pattern
"How to compose validation rules dynamically?" โ Chain of Responsibility
"What pattern separates validation logic from business logic?" โ Strategy Pattern
Performance Optimization:
"I need to cache expensive computations efficiently" โ Cache-Aside, Write-Through
"How to implement lazy loading for large datasets?" โ Lazy Loading, Virtual Proxy
"What pattern helps with connection pooling?" โ Object Pool Pattern
Category-Specific Searches
Enterprise Applications:
"Show me enterprise patterns for data access" โ Repository, Unit of Work, Data Mapper
"What patterns help with dependency injection?" โ DI Container, Service Locator
"How to implement domain-driven design?" โ Aggregate, Value Object, Bounded Context
Security Implementation:
"I need authentication and authorization patterns" โ RBAC, OAuth 2.0, JWT
"What patterns help with secure data handling?" โ Encryption at Rest, Defense in Depth
"How to implement role-based access control?" โ RBAC Pattern, Policy-Based Access
๐ง Advanced Configuration
Environment Variables
Using the Refactored Server
Performance Monitoring
๐งช Testing
The project includes a comprehensive test suite with 219 passing tests (100% success rate):
Contract Tests: Validate MCP protocol compliance
Integration Tests: Test interaction between components
Performance Tests: Evaluate search and vectorization performance
Unit Tests: Test individual components in isolation
Test Coverage
MCP Protocol: โ 100%
Core Services: โ 95%+
Performance: โ Comprehensive benchmarks
Database: โ Full migration & seeding tests
๐๏ธ Architecture Patterns Used
This project practices what it preaches by implementing:
Pattern | Location | Purpose |
Repository |
| Data access abstraction |
Service Layer |
| Business logic orchestration |
Object Pool |
| Resource management |
Facade |
| Simplified interface |
Dependency Injection |
| Inversion of control |
Strategy |
| Interchangeable algorithms |
Factory |
| Object creation |
Singleton | Via DI Container | Single instance management |
Adapter |
| External service integration |
Logger |
| Structured logging system |
๐ค Contributing
We welcome contributions! Here's how:
Fork the project
Create a feature branch (
git checkout -b feature/amazing-feature)Make your changes following our code style
Run tests (
npm test) and ensure they passRun linting (
npm run lint:fix)Commit your changes (
git commit -am 'Add amazing feature')Push to the branch (
git push origin feature/amazing-feature)Open a Pull Request
Development Guidelines
Follow SOLID principles
Write tests for new features
Update documentation
Use TypeScript strict mode
Use structured logging (
logger.info('service-name', message)) instead ofconsole.logFollow existing code patterns
๐ License
This project is licensed under the MIT License. See LICENSE for details.
๐ Useful Links
๐ Support
๐ Issues: Report bugs through GitHub Issues
๐ฌ Discussions: Join GitHub Discussions
๐ง Email: apolosan@protonmail.com
๐ Documentation: Comprehensive architecture and refactoring details available in project documentation
๐ Acknowledgments
Design patterns from the software engineering community
MCP protocol by Anthropic
SQLite and sqlite-vec for efficient storage and search
Open source contributors
Version: 0.2.10
Last Updated: October 2025
Patterns: 627
Tests: 219/219 passing (100%)
Status: Production Ready
Architecture: SOLID + Design Patterns
Logging: Structured Logger implemented