ensemble-mcp docs
Presentation GitHub

Tool Reference

Complete reference for all 19 MCP tools provided by ensemble-mcp, grouped by category. Every tool returns the standard response envelope.

Response Envelope

All tools return a JSON object with this structure:

{
  "ok": true,
  "data": { ... },
  "error": null,
  "meta": {
    "duration_ms": 5,
    "source": "sqlite",
    "confidence": "exact"
  }
}

On error:

{
  "ok": false,
  "data": null,
  "error": {
    "code": "VALIDATION_MISSING_FIELD",
    "message": "...",
    "retryable": false,
    "details": { ... }
  },
  "meta": { ... }
}

Tool Categories

graph TD subgraph Memory["Pattern Memory"] PS[patterns_search] PT[patterns_store] PP[patterns_prune] end subgraph Drift["Drift Detection"] DC[drift_check] end subgraph Routing["Model Routing"] MR[model_recommend] end subgraph Skills["Skill Intelligence"] SD[skills_discover] SS[skills_suggest] SG[skills_generate] end subgraph Session["Session Management"] SV[session_save] SL[session_load] SR[session_search] end subgraph Indexer["Codebase Indexer"] PI[project_index] PQ[project_query] PD[project_dependencies] PX[project_snapshot] end subgraph Compress["Context Optimization"] CC[context_compress] CP[context_prepare] end subgraph Utility["Utility"] H[health] R[reset] end style Memory fill:#2563eb,color:#fff style Drift fill:#dc2626,color:#fff style Routing fill:#7c3aed,color:#fff style Skills fill:#059669,color:#fff style Session fill:#d97706,color:#fff style Indexer fill:#0891b2,color:#fff style Compress fill:#4f46e5,color:#fff style Utility fill:#64748b,color:#fff

Pattern Memory (3 tools)

Search stored patterns by semantic similarity. Returns top-K matches above the minimum score threshold. Increments match_count and updates last_matched_at on returned patterns (used by patterns_prune to identify unused patterns).

Supports progressive disclosure via detail_level and category filtering via category. Results include token_count metadata (approximate token cost of the pattern text).

ParameterTypeRequiredDefaultDescription
querystringyesSemantic search query
top_kintegerno3Max results (1–100)
projectstringnoOptional project scope
detail_levelstringno"full""index" for compact metadata only; "full" for complete pattern text
categorystringnoFilter by category: gotcha, problem-solution, how-it-works, what-changed, discovery, decision, trade-off, general
idempotency_keystringnoOptional idempotency key

Response data (detail_level="full"):

{
  "matches": [
    {
      "id": 1,
      "name": "pattern-name",
      "context": "when this applies",
      "approach": "what was done",
      "outcome": "what happened",
      "category": "problem-solution",
      "score": 0.85,
      "token_count": 42
    }
  ]
}

Response data (detail_level="index"):

{
  "matches": [
    {
      "id": 1,
      "name": "pattern-name",
      "category": "problem-solution",
      "score": 0.85,
      "token_count": 42
    }
  ]
}

patterns_store

Store a new pattern from a successful pipeline for future semantic search. The pattern text is embedded using the ONNX model and stored in SQLite.

ParameterTypeRequiredDefaultDescription
namestringyesShort pattern name
contextstringyesWhen this pattern applies
approachstringyesWhat approach was used
outcomestringyesWhat happened (success/failure)
projectstringnoOptional project scope
categorystringno"general"Pattern category: gotcha, problem-solution, how-it-works, what-changed, discovery, decision, trade-off, general
idempotency_keystringnoOptional idempotency key

Response data:

{
  "id": 42,
  "stored": true,
  "category": "problem-solution"
}

patterns_prune

Remove old/unused patterns (zero match_count, older than max_age_days).

ParameterTypeRequiredDefaultDescription
max_age_daysintegerno90Max age in days (1–3650)
idempotency_keystringnoOptional idempotency key

Response data:

{
  "pruned": 5,
  "remaining": 42
}

Drift Detection (1 tool)

drift_check

Check if code changes drift from the original task. Embeds both the task description and the diff summary, then computes cosine similarity. Returns a 0–1 score (0 = no drift, 1 = complete drift) with specific flags and a verdict.

Also flags suspicious file changes (migrations, configs, etc.) that don't match the task description.

ParameterTypeRequiredDefaultDescription
task_descriptionstringyesThe original task being worked on
changed_filesarray[string]yesList of changed file paths
diff_summarystringyesSummary of the code changes
idempotency_keystringnoOptional idempotency key

Response data:

{
  "score": 0.25,
  "similarity": 0.75,
  "flags": ["Unexpected file change: migrations/001.sql"],
  "verdict": "aligned"
}

Verdicts:

Results are persisted to the drift_history table for dashboard viewing.


Model Routing (1 tool)

model_recommend

Recommend a model tier (best/mid/cheapest) for an agent and task. Uses a rule-based routing table mapping (agent, classification) pairs to tiers.

ParameterTypeRequiredDefaultDescription
agentstringyesAgent name (e.g., craft, scope, signal)
task_classificationstringyestrivial, simple, standard, or complex
task_descriptionstringnoReserved for future routing logic
idempotency_keystringnoOptional idempotency key

Response data:

{
  "tier": "best",
  "reason": "Complex task requiring strongest reasoning capability",
  "agent": "craft",
  "classification": "complex"
}

Routing table (built-in agents):

Agenttrivialsimplestandardcomplex
signalcheapestcheapestcheapestcheapest
proofcheapestcheapestmidmid
lenscheapestcheapestmidmid
craftmidmidbestbest
scopemidmidbestbest
ensemblemidmidbestbest
tracemidbestbestbest

Unknown agents default to mid tier.


Skill Intelligence (3 tools)

skills_discover

Scan tool-native skill locations and return relevant skills via semantic search. Scans these directories:

Uses mtime-based caching — file reads and embedding computation are skipped for unchanged files.

ParameterTypeRequiredDefaultDescription
project_pathstringyesAbsolute path to the project
querystringnoOptional semantic search query
idempotency_keystringnoOptional idempotency key

Response data:

{
  "detected": [
    {
      "name": "my-skill",
      "source_tool": "opencode",
      "path": ".opencode/skills/my-skill/SKILL.md",
      "confidence": 0.85
    }
  ],
  "snippets": [
    {
      "content": "First 500 chars of skill content...",
      "relevance": 0.85
    }
  ]
}

skills_suggest

Detect recurring patterns and suggest them as reusable skills. Clusters patterns by embedding similarity (≥ 0.75 threshold) and proposes clusters with ≥ min_cluster_size members as skill suggestions.

ParameterTypeRequiredDefaultDescription
project_pathstringyesAbsolute path to the project
min_cluster_sizeintegerno3Minimum cluster size (2–50)
stale_threshold_daysintegerno60Days before a skill is stale (1–3650)
idempotency_keystringnoOptional idempotency key

Response data:

{
  "suggestions": [
    {
      "id": 1,
      "pattern_ids": [5, 12, 18],
      "theme": "Cluster of 3 similar patterns",
      "confidence": 0.82,
      "proposed_name": "testing-patterns-api",
      "proposed_content": "# testing-patterns-api\n..."
    }
  ],
  "stale_skills": [
    {
      "path": ".ai/skills/old-skill.md",
      "last_matched_at": "2025-01-15T10:00:00",
      "days_unused": 90
    }
  ]
}

skills_generate

Accept, dismiss, or defer a skill suggestion.

ParameterTypeRequiredDefaultDescription
suggestion_idintegeryesSuggestion ID (≥ 1)
actionstringnoacceptaccept, dismiss, or defer
output_dirstringno.ai/skills/Directory for generated skill file
idempotency_keystringnoOptional idempotency key

Response data (accept):

{
  "generated": true,
  "path": ".ai/skills/testing-patterns-api.md",
  "content": "# testing-patterns-api\n...",
  "status": "accepted"
}

Response data (dismiss/defer):

{
  "generated": false,
  "status": "dismissed"
}

Session Management (3 tools)

session_save

Save pipeline checkpoint state with optimistic versioning. If version is provided, it must match the current database version (otherwise CONFLICT_VERSION_MISMATCH is raised). When original_request is provided, an embedding is generated for semantic search via session_search.

ParameterTypeRequiredDefaultDescription
session_idstringyesUnique session identifier
stateobjectyesPipeline state to checkpoint
versionintegernoExpected version for optimistic lock
original_requeststringnoUser's original request (enables semantic search)
decisionsarray[string]noKey decisions made during the pipeline
completed_stepsarray[string]noSteps completed so far
remaining_stepsarray[string]noSteps remaining to complete
files_changedarray[string]noFiles modified during the pipeline
errorsarray[string]noErrors encountered during the pipeline
context_for_resumestringnoKey context needed to resume without re-deriving
task_classificationstringnotrivial, simple, standard, or complex
statusstringnorunningPipeline status (pending, running, completed, failed, killed)
projectstringnoProject path for scoped search
idempotency_keystringnoOptional idempotency key

Response data:

{
  "saved": true,
  "version": 3
}

session_load

Load latest or specific pipeline checkpoint.

ParameterTypeRequiredDefaultDescription
session_idstringnoLoad specific session. Omit for latest.

Response data (found):

{
  "found": true,
  "session_id": "abc-123",
  "state": { ... },
  "version": 3,
  "original_request": "Add user authentication",
  "task_classification": "standard",
  "status": "running",
  "project": "/path/to/project"
}

Response data (not found):

{
  "found": false
}

Search sessions by semantic similarity. Embeds the query and compares against stored session embeddings using cosine similarity.

ParameterTypeRequiredDefaultDescription
querystringyesSemantic search query
top_kintegerno5Max results (1–100)
projectstringnoFilter by project
statusstringnoFilter by status (e.g., running, completed)
idempotency_keystringnoOptional idempotency key

Response data:

{
  "matches": [
    {
      "session_id": "abc-123",
      "score": 0.82,
      "version": 3,
      "created_at": "2025-03-15T10:00:00",
      "original_request": "Add user authentication",
      "task_classification": "standard",
      "status": "completed",
      "project": "/path/to/project"
    }
  ]
}

Codebase Indexer (4 tools)

project_index

Build or refresh the codebase index. Scans the filesystem, extracts language, role, exports, and imports for each file. Uses mtime-based incremental indexing.

ParameterTypeRequiredDefaultDescription
project_pathstringyesAbsolute path to the project
forcebooleannofalseForce full re-index
idempotency_keystringnoOptional idempotency key

Ignored directories: node_modules, vendor, .git, __pycache__, .mypy_cache, .ruff_cache, .pytest_cache, dist, build, .next, .nuxt, target, .tox, .venv, venv, env, .env

Ignored extensions: .pyc, .pyo, .so, .dylib, .dll, .exe, .bin, .wasm, .jpg, .jpeg, .png, .gif, .svg, .ico, .woff, .woff2, .ttf, .eot, .mp3, .mp4, .avi, .mov, .zip, .tar, .gz, .lock


project_query

Query the project index — find files by type, path pattern, or semantic query.

ParameterTypeRequiredDefaultDescription
project_pathstringyesAbsolute path to the project
querystringnoSemantic search query
file_typesarray[string]noFilter by file types (e.g., ["python", "typescript"])
path_patternstringnoGlob pattern for file paths

project_dependencies

Get the import/dependency graph for a specific file.

ParameterTypeRequiredDefaultDescription
project_pathstringyesAbsolute path to the project
file_pathstringyesRelative path to the file

project_snapshot

Generate a compact project baseline summary from the codebase index. Returns language, framework, conventions, directory structure, test setup, build tools, and key files. Results are cached with mtime-based invalidation (24-hour expiry).

ParameterTypeRequiredDefaultDescription
project_pathstringyesAbsolute path to the project
forcebooleannofalseForce regeneration even if cached
idempotency_keystringnoOptional idempotency key

Context Optimization (2 tools)

context_compress

Compress verbose natural language text into terse, token-efficient form while preserving all technical content (code blocks, URLs, file paths, headings, tables). Rule-based, zero LLM calls.

ParameterTypeRequiredDefaultDescription
textstringyesText to compress (10–100,000 chars)
idempotency_keystringnoOptional idempotency key

Response data:

{
  "compressed_text": "Compressed version...",
  "original_tokens": 500,
  "compressed_tokens": 320,
  "savings_pct": 36.0,
  "preserved_count": 15
}

context_prepare

Prepare and order prompt sections for optimal LLM cache hit rates. Sorts sections by priority (staticprojecttask) to maximize the stable prefix that LLM providers can cache across calls.

ParameterTypeRequiredDefaultDescription
sectionsarray[object]yesSections with name, content, and priority
compress_sectionsbooleannofalseCompress each section via the compression engine
idempotency_keystringnoOptional idempotency key

Each section object:

FieldTypeRequiredDescription
namestringyesSection name
contentstringyesSection content
prioritystringyesstatic, project, or task

Response data:

{
  "prepared_text": "Combined ordered text...",
  "section_count": 3,
  "prefix_stable_bytes": 1024,
  "sections": [
    {
      "name": "system-prompt",
      "priority": "static",
      "original_bytes": 500,
      "prepared_bytes": 480
    }
  ]
}

Utility (2 tools)

health

Server health check — returns status, version, database size, and pattern count.

ParameterTypeRequiredDefaultDescription
(none)No parameters

Response data:

{
  "status": "ok",
  "version": "0.1.0b4",
  "db_size_bytes": 524288,
  "pattern_count": 42,
  "server_name": "ensemble-mcp"
}

reset

Reset all stored data. Destructive — deletes all patterns, sessions, project indexes, drift history, skill suggestions, and idempotency keys.

ParameterTypeRequiredDefaultDescription
confirmbooleanyesMust be true to proceed
idempotency_keystringnoOptional idempotency key

Response data:

{
  "reset": true
}

Idempotency

All mutating tools accept an optional idempotency_key parameter. When provided:

Next Steps