agent-pattern-mcp
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@agent-pattern-mcpDesign a multi-agent research system using the supervisor-worker pattern for tool-use tasks."
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
agent-pattern-mcp
MCP server that provides AI agent pattern expertise: generate, analyze, and evaluate agent system designs against a curated catalog of 61 agent patterns (ReAct, supervisor-worker, reflexion, self-RAG, LLMCompiler, and more).
Table of Contents
Related MCP server: Design-Pattern-MCP
ā” Quickstart
# 1. Clone
git clone https://github.com/olk/agent-pattern-mcp.git && cd agent-pattern-mcp
# 2. Add your API key (the dev compose pins GENERATOR_PROVIDER=minimax and
# loads docker/.env ā not the repo-root .env)
echo 'MINIMAXAI_API_KEY=sk-...' > docker/.env
# 3. Build the images once (TEI model weights are baked in at build time,
# ~5 GB download on the first run), then start the stack
make docker-build-all
make docker-up
# 4. Demo
make clientš Connect Your Agent
Claude Code
# Install (one-time)
npm install -g @anthropic-ai/claude-code
# Run as stdio subprocess ā pass API key via env
GENERATOR_API_KEY=sk-... claude mcp add agent-pattern-mcp -- python -m src.main --transport stdioOpenCode
# Terminal 1: start the server
make docker-up
# or locally:
uv run python -m src.main
# Terminal 2: add to ~/.config/opencode/opencode.json{
"mcp": {
"agent-pattern-mcp": {
"type": "remote",
"url": "http://localhost:8061/mcp",
"enabled": true
}
}
}Codex CLI
# Install (one-time)
brew install codex
# Add to ~/.codex/config.toml[mcp_servers.agent-pattern-mcp]
url = "http://localhost:8061/mcp"Use the Tools
Design your first agent system
Ask your agent (or call the tool directly):
Use design_agent_system to design a research assistant that combines web search with sandboxed code execution for multi-hop questions. Domain: tool-use-tasks.
The tool runs the full pipeline ā analyze (pattern retrieval + requirements-weighted scoring) ā generate (LLM structured output) ā evaluate (metric scoring) ā refine (bounded retry loop) ā and returns a complete AgentSystemDesign with agents, relationships, tool contracts, and quality scores.
Explore the pattern catalog
List all agent patterns in the tool_use category.
Get the full JSON of the react pattern.
Async job pattern: submit_agent_design_job + get_agent_design_status
ONLY for clients with short request timeouts (Cursor, Claude Desktop, TS-SDK). The default is design_agent_system with heartbeat defence. submit_agent_design_job returns a job_id immediately; poll get_agent_design_status until done:
submit_agent_design_job(requirements, domain, override_topology) ā job_id
get_agent_design_status(job_id) ā {status, result, error}
cancel_agent_design(job_id) ā {cancelled, status}submit_agent_design_job returns a job_id in milliseconds. The pipeline runs in a background task. Poll get_agent_design_status(job_id) every 10ā30 seconds. When status is completed, the full design is in the result field. Cancellation is best-effort ā the job exits at the next pipeline stage boundary.
This is the only fix that works for TS-SDK clients (Claude Desktop, Cursor).
The job store is SQLite at ~/.config/agent-pattern-mcp/jobs.db (configurable via AGENT_PATTERN_JOBS_DB).
š ļø Tools at a Glance
Tool | Description |
| Full pipeline: analyze ā generate ā evaluate ā refine. Returns complete design + evaluation + quality metrics. Long-running (5ā10 min); use this unless your client has a short request timeout. |
| Analyse requirements and derive agent pattern recommendations using pattern matching and domain similarity. Long-running (LLM call). Not idempotent. |
| Generate an agent system design from requirements, topology, domain, and selected patterns. Long-running (LLM call). Not idempotent. |
| Evaluate an agent system design against specified criteria and domain using pattern benchmarking. Long-running (LLM call). Not idempotent. |
| List all 61 patterns; filter by |
| Get full JSON for a specific pattern by name |
| Start a background design job and return a |
| Poll job status. Returns the current status, progress message, and the full design output when |
| Cancel a running job (best-effort; takes effect at the next pipeline stage boundary; may take up to one LLM call). |
š¬ Prompts
The server also exposes four user-invoked workflow prompts (slash commands in clients that support them):
Prompt | Args | What it does |
|
| Full analyze ā generate ā evaluate pipeline |
|
| Live catalog discovery with embedded pattern names |
|
| Guide evaluation criteria + finding prioritisation |
|
| Two designs side-by-side; ~2Ć token cost |
* = required argument
Tool-only clients
In tool-only clients, the prompts are also exposed as tools via FastMCP's PromptsAsTools transform ā you can call them like any other tool.
š§āš« SKILL for AI Agents
AI coding agents (Claude Code, OpenCode, Codex CLI) can load a SKILL that teaches them how and when to use this server's tools ā including timeout-aware entry-point selection, output interpretation, and the full workflow recipe.
The SKILL lives in skills/agent-pattern-mcp/:
skills/agent-pattern-mcp/
āāā SKILL.md # Discovery, critical rules, decision guide
āāā references/
āāā tools.md # All 9 tool signatures and output schemas
āāā workflows.md # 4 worked examples, 4 prompts, best practicesFor agents that support file-based skills (OpenCode, Claude Code): point the agent's skill loader at skills/agent-pattern-mcp/SKILL.md. The skill tells the agent:
Which tool to use based on client type and timeout budget
How to phrase
requirements,domain, andtopologyas separate structured argumentsHow to interpret
final_quality_score,attempts > 1, andevaluation.recommendationsWhen to use the async job trio vs
design_agent_systemdirectly
š Pattern Catalog
61 agent patterns across 10 categories (reasoning, tool_use, planning, reflection, research_synthesis, multi_agent, memory, retrieval, safety_control, observability) and 8 topologies (single-agent-loop, hierarchical, pipeline, plan-execute, parallel-fan-out, evaluator-loop, graph-orchestrated, swarm).
Via MCP tools (recommended ā works in all clients)
list_agent_patterns(category="multi_agent")
get_agent_pattern(name="supervisor-worker")Via MCP resources
pattern:// ā list of all patterns
pattern://{name} ā full pattern JSON
template://{name} ā curated design templates (react, supervisor-worker, multi-agent-debate, agentic-rag)
component://{type} ā component blueprints derived from pattern dataPattern JSON structure
Each pattern/*-pattern.json file contains: name, category, topology, context, benefits, tradeoffs, quality_attributes (7 dims, 1-10), suitable_domains, unsuitable_domains, use_cases, avoid_when, component_types, technology_stack, anti_patterns, migration_from, migration_to, design_principles, best_practices, references.
Install Alternatives
Docker (manual)
# Build the image
docker build --target production -f Dockerfile -t agent-pattern-mcp:latest .
# Run with your API key
docker run -p 8061:8051 --env-file .env agent-pattern-mcp:latestDocker Hub image (compose)
Pull olkowa/agent-pattern-mcp without building. The hub compose starts the
MCP server only; start the TEI sidecars (olkowa/pattern-tei-embed,
olkowa/pattern-tei-rerank) separately and wire them via EMBEDDER_BASE_URL
/ RERANKER_BASE_URL:
TAG=latest docker compose -f docker/docker-compose.hub.yml up -dLocal Development (uv)
# Install
uv sync
# Configure
mkdir -p ~/.config/agent-pattern-mcp
cp config/config.json ~/.config/agent-pattern-mcp/
# Edit ~/.config/agent-pattern-mcp/config.json and set your GENERATOR_API_KEY
# Run the server
uv run python -m src.mainConfiguration
config.json
See config/config.json for the full annotated example. Key sections:
generator ā single LLM configuration: provider, model, temperature. Serves all pipeline phases (planning, generation, reflection).
embedder ā TEI (default), OpenAI, or Ollama embeddings for dense retrieval.
retrieval ā hybrid BM25 + dense fusion tuning: top-k caps, fusion mode (
simple/reciprocal_rerank), reranker settings, quality thresholds, blend weights, topology score threshold.validation ā self-healing retry loop settings (max_retries, retry_on_fail).
tasks ā heartbeat settings for long-running tools:
heartbeat_enabledandheartbeat_interval_seconds.pattern_directory ā where
*-pattern.jsonfiles are loaded from. Defaults to~/.config/agent-pattern-mcp/patternfor local runs; the Docker image setsPATTERN_DIRECTORY=/app/pattern, the baked 61-pattern catalog.
Generator LLM (LlamaIndex LiteLLM)
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 server composes the LiteLLM model string from your configuration as generator.provider + generator.config.model:
Config / env | Example | Resulting LiteLLM model string |
|
|
|
|
|
|
|
|
|
If the configured model already contains a provider prefix (e.g. openai/gpt-4o-mini), that prefix is stripped and replaced by the configured provider.
Provider list, model names, and the exact
<provider>/<model>syntax: LiteLLM Providers documentationCustom/OpenAI-compatible endpoints (proxies, vLLM, Ollama, ā¦): set
GENERATOR_BASE_URL(generator.config.base_url) ā it is passed as the LiteLLMapi_baseGENERATOR_API_KEYis passed as the LiteLLMapi_key;temperature,top_p,top_k, andstreammap to the corresponding LiteLLM parameters
Key environment variables
A single LLM configuration ā generator ā serves all pipeline phases (planning, generation, reflection). Legacy PLANNER_* / REFLECTOR_* variables and config sections were removed; configs containing them are rejected with an error.
Variable | Default | Purpose |
| (required) | LLM provider API key (passed to LiteLLM as |
|
| LiteLLM provider prefix: |
|
| Model name; final model string is |
|
| LLM temperature (all phases) |
|
| Embedder provider |
|
| TEI endpoint |
|
| Fusion mode |
|
| Enable TEI cross-encoder reranking |
|
| Reranker endpoint |
|
|
|
|
| HTTP port |
|
| Enable heartbeat progress notifications during long tool calls |
|
| Heartbeat interval in seconds (keep below client idle timeout) |
|
| SQLite path for async job state (job trio); ephemeral in Docker |
CLI flags
python -m src.main --config-path /path/to/config.json \
--transport stdio \
--host 0.0.0.0 \
--port 8051 \
--healthExtending with Custom Patterns
Create
~/.config/agent-pattern-mcp/pattern/my-pattern-pattern.json:
{
"name": "my-pattern",
"topology": "single-agent-loop",
"category": "tool_use",
"context": "When to use this pattern ā problem context and forces",
"benefits": ["..."],
"tradeoffs": ["..."],
"quality_attributes": {
"reliability": 7, "cost_efficiency": 6, "latency": 7,
"output_quality": 8, "observability": 6, "safety": 7, "simplicity": 8
},
"suitable_domains": ["tool-use-tasks"],
"use_cases": ["..."],
"avoid_when": ["..."],
"component_types": ["Planner: decomposes tasks"],
"technology_stack": ["LiteLLM"],
"anti_patterns": ["..."],
"design_principles": ["..."],
"best_practices": ["..."]
}Set
PATTERN_DIRECTORYorpattern_directoryin config to point at the directory (or place files in the repo'spattern/dir).Restart the server. Invalid files are skipped with a warning (lenient loading); valid ones appear in
list_agent_patternsimmediately.
Troubleshooting
Server starts but tools are not visible
Verify the client config URL matches
http://localhost:8061/mcp(note the/mcppath; dev default port is 8061, systemd uses 8051).Check
docker compose logs agent-pattern-mcpfor startup errors.
"Connection refused" or timeout errors
The server binds
0.0.0.0:8051by default (in-container). If Docker is used, the dev compose publishes on host port 8061 ("${MCP_HOST_PORT:-8061}:8051"); systemd uses 8051.
LLM provider errors (502 / 401)
GENERATOR_API_KEYmust be set (via.env, environment, or config).For MiniMax:
GENERATOR_PROVIDER=minimax,GENERATOR_MODEL=minimax/MiniMax-M2.7,GENERATOR_BASE_URL=https://api.minimax.io/v1.
Pattern JSON files not loading
Files must match
*-pattern.jsonand contain all required fields (name,context,category,topology,suitable_domains,quality_attributeswith all 7 keys).Check the startup log for
Pattern validation failedwarnings.
Async jobs not persisting across container restarts
jobs.dblives at~/.config/agent-pattern-mcp/jobs.dbinside the container; it is ephemeral (lost on restart). Restarting a container discards in-flight and completed jobs. To persist jobs across restarts, mount a volume and setAGENT_PATTERN_JOBS_DBto point at it.
Long-running tools & timeouts
design_agent_system (and to a lesser extent analyze_agent_system, generate_agent_system, evaluate_agent_system) run multi-stage LLM pipelines that can take 5ā10 minutes per call. This is inherent to the workload, not a bug: the generator LLM must process a large input payload ā the selected pattern definitions from the 61-pattern catalog, your requirements, and the full output of every previous stage ā and produce a large, strictly structured JSON document (agents, relationships, tool contracts, quality scores) one token at a time. The design_agent_system pipeline repeats generate ā evaluate up to three times, so a single call can comprise 9+ LLM round trips.
The timeout problem
MCP clients (AI coding agents, MCP SDKs) sit between the server and the LLM. Many implement a client-side idle timeout: if no data is received on the HTTP connection for some period (typically 30ā120 seconds), the client aborts the request. The server is still working ā the LLM is still generating ā but the client closes the connection and reports a timeout error to the agent.
This is a client-side behaviour, not a server-side one. The server processes the full request correctly; the client simply gives up before the response arrives.
Affected clients (hardcoded short timeouts):
Client | Timeout | Notes |
Claude Desktop (TS-SDK) | 60 s | Hardcoded; does not reset on progress notifications |
Cursor (TS-SDK) | 60 s | Same as Claude Desktop |
Other TS-SDK based agents | varies | Most cap at 60ā120 s |
These clients cannot be reconfigured to accept longer timeouts ā the timeout is baked into the SDK.
Clients covered by the heartbeat defence:
Client | Timeout | Defence |
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 |
Other HTTP-transport agents | varies | Most reset on any received data |
Works for these because their idle timers are reset by any incoming data ā the heartbeat progress notifications sent from a parallel async task on the server are received by the client, resetting its clock.
The heartbeat defence (applied by default)
Every long-running tool emits progress notifications from a parallel coroutine every 30 seconds (configurable via TASKS_HEARTBEAT_INTERVAL_SECONDS). As long as the client resets its idle timer on any received data, the request stays alive for the full duration of the pipeline.
TS-SDK clients (Claude Desktop, Cursor, etc.) do not reset their timeout on progress notifications.
The async job trio (for timeout-constrained clients)
For full control and compatibility with timeout-limited clients, three tools provide a durable job handle:
submit_agent_design_job(requirements, domain, override_topology) ā job_id
get_agent_design_status(job_id) ā {status, result, error}
cancel_agent_design(job_id) ā {cancelled, status}submit_agent_design_job returns a job_id in milliseconds. The pipeline runs in a background task. Poll get_agent_design_status(job_id) every 10ā30 seconds. When status is completed, the full design is in the result field. Cancellation is best-effort ā the job exits at the next pipeline stage boundary.
This is the only fix that works for TS-SDK clients (Claude Desktop, Cursor).
Bypassing client timeouts entirely: make client
The example client in examples/agent_client.py is a direct Python HTTP client ā it is not an MCP agent. It calls the server over HTTP without any MCP SDK, and therefore has no client-side idle timeout. It makes a single blocking request and waits for the full response, regardless of how long it takes.
# Start the server (from project root; builds first if images are missing)
make docker-build-all && make docker-up
# In another terminal, run the example client
make clientmake client is a development/demo tool. It demonstrates that the server correctly completes long requests ā the timeout issue is purely a client-side problem. For production use with MCP agents, the heartbeat defence covers the majority of clients; the async job trio is the universal fallback.
Verification Program
The repo carries a layered verification program (see docs/verification.md and docs/testing-strategies.md):
Layer | What it proves | Entry point |
L1 | unit suite (behavioral oracle) + secret canary |
|
L1b | MCP tool-surface boundary fuzz |
|
L2 | Hypothesis property oracles over the decision modules |
|
L3 | mutation testing (mutmut ratchet) + planted-bug garden |
|
L4 | FizzBee exhaustive model checks + FG spec garden |
|
L6 | deterministic-simulation races over the jobs store |
|
L8 | property-ID ledger + NL-Doc cross-consistency |
|
L9 | structural invariants over LLM output (opt-in live pipeline) |
|
L10 | perf smoke canary (RUN_PERF=1) | nightly workflow |
Fast gates: make check-all (lint + types + dead code + deps) and
make test-all (unit + oracles). The nightly canary lives in
.github/workflows/verification.yml.
Building & Development
make install # uv sync (dev deps included)
make check-lint # ruff check
make check-static-typing # mypy --strict
make test-unit # pytest tests/unit/ with coverage
make test-oracles # executable verification oracles
make docker-build-all # MCP + TEI + TEI-rerank imagesmake install # uv sync (dev deps included)
make lint # ruff check
make typecheck # mypy --strict (alias for static-typing)
make unit-tests # pytest tests/unit/
make docker-build-all # MCP + TEI + TEI-rerank imagesPublishing
Images publish to Docker Hub (olkowa/*) and GHCR (ghcr.io/olk/*).
Prerequisites
Docker Hub and GHCR (
docker login) access.
Publish (one-time setup + per-session)
# 1. Login to GHCR (interactive ā paste token at the password prompt)
docker login ghcr.io -u olk
# 2. Build and push all three images (MCP + TEI embedder + TEI reranker)
make docker-publish-all
# 3. Logout from GHCR immediately after publishing
docker logout ghcr.ioThe docker-publish target also creates and pushes an annotated git tag v$(VERSION).
First push ā set packages public (GHCR only)
New GHCR packages default to private. Visit github.com/users/olk/packages, open each package ā Package settings ā Change visibility ā Public.
systemd Service (Linux)
See systemd/README.md for the full guide: file layout, install steps, day-to-day commands, updating, and uninstall. Summary:
Prerequisite: The shared TEI infra stack must be installed first ā see
~/Projekte/Python/tei-infra/README.md. The systemd MCP stack joins thetei-sharedexternal network to reach the embedder/reranker.
# 0. Install + enable shared TEI infra (once)
sudo install -m 644 ~/Projekte/Python/tei-infra/pattern-tei-infra.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now pattern-tei-infra.service
# 1. Build images (once)
make docker-build-all
# 2. Deploy /etc/agent-pattern-mcp/
sudo install -d /etc/agent-pattern-mcp/config
sudo install -m 644 systemd/docker-compose.yml /etc/agent-pattern-mcp/
sudo install -m 644 ~/.config/agent-pattern-mcp/config.json /etc/agent-pattern-mcp/config/
# 3. Create the .env file (root:docker 640) and edit it.
sudo install -o root -g docker -m 640 /dev/null /etc/agent-pattern-mcp/.env
sudo $EDITOR /etc/agent-pattern-mcp/.env
# Contents:
# MINIMAXAI_API_KEY=sk-...
# COMPOSE_PROJECT_NAME=apmcp-systemd
# MCP_HOST_PORT=8051
# 4. Install and enable the service.
sudo install -m 644 systemd/agent-pattern-mcp.service /etc/systemd/system/
sudo systemctl daemon-reload
sudo systemctl enable --now agent-pattern-mcp.serviceLicense
MIT ā see LICENSE.
This server cannot be deployed
Maintenance
Related MCP Connectors
Design intelligence for coding agents: audits, design systems, and a taste profile agents consult.
Curated knowledge API for AI agents - skill packs, semantic search, validated patterns.
Agent-first resource directory for AI agents: protocols, security, RAG, memory, evals, and more.
Codebase intelligence for agents: 152 structured artifacts across 21 programs, one call.
Related MCP Servers
- AlicenseAqualityDmaintenanceAn architecture consulting server that reviews multi-agent systems against a knowledge graph of patterns derived from expert literature. It provides grounded recommendations with chapter citations, maturity scoring, and interactive architecture diagrams to identify and fix structural gaps.175AGPL 3.0
- AlicenseAqualityDmaintenanceProvides design pattern templates and anti-pattern guidance to AI coding agents for correct pattern implementation.2MIT
- FlicenseAqualityBmaintenanceGives coding agents a memory of codebases by searching repositories using semantic similarity and structural call/import graphs, enabling reuse of proven patterns and reducing token usage.61-
- AlicenseNot gradedqualityAmaintenanceProvides architecture design expertise to AI coding agents, analyzing requirements, selecting architecture patterns, generating concrete designs, and evaluating quality attributes.MIT