Design Patterns MCP Server
Design Patterns MCP Server
ハイブリッド検索(セマンティック + キーワード + グラフ拡張)を使用してデザインパターンのレコメンデーションを提供するインテリジェントな MCP(Model Context Protocol)サーバーです。高度なブレンド RAG アーキテクチャを備えた自然言語インターフェースを通じて、90 以上のカテゴリにわたる 710 のデザインパターンにアクセスできます。
クイックスタート
# 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/cli/migrate.js
node dist/cli/seed.js
node dist/cli/generate-embeddings.js
node dist/cli/setup-relationships.jsMCP クライアント(Claude Desktop、Cursor など)で設定し、自然言語クエリでパターンの発見を始めましょう。
Related MCP server: Acemcp
ツールとビルドの衛生管理
このリポジトリの標準パッケージマネージャーとして Bun を使用します(
bun installのみ)。ロックファイルはbun.lockです。.gitディレクトリをdist/dataにコピーしないでください(dist/内に同梱しないでください)。そのパスは、ギガバイト単位のイメージやメタデータの漏えいを防ぐため、プレーンなデータディレクトリのままにしておく必要があります。
機能
機能 | 説明 |
ハイブリッド検索エンジン | セマンティック、キーワード(BM25)、グラフ拡張検索を組み合わせたブレンド RAG |
710 のパターン | 段階的デリバリーと実験のための フィーチャーフラグ / フィーチャートグルを含む 90 以上のカテゴリにわたる包括的なカタログ |
MCP 統合 | Claude、Cursor、その他の MCP クライアントとのシームレスな統合 |
マルチレベルキャッシュ | 95% 以上のヒット率を誇る L1 インメモリ + L3 SQLite キャッシュ |
イベントバスシステム | pub/sub による疎結合なサービス間通信 |
テレメトリとヘルス | リアルタイムのパフォーマンスメトリクスとシステム監視 |
SOLID アーキテクチャ | ベストプラクティスに従ったクリーンで保守性の高いコードベース |
本番稼働対応 | 77 のテストファイルにわたる 654 のテストケース、100% の合格率(失敗 0、スキップ 0) |
利用可能なパターンカテゴリ
カテゴリ | 数 | 例 |
GoF クラシックパターン | 34 | Factory、Builder、Observer、Strategy、Command |
アーキテクチャパターン | 56 | MVC、クリーンアーキテクチャ、ヘキサゴナル、DDD、フィーチャーフラグ |
マイクロサービスとクラウド | 39 | Circuit Breaker、Saga、Service Mesh |
データエンジニアリング | 54 | Repository、CQRS、Event Sourcing |
AI/ML と MLOps | 46 | RAG、Fine-Tuning、Model Compression |
React パターン | 27 | Hooks、Server Components、Performance |
ブロックチェーンと Web3 | 115 | DeFi、NFT、スマートコントラクト、MEV |
並行処理とリアクティブ | 45 | Producer-Consumer、Actor Model |
セキュリティ | 21 | OAuth、RBAC、Zero Trust |
関数型プログラミング | 26 | Monads、Functors、Higher-Order Functions |
アーキテクチャ
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/ # 710 JSON pattern definitions (see `feature-flag.json`)
└── design-patterns.db # SQLite database with 710 patterns and 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:setupnpm でのセットアップ
package.json の prepare スクリプトには bun が必要です。bun がインストールされていない場合は、--ignore-scripts を使用してスキップし、手動でビルドしてください:
npm install --ignore-scripts
npx tsc
# Setup database
node dist/cli/migrate.js
node dist/cli/seed.js
node dist/cli/generate-embeddings.js
node dist/cli/setup-relationships.jsMCP 設定
MCP クライアント設定(Claude Desktop、Cursor など)に追加します:
{
"mcpServers": {
"design-patterns": {
"command": "node",
"args": ["/absolute/path/to/design-patterns-mcp/dist/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フィールドを確実にサポートしていないため、相対パスはプロジェクトディレクトリではなくユーザーのホームディレクトリに対して解決されます。クライアント固有の設定例については、プロジェクトのクイックスタートを参照してください。
環境変数
変数 | デフォルト | 説明 |
|
| ログレベル(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テスト
このプロジェクトには 77 のテストファイルにわたる 654 のテストケース が含まれており、100% の合格率(失敗 0、スキップ 0)です:
コントラクトテスト: MCP プロトコル準拠の検証
統合テスト: 実 SQLite DB と埋め込みに対するコンポーネント連携テスト
パフォーマンステスト: 検索とベクトル化のベンチマーク
ユニットテスト: 個々のコンポーネントのテスト
# 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アーキテクチャパターン
このプロジェクトは、文書化されているパターンを実装しています:
パターン | 実装 |
Repository |
|
Service Layer |
|
Object Pool |
|
Dependency Injection |
|
Strategy |
|
Event Bus |
|
Multi-Level Cache |
|
Builder |
|
ベクター検索(実行時の正直な説明)
サーバーは、保存された埋め込みに対するインメモリのコサイン類似度を備えた sql.js(SQLite WASM)を使用します。ネイティブの sqlite-vec(vec0 仮想テーブル)は、このランタイムでは利用できません。セマンティック検索は現在のカタログサイズ(約 710 パターン)では機能しますが、インデックス化されたネイティブなベクターテーブルは使用しません。
実際のプロバイダー統合がある場合にのみ LLM エンリッチメントを有効にしてください。組み込みの LLM ブリッジプロバイダーは、拡張しない限りプレースホルダーを返します。
コントリビューション
コントリビューションを歓迎します。コントリビューティングガイドを参照してください。
リポジトリをフォークする
フィーチャーブランチを作成する
SOLID 原則に従って変更を加える
テストとリンティングを実行する
プルリクエストを送信する
リリースノート
v0.7.2 — バージョン更新(2026-08-16)
アクティブなソースファイルとドキュメントファイル全体で、正規バージョンを
0.7.1→0.7.2に更新しました。更新されたファイル:
package.json、src/mcp-server.ts(Server 登録 + ランタイム情報)、AGENTS.md、CLAUDE.md(正規 ID ヘッダー)、README.md(バッジ、リリースノートセクション、バージョンフッター)、CHANGELOG.md(新しいエントリ)。docs/IMPROVEMENTS_03.mdとQUICKSTART.mdの監査証跡参照は、状態 #45 に従って変更せずに保持されます。古いバージョン参照を修正:
AGENTS.mdとCLAUDE.mdのヘッダー(version 0.6.0)→(version 0.7.2)(実際のpackage.jsonより 7 マイナーバージョン遅れていました)。ランタイムの自己報告が、
Serverコンストラクターと/infoエンドポイントを介して MCP クライアントに0.7.2を通知するようになりました。コードレベルの動作変更はありません。純粋なリリース/バージョン正規化パッチです。
テスト: 完全なスイートを維持(テストファイルの変更なし)、型チェックはクリーン。
v0.7.1 — Lint + テストの安定化(2026-08-16)
テストスイートは完全に検証済み: 654/654 GREEN、0 スキップ、0 TODO (以前は 651/654 で、既存のフレークが 3 件ありました)。
db:setupパイプラインによって導入されたdata/.gitリークを解消しました (データ衛生テスト)。2 つの古いテストを BUG-007 契約 に合わせました:
validateSearchPatternsArgsは snake_case のsearch_typeを黙って無視し、標準のデフォルトであるhybrid戦略が適用されます。tests/unit/input-validation.test.tstests/unit/mcp-server-search.test.ts
README.md のバージョン乖離を修正: 末尾のブロックが正規の 0.7.0 → 0.7.1 ベースラインを反映し、バッジ + Production Ready + Testing セクションが現在の 654 テストスイートに合わせられました。
Lint ベースラインを復元: 0 問題、exit 0 (以前は 2 エラー + 6 警告)。
src/mcp/http-transport.ts内の未使用のHealthStatusインポートを削除しました。src/health/embedding-coverage-health-check.ts内の同期check()に対するrequire-awaitの対象を絞ったeslint-disableを追加しました (インターフェース準拠を維持)。src/handlers/keyword-search-handler.tsのensureBM25()をBM25Scorerを返すようにリファクタリングし、呼び出し箇所の 4 つの非 null アサーションを排除しました。tests/unit/bm25-scorer.test.ts内のresults.find()に対する 2 つの非 null アサーションを、明示的なtoBeDefinedガードに置き換えました。
bun run typecheckはクリーンです。
v0.7.0 — カタログ拡張 (2026-08-16)
docs/01_Agentic_Design_Patterns.mdとdocs/02_Data_Engineering_Design_Patterns.mdから 24 件の新しいデザインパターン を追加しました:Agentic AI 3 件: Multi-Agent Collaboration、Goal Setting and Monitoring、Exception Handling and Recovery。
Data Engineering 21 件: Aligned Fan-In、Unaligned Fan-In、Bin Pack Orderer、Exclusive Choice、FIFO Orderer、Fine-Grained Accessor for Resources、Fine-Grained Accessor for Tables、Fine-Grained Tracker、In-Place Overwriter、Isolated Sequencer、Metadata Decorator、Metadata Enhancer、Offline Observer、Schema Compatibility Enforcer、Schema Migrator、Secretless Connector、Secrets Pointer、Single Runner、Skew Detector、SLA Misses Detector、Vertical Partitioner。
カタログは 686 → 710 パターン に拡大しました (Agentic AI: 3→6、Data Engineering: 4→25)。
整合性チェック PASS: 710 パターン、151 件の有効なリレーションシップ。
654/654 テストがパス (100% green、0 スキップ、0 TODO)。
ライセンス
MIT ライセンス - 詳細は LICENSE を参照してください。
リソース
ベクトル検索のメモ (sql.js vs sqlite-vec) — コントリビューティングガイドを参照
MCP ツールサーフェスリファレンス
ドキュメントインデックス
バージョン: 0.7.2 最終更新: 2026 年 8 月 パターン: 710 件の JSON 定義 (ハイライト: Feature Flag / Feature Toggle) テスト: 654 テストケース | 100% 合格率 (0 失敗、0 スキップ)
関連情報: 最新の敵対的品質保証レポート (16 件の指摘: クリティカル 1 件、高優先度 9 件、軽微 6 件)。指摘は検索パイプラインの正確性、設定の乖離、トランスポートセキュリティ、ドキュメントの同期を対象としています。
Available Tools
4 toolscount_patternsB
Get the total number of design patterns in the database
Inputs: includeDetails.
find_patternsC
Find design patterns matching a problem description using semantic search
Inputs: query (required), categories, maxResults, programmingLanguage.
get_pattern_detailsC
Get detailed information about a specific pattern
Inputs: patternId (required).
search_patternsC
Search patterns by keyword or semantic similarity
Inputs: query (required), searchType, limit.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 4 tools
Multiple tools have overlapping purposes that could cause confusion. 'find_patterns' and 'search_patterns' both appear to search for patterns, with descriptions that are nearly identical ('semantic search' vs 'keyword or semantic similarity'), making them difficult to distinguish. 'count_patterns' and 'get_pattern_details' are clearer, but the overlap between the two search tools significantly reduces disambiguation.
All tool names follow a consistent verb_noun pattern with snake_case, such as 'count_patterns', 'find_patterns', 'get_pattern_details', and 'search_patterns'. This uniformity makes the tool set predictable and easy to understand, with no deviations in naming conventions.
With only 4 tools, the set feels thin for a server focused on design patterns, which typically involve operations like creating, updating, or categorizing patterns. While basic retrieval functions are covered, the low count may limit functionality for more complex agent tasks, placing it in the borderline range for appropriateness.
The tool set is severely incomplete for a design patterns domain, as it only supports read operations (counting, searching, and getting details) with no ability to create, update, delete, or manage patterns. This lack of CRUD coverage creates significant gaps that will likely cause agent failures when trying to perform full lifecycle tasks.
Maintenance
Related MCP Connectors
Code intelligence for coding agents: semantic, AST, graph, and full-text search. 279+ languages.
Code intelligence platform for AI agents. 20 tools for architecture, security & impact analysis.
AI Agent with Architectural Memory. Impact analysis (free), tests and code from the graph (pro).
295k+ bug-fix patterns with MCP Hub proxy, PII filtering, and code search
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables 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
- AlicenseAqualityDmaintenanceProvides code repository indexing and semantic search capabilities, allowing natural language queries to find relevant code snippets with automatic incremental indexing and multi-language support.1360ISC
- AlicenseAqualityDmaintenanceProvides design pattern templates and anti-pattern guidance to AI coding agents for correct pattern implementation.21MIT
- AlicenseNot gradedqualityDmaintenanceExposes the 23 Gang of Four design patterns to AI coding agents for generation, canonical examples, AST-based detection, validation, and anti-pattern refactoring in Python codebases.1MIT