Skip to main content
Glama
apolosan

Design Patterns MCP Server

by apolosan

设计模式 MCP 服务器

Version License: MIT Test Status Patterns TypeScript

一个智能 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 Trust

MCP 工具

工具

描述

find_patterns

使用问题描述进行模式的混合搜索

search_patterns

带过滤功能的关键词或语义搜索

get_pattern_details

包含代码示例的综合模式信息

count_patterns

关于可用模式的统计信息

get_health_status

系统健康状况和服务状态

安装

先决条件

  • 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.js

MCP 配置

添加到您的 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"
      }
    }
  }
}

重要提示: argsDATABASE_PATH 请务必使用绝对路径。像 Cursor 这样的 MCP 客户端对 cwd 字段的支持并不稳定,因此相对路径会解析为用户主目录而不是项目目录。请参阅 QUICKSTART.md 获取特定客户端的配置示例。

环境变量

变量

默认值

描述

LOG_LEVEL

info

日志级别 (debug, info, warn, error)

DATABASE_PATH

./data/design-patterns.db

SQLite 数据库路径

ENABLE_HYBRID_SEARCH

true

启用混合 RAG 搜索

ENABLE_GRAPH_AUGMENTATION

true

启用模式关系遍历

EMBEDDING_COMPRESSION

true

降维

ENABLE_FUZZY_LOGIC

true

模糊逻辑结果优化

ENABLE_TELEMETRY

true

性能指标

ENABLE_MULTI_LEVEL_CACHE

true

L1 + L3 缓存

MAX_CONCURRENT_REQUESTS

10

请求并发限制

CACHE_MAX_SIZE

1000

缓存大小限制

CACHE_TTL

3600000

缓存 TTL (毫秒)

TRANSPORT_MODE

stdio

传输模式 (stdio/http)

HTTP_PORT

3000

HTTP 端口 (http 模式)

MCP_ENDPOINT

/mcp

MCP 端点路径

HEALTH_CHECK_PATH

/health

健康检查路径

SKIP_DB_SETUP

false

跳过数据库设置

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-mcp

Docker Compose

docker compose up --build -d

环境变量

变量

默认值

描述

TRANSPORT_MODE

stdio

传输模式 (stdio/http)

HTTP_PORT

3000

HTTP 端口 (http 模式)

MCP_ENDPOINT

/mcp

MCP 端点路径

HEALTH_CHECK_PATH

/health

健康检查路径

DATABASE_PATH

/app/data/design-patterns.db

SQLite 数据库路径

LOG_LEVEL

info

日志级别

SKIP_DB_SETUP

false

跳过数据库设置

端点 (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

架构模式

本项目实现了其所记录的模式:

模式

实现

存储库

repositories/pattern-repository.ts

服务层

services/pattern-service.ts

对象池

services/statement-pool.ts

依赖注入

core/container.ts

策略

strategies/search-strategy.ts

事件总线

events/event-bus.ts

多级缓存

services/multi-level-cache.ts

构建器

core/config-builder.ts

贡献

欢迎贡献!在提交 PR 之前,请阅读我们的贡献指南。

  1. Fork 本仓库

  2. 创建功能分支

  3. 遵循 SOLID 原则进行更改

  4. 运行测试和 linting

  5. 提交拉取请求

许可证

MIT 许可证 - 详情请参阅 LICENSE

资源


版本: 0.4.4
最后更新: 2026 年 2 月
模式: 685+ (750+ JSON 文件)
测试: 464 个测试用例 | 100% 通过率

Install Server
A
license - permissive license
B
quality
C
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity
Issues opened vs closed

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

  • A
    license
    -
    quality
    D
    maintenance
    Enables 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
  • A
    license
    A
    quality
    F
    maintenance
    Provides code repository indexing and semantic search capabilities, allowing natural language queries to find relevant code snippets with automatic incremental indexing and multi-language support.
    1
    37
    359
    ISC
  • F
    license
    -
    quality
    D
    maintenance
    Enables semantic search and knowledge management for storing and querying principles, patterns, and learnings using hybrid keyword and vector search.
    1

View all related MCP servers

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.

View all MCP Connectors

Latest Blog Posts

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