Design Patterns MCP Server
设计模式 MCP 服务器
一个智能 MCP (Model Context Protocol) 服务器,通过混合搜索(语义 + 关键词 + 图增强)提供设计模式推荐。通过具有先进混合 RAG 架构的自然语言界面,访问 90 多个类别中的 685+ 种设计模式。
快速开始
# Clone and setup
git clone https://github.com/apolosan/design_patterns_mcp.git
cd design_patterns_mcp
# Install dependencies and build (using bun)
bun install
bun run db:setup
# Or using npm (if bun is not installed)
npm install --ignore-scripts
npx tsc
node dist/src/cli/migrate.js
node dist/src/cli/seed.js
node dist/src/cli/generate-embeddings.js
node dist/src/cli/setup-relationships.js在您的 MCP 客户端(Claude Desktop、Cursor 等)中进行配置,并开始通过自然语言查询发现模式。
Related MCP server: Acemcp
特性
特性 | 描述 |
混合搜索引擎 | 结合语义、关键词 (TF-IDF) 和图增强检索的混合 RAG |
685+ 模式 | 涵盖 12 个主要类别的综合目录 |
MCP 集成 | 与 Claude、Cursor 及其他 MCP 客户端无缝集成 |
多级缓存 | L1 内存缓存 + L3 SQLite 缓存,命中率 95%+ |
事件总线系统 | 通过发布/订阅实现解耦的服务通信 |
遥测与健康状况 | 实时性能指标和系统监控 |
SOLID 架构 | 遵循最佳实践的简洁、可维护的代码库 |
生产就绪 | 464 个测试用例,通过率 100% |
可用模式类别
类别 | 数量 | 示例 |
经典 GoF 模式 | 34 | 工厂、构建器、观察者、策略、命令 |
架构模式 | 56 | MVC、整洁架构、六边形、DDD |
微服务与云 | 39 | 断路器、Saga、服务网格 |
数据工程 | 54 | 存储库、CQRS、事件溯源 |
AI/ML 与 MLOps | 46 | RAG、微调、模型压缩 |
React 模式 | 27 | Hooks、服务器组件、性能 |
区块链与 Web3 | 115 | DeFi、NFT、智能合约、MEV |
并发与响应式 | 45 | 生产者-消费者、Actor 模型 |
安全性 | 21 | OAuth、RBAC、零信任 |
函数式编程 | 26 | 单子、函子、高阶函数 |
架构
src/
├── adapters/ # External service adapters (LLM, embeddings)
├── cli/ # CLI commands (migrate, seed, embeddings, setup-relationships)
├── core/ # DI Container, configuration builder
├── db/ # Database migrations
├── events/ # Event bus system
├── handlers/ # MCP request handlers (hybrid search, recommendations)
├── health/ # Health check services
├── repositories/ # Data access layer
├── search/ # Hybrid search engine
├── services/ # Business services (cache, telemetry, pattern service)
├── strategies/ # Strategy pattern implementations
├── types/ # TypeScript type definitions
└── mcp-server.ts # MCP server entry point
data/
├── patterns/ # 750+ JSON pattern definitions
└── design-patterns.db # SQLite database with embeddings使用方法
查找模式
通过您的 MCP 客户端提出自然语言问题:
"I need to create complex objects with many optional configurations"
→ Builder, Abstract Factory, Factory Method
"How to handle service failures gracefully in distributed systems?"
→ Circuit Breaker, Bulkhead, Retry, Fallback
"What pattern helps with state-dependent behavior in React?"
→ State Machine, Observer, useReducer
"How to implement secure authentication and authorization?"
→ OAuth 2.0, RBAC, JWT, Zero TrustMCP 工具
工具 | 描述 |
| 使用问题描述进行模式的混合搜索 |
| 带过滤功能的关键词或语义搜索 |
| 包含代码示例的综合模式信息 |
| 关于可用模式的统计信息 |
| 系统健康状况和服务状态 |
安装
先决条件
Node.js >= 18.0.0
Bun >= 1.0.0 (推荐) 或 npm >= 8.0.0
使用 Bun 安装
bun install
bun run build
bun run db:setup使用 npm 安装
package.json 中的 prepare 脚本需要 bun。如果您没有安装 bun,请使用 --ignore-scripts 跳过它并手动构建:
npm install --ignore-scripts
npx tsc
# Setup database
node dist/src/cli/migrate.js
node dist/src/cli/seed.js
node dist/src/cli/generate-embeddings.js
node dist/src/cli/setup-relationships.jsMCP 配置
添加到您的 MCP 客户端配置(Claude Desktop、Cursor 等)中:
{
"mcpServers": {
"design-patterns": {
"command": "node",
"args": ["/absolute/path/to/design-patterns-mcp/dist/src/mcp-server.js"],
"env": {
"LOG_LEVEL": "info",
"DATABASE_PATH": "/absolute/path/to/design-patterns-mcp/data/design-patterns.db",
"ENABLE_HYBRID_SEARCH": "true",
"ENABLE_GRAPH_AUGMENTATION": "true",
"EMBEDDING_COMPRESSION": "true",
"ENABLE_FUZZY_LOGIC": "true",
"ENABLE_TELEMETRY": "true",
"ENABLE_MULTI_LEVEL_CACHE": "true"
}
}
}
}重要提示:
args和DATABASE_PATH请务必使用绝对路径。像 Cursor 这样的 MCP 客户端对cwd字段的支持并不稳定,因此相对路径会解析为用户主目录而不是项目目录。请参阅 QUICKSTART.md 获取特定客户端的配置示例。
环境变量
变量 | 默认值 | 描述 |
|
| 日志级别 (debug, info, warn, error) |
|
| SQLite 数据库路径 |
|
| 启用混合 RAG 搜索 |
|
| 启用模式关系遍历 |
|
| 降维 |
|
| 模糊逻辑结果优化 |
|
| 性能指标 |
|
| L1 + L3 缓存 |
|
| 请求并发限制 |
|
| 缓存大小限制 |
|
| 缓存 TTL (毫秒) |
|
| 传输模式 (stdio/http) |
|
| HTTP 端口 (http 模式) |
|
| MCP 端点路径 |
|
| 健康检查路径 |
|
| 跳过数据库设置 |
Docker 部署
快速开始
# Build
docker build -t design-patterns-mcp .
# Run HTTP mode
docker run -p 3000:3000 -e TRANSPORT_MODE=http design-patterns-mcp
# Run stdio mode (default)
docker run design-patterns-mcpDocker Compose
docker compose up --build -d环境变量
变量 | 默认值 | 描述 |
|
| 传输模式 (stdio/http) |
|
| HTTP 端口 (http 模式) |
|
| MCP 端点路径 |
|
| 健康检查路径 |
|
| SQLite 数据库路径 |
|
| 日志级别 |
|
| 跳过数据库设置 |
端点 (HTTP 模式)
GET /health- 健康检查POST /mcp- MCP JSON-RPC 端点
命令
# Development
bun run build # Compile TypeScript
bun run dev # Development with hot reload
bun run start # Build and start production server
# Database
bun run db:setup # Complete database setup
bun run migrate # Run migrations
bun run seed # Seed pattern data
bun run generate-embeddings # Generate semantic embeddings
bun run setup-relationships # Setup pattern relationships
# Quality
bun run test # Run all tests
bun run lint # Check code quality
bun run lint:fix # Auto-fix linting issues
bun run typecheck # TypeScript type checking测试
该项目包含 464 个测试用例,分布在 41 个测试文件中,通过率为 100%:
契约测试:MCP 协议合规性验证
集成测试:组件交互测试
性能测试:搜索和向量化基准测试
单元测试:单个组件测试
# Run all tests
bun run test
# Run specific test suites
bun run test:unit -- --grep "PatternService"
bun run test:integration -- --grep "database"
bun run test:performance -- --timeout 30000架构模式
本项目实现了其所记录的模式:
模式 | 实现 |
存储库 |
|
服务层 |
|
对象池 |
|
依赖注入 |
|
策略 |
|
事件总线 |
|
多级缓存 |
|
构建器 |
|
贡献
欢迎贡献!在提交 PR 之前,请阅读我们的贡献指南。
Fork 本仓库
创建功能分支
遵循 SOLID 原则进行更改
运行测试和 linting
提交拉取请求
许可证
MIT 许可证 - 详情请参阅 LICENSE。
资源
版本: 0.4.4
最后更新: 2026 年 2 月
模式: 685+ (750+ JSON 文件)
测试: 464 个测试用例 | 100% 通过率
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- Alicense-qualityDmaintenanceEnables semantic code search across projects using AI embeddings to find code by meaning rather than just text matching. Provides fast intelligent search, symbol analysis, and code similarity detection with multi-language support.MIT
- AlicenseAqualityFmaintenanceProvides code repository indexing and semantic search capabilities, allowing natural language queries to find relevant code snippets with automatic incremental indexing and multi-language support.137359ISC
- Flicense-qualityDmaintenanceEnables semantic search and knowledge management for storing and querying principles, patterns, and learnings using hybrid keyword and vector search.1
- Flicense-qualityFmaintenanceGives Claude semantic search superpowers to find and reuse existing patterns in your codebase.16
Related MCP Connectors
AI Agent with Architectural Memory. Impact analysis (free), tests and code from the graph (pro).
Multilingual semantic SVG icon search with previews for AI coding agents. 20,000+ icons.
A design-style library for AI agents: search real styles, fetch a ready-to-apply design spec.
Appeared in Searches
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/apolosan/design_patterns_mcp'
If you have feedback or need assistance with the MCP directory API, please join our Discord server