An MCP server that provides design-pattern selection expertise to AI coding agents.
636
An MCP server that provides design-pattern selection expertise to AI coding agents. Analyzes a free-text system description, retrieves from 486 built-in patterns (each with generic + 13 language bindings), generates a concrete design with participants/interactions/implementation steps, and evaluates it against eight quality axes.
This Docker image contains a complete MCP (Model Context Protocol) server that brings design-pattern expertise to your AI coding agents. Given a description string plus optional language / paradigm / focus hints, it:
LOOP_MAX_TRIES attempts, default 2)pattern/; alias-aware loader with startup enum-drift guard┌───────────────────────────────────────────────────────────────────┐
│ OpenCode / Claude Code / VS Code / any MCP client │
│ ────────── HTTP ──────────► :8822/mcp (A) or :8812/mcp (B) │
│ │
│ ┌──────────────────────────────┐ │
│ │ design-pattern-mcp │ │
│ └───────────────┬──────────────┘ │
│ │ │
│ ┌───────────────────┼────────────────────┐ │
│ │ design-pattern- │ design-pattern- │ ← shared infra in │
│ │ tei-embed :8080 │ tei-rerank :8080 │ Path B, own copies│
│ │ (TEI) │ (TEI) │ in Path A │
│ └───────────────────┴────────────────────┘ │
│ ┌────────────────────────────────────────┐ │
│ │ design-pattern-style-head :8800 (CPU) │ ← ships in both │
│ └────────────────────────────────────────┘ │
└───────────────────────────────────────────────────────────────────┘
This image is the MCP server only. Retrieval needs two more images from this project:
Qwen/Qwen3-Embedding-0.6B): pattern-tei-embed-gpuAlibaba-NLP/gte-reranker-modernbert-base): pattern-tei-rerank-gpuplus the CPU style head: design-pattern-style-head.
All four images share one version tag (the MCP release, from pyproject.toml). Only the -gpu TEI pair is published — it needs an NVIDIA GPU with sm_61 minimum (sm_60 and below unsupported; sm_61 is the only hardware tested). CPU-only hosts build the -cpu pair locally (make docker-build-tei-cpu); it serves the same models, so the dense cache is shared across lanes.
They connect via Docker DNS using the hostnames design-pattern-tei-embed and design-pattern-tei-rerank on a shared Docker network (Path B joins the shared pattern-tei-infra stack instead, hostnames pattern-tei-embed / pattern-tei-rerank). Published server images bake in the dense embedding cache, so first start is fast; a locally built cache-less image embeds the whole catalog at first start (~5 min via the GPU sidecar vs ~19 min via the CPU sidecar — full-catalog cache build only).
| Tool | Description |
|---|---|
select_design_patterns | Full pipeline (analyze → weights ∥ retrieval → generate → evaluate → refine). 2–10 min |
analyze_design | Requirements analysis only: decision-part decomposition, category recommendations (~1 min) |
generate_design | Generate a design from explicitly named patterns or a prior analyze_design payload (~1 min) |
evaluate_design | Score an existing design JSON against the eight quality axes (~30 s) |
submit_design_job | Start background job, get job_id immediately — for clients with short timeouts |
get_design_status | Poll job status; returns full DesignResult when completed |
cancel_design | Cancel a running job (best-effort, takes effect at next stage boundary) |
list_design_patterns | List all 486 patterns; filter by category and/or language |
get_design_pattern | Get full JSON for a specific pattern (alias-aware) |
Example call:
Call select_design_patterns with:
description: "IoT ingestion path: Kafka consumer (10k events/sec) → JSON parse → Redis geo-enrich → InfluxDB + S3 sink. At-least-once, backpressure."
language: "python"
| Prompt | Args | What it does |
|---|---|---|
/select_design_patterns_workflow | description*, language, architecture_style, paradigm, focus | Guided end-to-end selection workflow |
/explore_pattern_catalog | category | Live catalog discovery |
/evaluate_my_design | description* | Compare the catalog's selection against an existing design |
/compare_pattern_candidates | decision*, candidates* | Two or three named patterns side-by-side (one selection run per candidate) |
* = required
Tool-only clients (no native prompts/list) reach the same four workflows via the generated list_prompts / get_prompt tools.
test -f docker/docker-compose.yml)docker compose version), Docker group membership, ≥ 18 GB free (MCP ≈ 1 GB with baked dense cache, TEI ≈ 14 GB)-gpu TEI pair; CPU-only hosts build the -cpu pair locally instead (make docker-build-tei-cpu)OPENCODE_API_KEY); any LiteLLM-compatible provider works (OpenAI, Anthropic, MiniMax, DeepSeek, Ollama, vLLM, OpenRouter, …)make docker-build-baseselect_design_patterns runs a multi-stage LLM pipeline that takes minutes per call (2–10 min) — the generator LLM processes fused retrieval candidates plus per-part quality weights and emits a large strictly-structured JSON document; the design loop repeats generate → evaluate up to LOOP_MAX_TRIES times.
MCP clients implement client-side idle timeouts (typically 30–120 s). If no data is received, the client aborts — even though the server is still working correctly.
| Client | Timeout | Notes |
|---|---|---|
| Claude Desktop (TS-SDK) | 60 s | Hardcoded; does not reset on progress |
| Cursor (TS-SDK) | 60 s | Same as Claude Desktop |
| Claude Code | ~300 s | Heartbeat every 30 s resets idle timer |
| OpenCode | ~300 s | Heartbeat every 30 s resets idle timer |
| Codex CLI | ~300 s | Heartbeat every 30 s resets idle timer |
Heartbeat defence (default) — The server emits progress notifications every 30 s (TASKS_HEARTBEAT_INTERVAL_SECONDS), resetting idle timers for most HTTP clients. TS-SDK clients do not reset on progress — use the job trio.
Async job trio — For timeout-constrained clients (Claude Desktop, Cursor), use submit_design_job + get_design_status + cancel_design. Returns a job_id immediately; poll every 10–30 s. Jobs persist in SQLite (JOBS_DB) and survive server restarts.
Direct HTTP client — make client-analyze / make client-design / make client-async bypass the MCP SDK entirely with no idle timeout (override the target with CLIENT_URL).
Two paths (full runbook: INSTALL.md). Pick exactly one — they use fixed distinct host ports (8822 vs 8812), so both stacks can run concurrently.
| Path A — Compose stack | Path B — systemd stack | |
|---|---|---|
| Use when | evaluating / developing; no sudo | persistent host service, starts at boot |
| Host port | 8822 | 8812 |
| TEI sidecars | own copies in the compose project | shared pattern-tei-infra stack |
| Style head | own copy in the compose project | own copy in the systemd stack |
| Survives reboot | no | yes |
# 0. Clone (compose files + config template ship with the repo)
git clone https://github.com/olk/design-pattern-mcp.git && cd design-pattern-mcp
# A1. Resolve the release version and pull. All four images (MCP, TEI pair,
# style head) carry the same version tag.
VERSION=$(grep -m 1 '^version' pyproject.toml | sed -E 's/.*"([^"]+)".*/\1/')
docker pull "olkowa/design-pattern-mcp:${VERSION}"
docker pull "olkowa/pattern-tei-embed-gpu:${VERSION}"
docker pull "olkowa/pattern-tei-rerank-gpu:${VERSION}"
docker pull "olkowa/design-pattern-style-head:${VERSION}"
# If a pull 404s (tag not published), list tags and use latest:
# curl -fsS 'https://hub.docker.com/v2/repositories/olkowa/design-pattern-mcp/tags'
# A2. Write the env file next to the compose file
cat > docker/.env <<EOF
MCP_IMAGE=olkowa/design-pattern-mcp:${VERSION}
TEI_IMAGE=olkowa/pattern-tei-embed-gpu:${VERSION}
TEI_RERANK_IMAGE=olkowa/pattern-tei-rerank-gpu:${VERSION}
STYLE_HEAD_IMAGE=olkowa/design-pattern-style-head:${VERSION}
OPENCODE_API_KEY=sk-REPLACE-ME
EOF
# A3. Start. TEI sidecars cold-start model weights; first start takes ~2 min.
# (Published server images bake in the dense embedding cache; a locally
# built cache-less image instead embeds the whole catalog at first start,
# ~5 min via the GPU sidecar vs ~19 min via the CPU sidecar.)
docker compose --env-file docker/.env -f docker/docker-compose.yml up -d
# A4. Wait until all three report "healthy" (poll if still "starting").
docker inspect -f '{{.Name}} {{.State.Health.Status}}' \
design-pattern-tei-embed-dev design-pattern-tei-rerank-dev design-pattern-mcp-dev
# A5. Probe the MCP endpoint — must print 200.
# (GET /health is 404 by design; the JSON-RPC initialize POST is the probe.
# The MCP image has no curl binary; probe from the host.)
curl -s -o /dev/null -w '%{http_code}\n' -X POST "http://localhost:8822/mcp" \
-H 'Content-Type: application/json' \
-H 'Accept: application/json, text/event-stream' \
-d '{"jsonrpc":"2.0","method":"initialize","params":{"protocolVersion":"2025-03-26","capabilities":{},"clientInfo":{"name":"probe","version":"0.0.0"}},"id":1}'
The server starts on streamable-http at http://localhost:8822/mcp. Config is the repo file config/config.json (mounted at /app/config); restart the server container after editing.
Path B (systemd,
:8812, shared TEI infra,sudorequired) and uninstall steps: see INSTALL.md Path B.
Standalone stack: Path A starts its own TEI sidecar copies. If you already run the shared
pattern-tei-infrastack, you can alternatively drop the two sidecar services and pointEMBEDDER_BASE_URL/RERANKER_BASE_URLat the existing sidecars instead (or start with--profile offlinefor deterministic lexical-only retrieval with no sidecars).
CPU-only hosts: build the
-cpuTEI pair (make docker-build-tei-cpu) and append-f docker/docker-compose.cpu.ymlto the compose commands above (or runmake docker-up-cpu) — same models, shared dense cache.
The default stack uses Muse Spark 1.3 Contributor via the OpenCode Go gateway (GENERATOR_PROVIDER=opencode-go, GENERATOR_MODEL=openai/muse-spark-1.3-contributor, GENERATOR_BASE_URL=https://opencode.ai/zen/go/v1, key from OPENCODE_API_KEY, GENERATOR_SESSION_ID=design-pattern-mcp sent as x-opencode-session). To use another LiteLLM provider, edit the GENERATOR_* lines in the compose file and put your key in the env file, then restart:
- GENERATOR_PROVIDER=openai
- GENERATOR_MODEL=openai/gpt-4o-mini # LiteLLM syntax: provider/model
- GENERATOR_BASE_URL=https://api.openai.com/v1
- GENERATOR_API_KEY=${OPENAI_API_KEY}
| Provider | .env / compose additions |
|---|---|
| Muse Spark (default, OpenCode gateway) | GENERATOR_PROVIDER=opencode-go · GENERATOR_MODEL=openai/muse-spark-1.3-contributor · GENERATOR_BASE_URL=https://opencode.ai/zen/go/v1 · GENERATOR_SESSION_ID=design-pattern-mcp · key via OPENCODE_API_KEY |
| OpenAI | GENERATOR_PROVIDER=openai · GENERATOR_MODEL=openai/gpt-4o-mini · GENERATOR_BASE_URL=https://api.openai.com/v1 · GENERATOR_API_KEY=sk-... |
| Anthropic | GENERATOR_PROVIDER=anthropic · GENERATOR_MODEL=anthropic/claude-sonnet-4-5 · GENERATOR_API_KEY=sk-ant-... |
| MiniMax | GENERATOR_PROVIDER=minimax · GENERATOR_MODEL=minimax/MiniMax-M2.7 · GENERATOR_BASE_URL=https://api.minimax.io/v1 · GENERATOR_API_KEY=... |
| DeepSeek | GENERATOR_PROVIDER=deepseek · GENERATOR_MODEL=deepseek-chat · GENERATOR_BASE_URL=https://api.deepseek.com/v1 · GENERATOR_API_KEY=sk-... |
| Ollama / vLLM / OpenRouter / any OpenAI-compatible | GENERATOR_BASE_URL=http://host:11434/v1 · GENERATOR_MODEL=... · GENERATOR_API_KEY=... |
The generator LLM is accessed through the LlamaIndex LiteLLM integration (llama-index-llms-litellm). All provider settings therefore follow LiteLLM's model syntax: <provider>/<model> (e.g. openai/gpt-4o-mini, anthropic/claude-sonnet-4-5, openrouter/minimax/minimax-m2); the provider prefix lives in the model string (LiteLLM convention) while GENERATOR_PROVIDER labels error messages.
<provider>/<model> syntax: LiteLLM Providers documentationGENERATOR_BASE_URL — it is passed as the LiteLLM api_baseGENERATOR_API_KEY is passed as the LiteLLM api_key; temperature, top_p, top_k, and timeout_seconds map to the corresponding LiteLLM parametersThe MCP server reaches the sidecars by Docker DNS — these match the defaults, so no URL overrides are required in the standard stacks (Path B uses the pattern-tei-* hostnames of the shared infra stack):
| Variable | Default (Path A) | Description |
|---|---|---|
EMBEDDER_BASE_URL | http://design-pattern-tei-embed:8080 | TEI embedder URL (dev compose uses the /v1 OpenAI-compatible route) |
RERANKER_BASE_URL | http://design-pattern-tei-rerank:8080 | TEI reranker URL (POST /rerank directly, no /v1) |
DECISIONS_STYLE_BASE_URL | http://design-pattern-style-head:8800/v1 | Style-head URL (Ch2 seam; CPU sidecar) |
The embedder must be TEI serving the same model — the embedder config has no model field, so openai / ollama / vllm providers cannot address an arbitrary remote model without a code change. The reranker is not a LiteLLM client. Keep RETRIEVAL_MAX_CONCURRENT_PARTS=1 (shipped default) — one full-text rerank request already saturates the CPU sidecar's token buffer (HTTP 429 otherwise).
The Ch2 style seam is on by default in Path B and opt-in in Path A (DECISIONS_STYLE_ENABLED=true in the env file); if the sidecar is unreachable the seam degrades to the LLM style. Confidence floor: DECISIONS_STYLE_CONFIDENCE_FLOOR=0.6.
Upgrading from an older release? The
DESIGN_PATTERN_env prefix was removed — strip it from every key (DESIGN_PATTERN_GENERATOR_API_KEY→GENERATOR_API_KEY, …) and reinstallconfig/config.jsonin the same step.
Full env var reference: GitHub README → Configuration
Point at Path A (:8822) or Path B (:8812) depending on which stack you installed.
Add to ~/.config/opencode/opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"design-patterns": {
"type": "remote",
"url": "http://localhost:8822/mcp"
}
}
}
Note:
GENERATOR_API_KEYis read from the server's config file / environment, not from opencode's environment.
Add to .vscode/mcp.json:
{
"servers": {
"design-patterns": {
"url": "http://localhost:8822/mcp",
"type": "http"
}
}
}
Stdio transport — this section is for Claude Code / Codex CLI subprocess mode. It requires a local
git clone(one-time setup). If you want HTTP transport (recommended for Docker Hub users), use the Quick start above instead.
# Install (one-time)
git clone https://github.com/olk/design-pattern-mcp.git && cd design-pattern-mcp
make install
# Add to your agent
claude mcp add design-patterns \
-e GENERATOR_PROVIDER=opencode-go \
-e GENERATOR_MODEL=openai/muse-spark-1.3-contributor \
-e GENERATOR_BASE_URL=https://opencode.ai/zen/go/v1 \
-e GENERATOR_API_KEY=sk-... \
-e GENERATOR_SESSION_ID=design-pattern-mcp \
-- design-pattern-mcp --transport stdio
Stdio mode needs the TEI endpoints reachable (defaults http://design-pattern-tei-embed:8080 and the reranker URL from config/config.json) — either run the compose stack's sidecars or set EMBEDDER_BASE_URL / RERANKER_BASE_URL to your own. For a no-network smoke run, start with --offline (deterministic lexical-only retrieval instead of TEI).
Full client docs: GitHub README → Connect Your Agent
Ask your agent (or use the Inspector):
Build the cache-miss path of a geolocation enricher: look up keys in Redis, fall back to an external geo API on miss, protect the fallback with a circuit breaker and retry. Python.
This should call select_design_patterns with:
description: "cache-aside enrichment with Redis fallback, circuit-breaker + retry on the miss path"language: "python"Expect a circuit-breaker + retry design with participants, implementation_steps, and a Python code_sketch bound to the catalog variant. Sibling workflow: run the architecture-pattern-mcp server first for the system shape (pipe-and-filter ETL: Kafka source → parser filter → enricher → InfluxDB/S3 sinks), then bring each component's internals here.
# Update images (re-resolve VERSION first, then pull + restart)
docker compose --env-file docker/.env -f docker/docker-compose.yml pull
docker compose --env-file docker/.env -f docker/docker-compose.yml up -d
# View logs
docker compose --env-file docker/.env -f docker/docker-compose.yml logs -f design-pattern-mcp
# Stop (keep the env file — it holds the API key)
docker compose --env-file docker/.env -f docker/docker-compose.yml down
On Linux with a shared host, restrict your env file:
chmod 600 docker/.env
| Symptom | Fix |
|---|---|
GET /health returns 404 | Expected — FastMCP streamable-http exposes no GET /health. Probe POST /mcp (Quick start A5). |
401 Unauthorized from LLM, or every LLM call returns ERR_009 | Check the API key in docker/.env; verify the key is active and the GENERATOR_* provider block matches it. An env file from an older release still uses the removed DESIGN_PATTERN_ prefix — strip it from every key. |
| TEI connection errors / unhealthy sidecars | TEI cold-starts model weights (~2 min, start_period: 120s) — recheck health after ~2 min; verify sidecar containers are running and design-pattern-tei-embed resolves on the compose network |
| MCP unhealthy for many minutes; logs show dense-cache re-embed | Cache-less image embeds the whole catalog at first start (~5 min via GPU, ~19 min via CPU) — wait, or rebuild with make docker-build (bakes the cache) |
| Reranker HTTP 429 "Model is overloaded" | One full-text rerank request saturates the CPU sidecar's token buffer — keep RETRIEVAL_MAX_CONCURRENT_PARTS=1 (shipped default) |
| Tool calls rejected for ~60 s after 3 transport failures | Circuit breaker open (GENERATOR_CIRCUIT_BREAKER_* knobs) — check the provider key/endpoint, then wait out the cooldown |
Image pull fails for ${VERSION} | Tag not published; list tags at https://hub.docker.com/v2/repositories/olkowa/design-pattern-mcp/tags and use latest |
:8060 / :8822): architecture-pattern-mcpdocker pull olkowa/design-pattern-mcp:latest