An MCP server that provides blockchain design expertise to AI coding agents. Analyzes requirements, selects from 109 built-in patterns, generates concrete blockchain designs with components/API contracts, and evaluates against quality attributes.
This Docker image contains a complete MCP (Model Context Protocol) server that brings blockchain design expertise to your AI coding agents. Given a requirements string and a domain, it:
┌───────────────────────────────────────────────────────────────────┐
│ OpenCode / Claude Code / VS Code / any MCP client │
│ ────────── HTTP ──────────► :8823/mcp (Path A) │
│ or :8813/mcp (Path B) │
│ │
│ ┌──────────────────────────────┐ │
│ │ blockchain-pattern-mcp │ │
│ └───────────────┬──────────────┘ │
│ │ │
│ ┌───────────────────┼────────────────────┐ │
│ │ pattern-tei-embed │ pattern-tei-rerank │ ← own copies (A) │
│ │ :8080 (TEI) │ :8080 (TEI) │ or shared infra │
│ └───────────────────┴────────────────────┘ stack (B) │
└───────────────────────────────────────────────────────────────────┘
This image is the MCP server only. The TEI embedder (Qwen3-Embedding-0.6B) and TEI reranker (gte-reranker-modernbert-base) are
separate infrastructure (see pattern-tei-infra project)
published as
pattern-tei-embed-gpu and
pattern-tei-rerank-gpu.
All three images share the same version tag (latest plus the MCP release, e.g. 1.2.0). Both lanes are published (NVIDIA GPU, sm_61 minimum, CUDA for -gpu; the -cpu pair serves the same models with no GPU needed).
They connect via Docker DNS using the hostnames pattern-tei-embed and pattern-tei-rerank on a shared Docker network.
| Tool | Description |
|---|---|
analyze_blockchain | Analyse requirements → recommended style, patterns, quality metrics |
generate_blockchain | Generate blockchain design from requirements + selected patterns |
evaluate_blockchain | Score an existing design against quality attributes |
design_blockchain | Full pipeline (analyse → generate → evaluate → refine, up to 3 attempts). 5–10 min |
submit_blockchain_design_job | Start background job, get job_id immediately — for clients with short timeouts |
get_blockchain_design_status | Poll job status; returns full design when completed |
cancel_blockchain_design | Cancel a running job (best-effort) |
list_blockchain_patterns | List all 109 patterns; filter by category and/or domain |
get_blockchain_pattern | Get full JSON for a specific pattern |
Example call:
Call design_blockchain with:
requirements: "Constant-product AMM with TWAP oracle and reentrancy guards"
domain: "defi-trading"
| Prompt | Args | What it does |
|---|---|---|
/design_blockchain_workflow | requirements* | Full analyze → generate → evaluate pipeline |
/explore_pattern_catalog | domain, category | Live catalog discovery |
/evaluate_my_blockchain | focus | Guide evaluation criteria + prioritisation |
/compare_blockchain_styles | style_a*, style_b*, requirements* | Two designs side-by-side (~2× token cost) |
* = required
Tool-only clients (no native prompts/list) reach the same four workflows via the generated list_prompts and get_prompt tools.
test -f docker/docker-compose.yml)docker compose version), Docker group membership, ≥ 18 GB free (MCP ≈ 1 GB, TEI ≈ 14 GB)OPENCODE_API_KEY); any LiteLLM-compatible provider works (OpenAI, Anthropic, DeepSeek, Ollama, vLLM, OpenRouter, …)/var/run/cdi/nvidia.yaml); otherwise pull the published -cpu TEI pair (see the CPU note under Quick start)make docker-build-alldesign_blockchain runs multi-stage LLM pipelines that can take 5–10 minutes — the generator LLM processes large input payloads across 9+ round trips.
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_blockchain_design_job + get_blockchain_design_status + cancel_blockchain_design. Returns a job_id immediately; poll every 10–30 s. Jobs persist in SQLite (BLOCKCHAIN_PATTERN_JOBS_DB).
FastMCP client demo — make client-analyze drives the server through the FastMCP client with no client-side idle timeout.
Two paths (full runbook: INSTALL.md). Pick exactly one — both can run concurrently (distinct container names and ports).
| Path A — Compose stack | Path B — systemd stack | |
|---|---|---|
| Use when | evaluating / developing; no sudo | persistent host service, starts at boot |
| Host port | 8823 | 8813 |
| TEI sidecars | own copies in the compose project | shared pattern-tei-infra stack |
| Survives reboot | no | yes |
# 0. Clone (compose files + config template ship with the repo)
git clone https://github.com/olk/blockchain-pattern-mcp.git && cd blockchain-pattern-mcp
# A1. Resolve the release version and pull. All three images share the MCP
# version tag (verified on the Hub: latest + 1.2.0); fall back to latest
# when the version tag is not published yet.
VERSION=$(grep -m 1 '^version' pyproject.toml | sed -E 's/.*"([^"]+)".*/\1/')
PULL_TAG="${VERSION}"
for img in olkowa/blockchain-pattern-mcp olkowa/pattern-tei-embed-gpu olkowa/pattern-tei-rerank-gpu; do
docker pull "${img}:${PULL_TAG}" || PULL_FAILED=1
done
if [ "${PULL_FAILED:-0}" = 1 ]; then PULL_TAG="latest"
for img in olkowa/blockchain-pattern-mcp olkowa/pattern-tei-embed-gpu olkowa/pattern-tei-rerank-gpu; do
docker pull "${img}:${PULL_TAG}" || { echo "no Hub tag; build locally: make docker-build-all"; exit 1; }
done
fi
# A2. Write the env file next to the compose file (export your real key first —
# placeholders deploy a stack whose design calls fail with 401).
: "${OPENCODE_API_KEY:?export OPENCODE_API_KEY='sk-...' before running A2}"
cat > docker/.env <<EOF
MCP_IMAGE=olkowa/blockchain-pattern-mcp:${PULL_TAG}
TEI_IMAGE=olkowa/pattern-tei-embed-gpu:${PULL_TAG}
TEI_RERANK_IMAGE=olkowa/pattern-tei-rerank-gpu:${PULL_TAG}
OPENCODE_API_KEY=${OPENCODE_API_KEY}
MCP_HOST_PORT=8823
EOF
chmod 600 docker/.env
# A3. Sanity check: interpolation resolved (expect 3 image: lines).
docker compose --env-file docker/.env -f docker/docker-compose.yml config | grep 'image:'
# A4. Start. TEI sidecars cold-start model weights; first start takes ~2 min.
# --wait gates on all three healthchecks instead of a blind sleep.
docker compose --env-file docker/.env -f docker/docker-compose.yml up -d --wait --wait-timeout 300
# A5. Confirm all three report "healthy".
docker inspect -f '{{.Name}} {{.State.Health.Status}}' \
blockchain-pattern-tei-embed-dev blockchain-pattern-tei-rerank-dev blockchain-pattern-mcp-dev
# A6. Probe the MCP endpoint — must print 200.
# (GET /health is 404 by design; the JSON-RPC initialize POST is the probe.)
curl -s -o /dev/null -w '%{http_code}\n' -X POST "http://localhost:8823/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:8823/mcp. Config is the repo file config/config.json (mounted at /app/config); validate with python3 -m json.tool config/config.json, then restart blockchain-pattern-mcp after editing.
Path B (systemd,
:8813, shared TEI infra,sudorequired) and uninstall steps: see INSTALL.md Path B.
CPU-only hosts: pull the published
-cpupair (olkowa/pattern-tei-embed-cpu/olkowa/pattern-tei-rerank-cpu, same tag), setTEI_IMAGE_CPU/TEI_RERANK_IMAGE_CPUindocker/.env, and merge-f docker/docker-compose.cpu.ymlinto the A3/A4 commands. Same models, shared embedding-index cache.
Standalone stack: Path A starts its own TEI sidecar copies under distinct
-devcontainer names, so it coexists with the sharedpattern-tei-infrastack (different names, different ports).
The default stack uses Muse Spark 1.3 Contributor via the OpenCode Go gateway (GENERATOR_PROVIDER=openai, 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=blockchain-pattern-mcp). 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}
- GENERATOR_SESSION_ID= # gateway-only header; empty = none
| Provider | .env / compose additions |
|---|---|
| Muse Spark (default, via OpenCode Go gateway) | GENERATOR_PROVIDER=openai · GENERATOR_MODEL=openai/muse-spark-1.3-contributor · GENERATOR_BASE_URL=https://opencode.ai/zen/go/v1 · key via OPENCODE_API_KEY · GENERATOR_SESSION_ID=blockchain-pattern-mcp |
| 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-... |
| 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 server composes the LiteLLM model string as provider + / + model-suffix: if the configured model already contains a provider prefix, that prefix is stripped and replaced by the configured provider:
| Config / env | Example | Resulting LiteLLM model string |
|---|---|---|
provider: "openai", model: "gpt-4o-mini" | GENERATOR_PROVIDER=openai, GENERATOR_MODEL=gpt-4o-mini | openai/gpt-4o-mini |
provider: "openai", model: "openai/muse-spark-1.3-contributor" | GENERATOR_MODEL=openai/muse-spark-1.3-contributor | openai/muse-spark-1.3-contributor |
provider: "anthropic", model: "claude-sonnet-4-5" | GENERATOR_PROVIDER=anthropic, GENERATOR_MODEL=claude-sonnet-4-5 | anthropic/claude-sonnet-4-5 |
provider: "openrouter", model: "minimax/minimax-m2" | GENERATOR_PROVIDER=openrouter, GENERATOR_MODEL=minimax/minimax-m2 | openrouter/minimax/minimax-m2 |
<provider>/<model> syntax: LiteLLM Providers documentationGENERATOR_BASE_URL (generator.config.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 stream map to the corresponding LiteLLM parametersThe MCP server reaches the sidecars by Docker DNS (pattern-tei-embed, pattern-tei-rerank) — these match the defaults, so no URL overrides are required in the standard stacks:
| Variable | Default | Description |
|---|---|---|
EMBEDDER_BASE_URL | http://pattern-tei-embed:8080/v1 | TEI embedder URL (OpenAI-compatible route) |
RERANKER_BASE_URL | http://pattern-tei-rerank:8080 | TEI reranker URL (POST /rerank directly, no /v1) |
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.
Full env var reference: GitHub README → Configuration
Point at Path A (:8823) or Path B (:8813) depending on which stack you installed.
Add to ~/.config/opencode/opencode.json:
{
"$schema": "https://opencode.ai/config.json",
"mcp": {
"blockchain-pattern": {
"type": "remote",
"url": "http://localhost:8823/mcp"
}
}
}
Note:
GENERATOR_API_KEYis read from the server's config file / environment, not from opencode's environment.
Add to .vscode/mcp.json:
{
"servers": {
"blockchain-pattern": {
"url": "http://localhost:8823/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/blockchain-pattern-mcp.git && cd blockchain-pattern-mcp
make install
# Add to your agent (key must match the provider; example: OpenAI)
claude mcp add blockchain-pattern \
-e GENERATOR_PROVIDER=openai \
-e GENERATOR_API_KEY=sk-... \
-- blockchain-pattern-mcp --transport stdio
For the Muse Spark default over stdio, also pass -e GENERATOR_MODEL=openai/muse-spark-1.3-contributor -e GENERATOR_BASE_URL=https://opencode.ai/zen/go/v1 -e GENERATOR_SESSION_ID=blockchain-pattern-mcp.
Full client docs: GitHub README → Connect Your Agent
Ask your agent (or use the Inspector):
Design a cross-chain token bridge with fraud proofs, rate-limited mints and a light-client verifier for L2 → L1 withdrawals.
This should call design_blockchain with:
requirements: "Cross-chain bridge with fraud proofs, rate-limited mints and a light-client verifier for L2 -> L1 withdrawals"domain: "bridge"style: "lock-mint-bridge"# Update images (re-resolve the tag first, then pull + restart)
VERSION=$(grep -m 1 '^version' pyproject.toml | sed -E 's/.*"([^"]+)".*/\1/')
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 --wait --wait-timeout 300
# View logs
docker compose --env-file docker/.env -f docker/docker-compose.yml logs -f blockchain-pattern-mcp
# Stop (keep the env file — it holds the API key)
docker compose --env-file docker/.env -f docker/docker-compose.yml down
Host ports default via MCP_HOST_PORT (8823 Path A, 8813 Path B) — override it in the env file, then update your client URL. If a port is already bound, find the owner with ss -ltn | grep ':8823 '.
| Symptom | Fix |
|---|---|
GET /health returns 404 | Expected — FastMCP streamable-http exposes no GET /health. Probe POST /mcp (Quick start A6). |
401 Unauthorized from LLM | Check OPENCODE_API_KEY in docker/.env; verify the key is active and the GENERATOR_* provider block matches it |
| 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 pattern-tei-embed resolves on the compose network |
| Port already in use | Ports default via MCP_HOST_PORT (8823/8813); check ss -ltn, stop the owner or override the variable |
Image pull fails for ${VERSION} | Tag not published — the A1 block already retries with latest; list tags at https://hub.docker.com/v2/repositories/olkowa/blockchain-pattern-mcp/tags |
-cpu pair on the same Hub orgdocker pull olkowa/blockchain-pattern-mcp:latest