Skip to content

MCP Tools Reference

geoffrey fernald edited this page Feb 4, 2026 · 6 revisions

MCP Tools Reference

Drift provides 50 MCP tools organized in a 7-layer architecture designed for efficient AI agent interaction. This architecture minimizes token usage while maximizing capability β€” a model for how MCP servers should be built.

Architecture Philosophy

Drift's MCP architecture follows key principles that make it the gold standard for AI tool design:

1. Layered Tool Design

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Layer 1: ORCHESTRATION                                          β”‚
β”‚  "Tell me what you want to do, I'll give you everything"         β”‚
β”‚  drift_context, drift_package_context                            β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Layer 2: DISCOVERY                                              β”‚
β”‚  "Quick health check, what's available?"                         β”‚
β”‚  drift_status, drift_capabilities, drift_projects                β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Layer 3: SURGICAL                                               β”‚
β”‚  "I need exactly this one thing, nothing more"                   β”‚
β”‚  12 ultra-focused tools (200-500 tokens each)                    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Layer 4: EXPLORATION                                            β”‚
β”‚  "Let me browse and filter"                                      β”‚
β”‚  drift_patterns_list, drift_security_summary, etc.               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Layer 5: DETAIL                                                 β”‚
β”‚  "Deep dive into this specific thing"                            β”‚
β”‚  drift_pattern_get, drift_code_examples, etc.                    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Layer 6: ANALYSIS                                               β”‚
β”‚  "Run complex analysis"                                          β”‚
β”‚  drift_test_topology, drift_coupling, drift_error_handling       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  Layer 7: GENERATION                                             β”‚
β”‚  "Help me write/validate code"                                   β”‚
β”‚  drift_suggest_changes, drift_validate_change, drift_explain     β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

2. Token Budget Awareness

Every tool is designed with token budgets:

Layer Target Tokens Max Tokens Purpose
Orchestration 1000-2000 4000 Comprehensive context
Discovery 200-500 1000 Quick status
Surgical 200-500 800 Precise lookups
Exploration 500-1000 2000 Paginated lists
Detail 500-1500 3000 Deep dives
Analysis 1000-2000 4000 Complex analysis
Generation 500-1500 3000 Code suggestions

3. Response Structure

Every response follows a consistent structure:

{
  "summary": "One-line description of what was found",
  "data": { /* The actual payload */ },
  "pagination": {
    "cursor": "next_page_token",
    "hasMore": true,
    "totalCount": 150,
    "pageSize": 20
  },
  "hints": {
    "nextActions": ["Suggested next steps"],
    "relatedTools": ["drift_tool_1", "drift_tool_2"],
    "warnings": ["Important warnings"]
  },
  "meta": {
    "requestId": "req_abc123",
    "durationMs": 45,
    "cached": false,
    "tokenEstimate": 850
  }
}

4. Smart Caching & Rate Limiting

  • Response caching β€” Repeated queries return cached results
  • Rate limiting β€” Prevents runaway tool calls
  • Metrics collection β€” Track usage patterns

Layer 1: Orchestration

The recommended starting point. These tools understand your intent and return curated context.

drift_context

The "final boss" tool. Instead of making the AI figure out which tools to call, this tool understands intent and returns everything needed.

{
  "intent": "add_feature",
  "focus": "user authentication",
  "question": "How do I add a new auth endpoint?",
  "project": "backend"
}

Parameters:

Parameter Type Required Description
intent enum Yes What you're trying to do
focus string Yes The area you're working with
question string No Specific question to answer
project string No Target a specific registered project

Intent Options:

  • add_feature β€” Adding new functionality
  • fix_bug β€” Fixing a bug or issue
  • refactor β€” Improving code structure
  • security_audit β€” Reviewing for security issues
  • understand_code β€” Learning how something works
  • add_test β€” Adding test coverage

Returns:

{
  "summary": "Adding feature in 'user authentication'. Found 5 relevant patterns...",
  "relevantPatterns": [
    {
      "id": "auth-jwt-pattern",
      "name": "JWT Authentication",
      "category": "auth",
      "why": "Directly related to 'authentication' - this is the established pattern",
      "example": "// Code example from your codebase",
      "confidence": 0.92,
      "locationCount": 12
    }
  ],
  "suggestedFiles": [
    {
      "file": "src/auth/login.ts",
      "reason": "Matches focus area",
      "patterns": ["JWT Authentication", "Error Handling"],
      "risk": "medium"
    }
  ],
  "guidance": {
    "keyInsights": [
      "This codebase has established API patterns - follow them for consistency",
      "Error handling patterns exist - use the established error types"
    ],
    "commonMistakes": [
      "Don't create new patterns when existing ones apply",
      "Remember to add appropriate logging"
    ],
    "decisionPoints": [
      "Decide if this feature needs its own module or fits in existing structure"
    ]
  },
  "warnings": [
    {
      "type": "data_access",
      "message": "src/auth/login.ts accesses sensitive data: users.password_hash",
      "severity": "warning"
    }
  ],
  "confidence": {
    "patternCoverage": 80,
    "dataFreshness": "Current session",
    "limitations": []
  },
  "deeperDive": [
    {
      "tool": "drift_code_examples",
      "args": { "pattern": "auth-jwt-pattern", "maxExamples": 3 },
      "reason": "See more examples of 'JWT Authentication' pattern"
    }
  ],
  "semanticInsights": {
    "frameworks": ["Express", "Prisma"],
    "entryPoints": [
      { "name": "login", "file": "src/auth/login.ts", "type": "route", "path": "/api/auth/login" }
    ],
    "dataAccessors": [
      { "name": "findUser", "file": "src/repositories/user.ts", "tables": ["users"] }
    ]
  },
  "constraints": [
    {
      "id": "auth-required",
      "name": "Authentication Required",
      "enforcement": "error",
      "guidance": "All /api/* routes must use @RequireAuth middleware"
    }
  ]
}

drift_package_context

Get context for a specific package or module.

{
  "package": "src/auth",
  "depth": "detailed"
}

Layer 2: Discovery

Quick, lightweight tools for health checks and capability discovery.

drift_status

Codebase health snapshot. Always fast, always lightweight.

{}

Returns:

{
  "summary": "47 patterns (12 approved), health score 72/100",
  "data": {
    "patterns": {
      "total": 47,
      "approved": 12,
      "discovered": 32,
      "ignored": 3
    },
    "categories": {
      "api": 12,
      "auth": 8,
      "errors": 15,
      "data-access": 12
    },
    "healthScore": 72,
    "criticalIssues": []
  }
}

drift_capabilities

List all Drift capabilities and when to use each tool.

{}

Returns: Organized guide to all 50 available tools.

drift_projects

Manage registered projects for multi-project workflows.

{
  "action": "list"
}

Actions: list, info, switch, recent, register

drift_setup

Initialize and configure drift for a project.

{
  "action": "status"
}

Actions: status, init, scan, callgraph, full

drift_telemetry

Manage telemetry settings. Telemetry helps improve pattern detection by sharing anonymized data (no source code is ever sent).

{
  "action": "status"
}

Actions:

  • status β€” Check current telemetry settings
  • enable β€” Enable telemetry (opt-in to help improve Drift)
  • disable β€” Disable telemetry

Privacy Guarantees:

  • No source code is ever sent
  • Only pattern signatures (SHA-256 hashes), categories, and confidence scores
  • Aggregate statistics (pattern counts, languages detected)
  • Anonymous installation ID (UUID, not tied to identity)

Returns:

{
  "success": true,
  "enabled": true,
  "config": {
    "sharePatternSignatures": true,
    "shareAggregateStats": true,
    "shareUserActions": false,
    "installationId": "uuid-here",
    "enabledAt": "2026-02-03T12:00:00Z"
  },
  "message": "Telemetry enabled. Thank you for helping improve Drift!"
}

drift_curate

Curate patterns: approve, ignore, or review with mandatory verification. Prevents AI hallucination through grep-based evidence checking.

{
  "action": "review",
  "category": "api",
  "minConfidence": 0.7
}

Actions:

  • review β€” Get patterns pending review with evidence requirements
  • verify β€” Verify a pattern exists (REQUIRED before approve for non-high-confidence)
  • approve β€” Approve a verified pattern
  • ignore β€” Ignore a pattern with reason
  • bulk_approve β€” Auto-approve patterns with confidence >= 0.95
  • audit β€” View curation decision history

Parameters:

Parameter Type Required Description
action enum Yes Action to perform
patternId string For verify/approve/ignore Pattern ID to act on
category string No Filter by pattern category
minConfidence number No Minimum confidence filter
maxConfidence number No Maximum confidence filter
limit number No Max patterns to return (default: 20)
evidence object For verify/approve Evidence for verification
ignoreReason string For ignore Why ignoring (required)
approvedBy string No Who approved
confidenceThreshold number No Min confidence for bulk_approve (default: 0.95)
dryRun boolean No Preview bulk_approve without changes

Evidence Requirements (by confidence level):

  • High (>=0.85): 1 file, no snippet required
  • Medium (>=0.65): 2 files, snippets required
  • Low (>=0.45): 3 files, snippets required
  • Uncertain (<0.45): 5 files, snippets required

Workflow:

  1. Use action="review" to see pending patterns
  2. For each pattern, grep the codebase to find evidence
  3. Use action="verify" with evidence to validate
  4. If verified, use action="approve" to approve

Example - Review patterns:

{
  "action": "review",
  "category": "api",
  "minConfidence": 0.7,
  "limit": 10
}

Example - Verify with evidence:

{
  "action": "verify",
  "patternId": "api-rest-controller",
  "evidence": {
    "files": ["src/api/users.ts", "src/api/posts.ts"],
    "snippets": ["export class UsersController", "export class PostsController"],
    "reasoning": "Found consistent controller pattern across API files"
  }
}

Example - Bulk approve high-confidence:

{
  "action": "bulk_approve",
  "confidenceThreshold": 0.95,
  "dryRun": true
}

Layer 3: Surgical Tools

12 ultra-focused tools designed for minimal token usage. Each tool does exactly one thing.

drift_signature

Get function signature without reading entire files.

{
  "symbol": "handleLogin",
  "file": "src/auth/login.ts",
  "includeDocs": true
}

Returns:

{
  "summary": "Found function 'handleLogin' in src/auth/login.ts:45",
  "data": {
    "found": true,
    "signatures": [{
      "file": "src/auth/login.ts",
      "line": 45,
      "kind": "function",
      "signature": "export async function handleLogin(email: string, password: string): Promise<User>",
      "parameters": [
        { "name": "email", "type": "string", "required": true },
        { "name": "password", "type": "string", "required": true }
      ],
      "returnType": "Promise<User>",
      "exported": true
    }]
  }
}

drift_callers

Lightweight "who calls this function" lookup.

{
  "function": "validateToken",
  "transitive": true,
  "maxDepth": 2
}

Returns:

{
  "summary": "'validateToken' has 5 direct callers (public API)",
  "data": {
    "target": { "function": "validateToken", "file": "src/auth/token.ts", "line": 23 },
    "directCallers": [
      { "function": "requireAuth", "file": "src/middleware/auth.ts", "line": 12, "callSite": 34 }
    ],
    "transitiveCallers": [
      { "function": "handleRequest", "file": "src/api/handler.ts", "depth": 2, "path": ["validateToken", "requireAuth"] }
    ],
    "stats": {
      "directCount": 5,
      "transitiveCount": 12,
      "isPublicApi": true,
      "isWidelyUsed": true
    }
  }
}

drift_imports

Resolve correct import statements.

{
  "symbols": ["User", "createUser"],
  "targetFile": "src/api/users.ts"
}

drift_prevalidate

Quick validation before making changes.

{
  "code": "export async function createUser(data: UserInput): Promise<User> { ... }",
  "targetFile": "src/api/users.ts",
  "kind": "function"
}

drift_similar

Find semantically similar code.

{
  "intent": "api_endpoint",
  "description": "user preferences CRUD",
  "scope": "src/api",
  "limit": 3
}

drift_type

Expand type definitions.

{
  "type": "User",
  "depth": 2,
  "file": "src/types/user.ts"
}

drift_recent

Show recent changes in an area.

{
  "area": "src/api/",
  "days": 7,
  "type": "feat"
}

drift_test_template

Generate test scaffolding.

{
  "targetFile": "src/auth/login.ts",
  "function": "handleLogin",
  "type": "unit"
}

drift_dependencies

Package dependencies lookup (multi-language).

{
  "search": "react",
  "type": "prod",
  "category": "framework",
  "language": "javascript"
}

drift_middleware

Middleware pattern lookup.

{
  "type": "auth",
  "framework": "express",
  "limit": 20
}

drift_hooks

React/Vue hooks lookup.

{
  "component": "UserProfile",
  "file": "src/components/UserProfile.tsx"
}

drift_errors

Error types and handling gaps.

{
  "function": "handlePayment",
  "file": "src/payments/handler.ts"
}

Layer 4: Exploration

Paginated listing tools for browsing and filtering.

drift_patterns_list

List patterns with summaries.

{
  "categories": ["api", "auth"],
  "status": "approved",
  "minConfidence": 0.8,
  "search": "controller",
  "limit": 20,
  "cursor": "next_page_token"
}

drift_security_summary

Security posture overview.

{
  "focus": "critical",
  "limit": 10
}

Focus options: all, critical, data-access, auth

drift_contracts_list

API contracts between frontend and backend.

{
  "status": "mismatch",
  "limit": 20
}

Status options: all, verified, mismatch, discovered

drift_trends

Pattern trend analysis over time.

{
  "period": "30d",
  "category": "security",
  "severity": "critical"
}

drift_env

Environment variable analysis.

{
  "action": "list",
  "category": "secrets"
}

Layer 5: Detail

Deep dives into specific patterns, files, and analysis.

drift_pattern_get

Complete details for a specific pattern.

{
  "id": "api-rest-controller-pattern",
  "includeLocations": true,
  "includeOutliers": true,
  "maxLocations": 20
}

drift_code_examples

Real code examples for patterns.

{
  "categories": ["api", "errors"],
  "pattern": "error-handling-try-catch",
  "maxExamples": 3,
  "contextLines": 10
}

drift_files_list

List files with patterns.

{
  "path": "src/api/**/*.ts",
  "category": "api",
  "limit": 20
}

drift_file_patterns

All patterns in a specific file.

{
  "file": "src/api/users.controller.ts",
  "category": "api"
}

drift_impact_analysis

Analyze impact of changing a file or function.

{
  "target": "src/auth/login.ts",
  "maxDepth": 10,
  "limit": 10
}

drift_reachability

Data reachability analysis.

{
  "direction": "forward",
  "location": "src/api/users.ts:42",
  "maxDepth": 10,
  "sensitiveOnly": true
}

Or inverse:

{
  "direction": "inverse",
  "target": "users.password_hash",
  "maxDepth": 10
}

drift_dna_profile

Styling DNA profile for frontend consistency.

{
  "gene": "variant-handling"
}

Gene options: variant-handling, responsive-approach, state-styling, theming, spacing-philosophy, animation-approach

drift_wrappers

Framework wrapper detection.

{
  "category": "data-fetching",
  "minConfidence": 0.5,
  "minClusterSize": 2
}

Layer 6: Analysis

Complex analysis tools. Some require pre-built data.

Note: Run build commands first:

  • drift test-topology build
  • drift coupling build
  • drift error-handling build

drift_test_topology

Test-to-code mapping analysis.

{
  "action": "affected",
  "files": ["src/auth/login.ts", "src/auth/logout.ts"]
}

Actions: status, coverage, uncovered, mocks, affected, quality

drift_coupling

Module dependency analysis.

{
  "action": "cycles",
  "minSeverity": "warning"
}

Actions: status, cycles, hotspots, analyze, refactor-impact, unused-exports

drift_error_handling

Error handling pattern analysis.

{
  "action": "gaps",
  "minSeverity": "medium"
}

Actions: status, gaps, boundaries, unhandled, analyze

drift_constants

Analyze constants, enums, and exported values.

{
  "action": "secrets",
  "severity": "high"
}

Actions: status, list, get, usages, magic, dead, secrets, inconsistent

drift_quality_gate

Run quality gates on code changes.

{
  "files": ["src/routes/users.ts"],
  "policy": "strict",
  "gates": "pattern-compliance,security-boundary",
  "format": "github"
}

Policies: default, strict, relaxed, ci-fast

Gates: pattern-compliance, constraint-verification, regression-detection, impact-simulation, security-boundary, custom-rules

drift_decisions

Architectural decision records.

{
  "action": "list",
  "status": "active"
}

drift_constraints

Architectural constraints.

{
  "action": "list"
}

drift_simulate

Simulate changes before making them.

{
  "file": "src/api/users.ts",
  "change": "add new endpoint"
}

Layer 7: Generation

AI-assisted code generation and validation.

drift_suggest_changes

AI-guided fix suggestions.

{
  "target": "src/api/users.ts",
  "issue": "outlier",
  "patternId": "api-rest-controller",
  "maxSuggestions": 3
}

Issue types: outlier, security, coupling, error-handling, test-coverage, pattern-violation

drift_validate_change

Validate proposed changes against patterns.

{
  "file": "src/api/users.ts",
  "content": "// new code here",
  "strictMode": false
}

Or with diff:

{
  "file": "src/api/users.ts",
  "diff": "--- a/file\n+++ b/file\n...",
  "strictMode": true
}

drift_explain

Comprehensive code explanation.

{
  "target": "src/auth/middleware.ts",
  "depth": "comprehensive",
  "focus": "security"
}

Depth options: summary, detailed, comprehensive

Focus options: security, performance, architecture, testing


Language-Specific Tools

All 9 languages have dedicated MCP tools for language-specific analysis.

drift_typescript

TypeScript/JavaScript-specific analysis.

{
  "action": "status",
  "path": "src/",
  "framework": "express",
  "limit": 50
}

Actions:

  • status β€” Project overview (files, frameworks, stats)
  • routes β€” HTTP routes (Express, NestJS, Next.js, Fastify)
  • components β€” React components (functional, class)
  • hooks β€” React hooks usage (builtin, custom)
  • errors β€” Error handling patterns (try-catch, boundaries)
  • data-access β€” Database patterns (Prisma, TypeORM, Drizzle, Sequelize, Mongoose)
  • decorators β€” Decorator usage (NestJS, TypeORM)

drift_python

Python-specific analysis.

{
  "action": "routes",
  "framework": "fastapi"
}

Actions:

  • status β€” Project overview
  • routes β€” HTTP routes (Flask, FastAPI, Django, Starlette)
  • errors β€” Error handling patterns (try-except, custom exceptions)
  • data-access β€” Database patterns (Django ORM, SQLAlchemy, Tortoise, Peewee)
  • decorators β€” Decorator usage
  • async β€” Async patterns (async/await, asyncio)

drift_java

Java-specific analysis.

{
  "action": "annotations",
  "framework": "spring"
}

Actions:

  • status β€” Project overview
  • routes β€” HTTP routes (Spring MVC, JAX-RS, Micronaut, Quarkus)
  • errors β€” Error handling patterns (try-catch, exception handlers)
  • data-access β€” Database patterns (Spring Data JPA, Hibernate, JDBC, MyBatis)
  • annotations β€” Annotation usage (@RestController, @Service, etc.)

drift_php

PHP-specific analysis.

{
  "action": "traits",
  "framework": "laravel"
}

Actions:

  • status β€” Project overview
  • routes β€” HTTP routes (Laravel, Symfony, Slim, Lumen)
  • errors β€” Error handling patterns (try-catch, custom exceptions)
  • data-access β€” Database patterns (Eloquent, Doctrine, PDO)
  • traits β€” Trait definitions and usage

drift_go

Go-specific analysis.

{
  "action": "goroutines"
}

Actions:

  • status β€” Project overview
  • routes β€” HTTP routes (Gin, Echo, Chi, Fiber, net/http)
  • errors β€” Error handling patterns
  • interfaces β€” Interface implementations
  • data-access β€” Database patterns (GORM, sqlx, database/sql)
  • goroutines β€” Concurrency patterns

drift_rust

Rust-specific analysis.

{
  "action": "async"
}

Actions:

  • status β€” Project overview
  • routes β€” HTTP routes (Actix, Axum, Rocket, Warp)
  • errors β€” Error handling (Result, thiserror, anyhow)
  • traits β€” Trait implementations
  • data-access β€” Database patterns (SQLx, Diesel, SeaORM)
  • async β€” Async patterns and runtime usage

drift_cpp

C++-specific analysis.

{
  "action": "memory"
}

Actions:

  • status β€” Project overview
  • classes β€” Class/struct analysis with inheritance
  • memory β€” Memory management (smart pointers, RAII)
  • templates β€” Template classes and functions
  • virtual β€” Virtual functions and polymorphism

drift_wpf

WPF (C#) specific analysis.

{
  "action": "bindings"
}

Actions:

  • status β€” Project overview
  • bindings β€” XAML data bindings
  • mvvm β€” MVVM compliance check
  • datacontext β€” DataContext resolution
  • commands β€” ICommand implementations

Pattern Categories

Available categories for filtering:

Category Description
api REST endpoints, GraphQL resolvers
auth Authentication, authorization
security Security patterns, validation
errors Error handling patterns
logging Logging, observability
data-access Database queries, ORM usage
config Configuration patterns
testing Test patterns, mocks
performance Caching, optimization
components UI components
styling CSS, styling patterns
structural Code organization
types Type definitions
accessibility A11y patterns
documentation Doc patterns

Memory Tools (Cortex V2)

Cortex V2 introduces intelligent memory tools for learning, retrieval, and causal understanding.

drift_why

Get causal narrative explaining WHY something exists.

{
  "intent": "understand_code",
  "focus": "authentication",
  "maxDepth": 3
}

Returns: Human-readable narrative tracing causal chains.

drift_memory_status

Health overview with recommendations.

{}

Returns:

{
  "summary": "Memory system healthy. 47 memories, 0.78 avg confidence",
  "data": {
    "totalMemories": 47,
    "byType": { "tribal_knowledge": 20, "pattern_rationale": 15, ... },
    "averageConfidence": 0.78,
    "validationBacklog": 5,
    "healthScore": 85
  },
  "recommendations": [
    "5 memories need validation",
    "Consider consolidating similar memories"
  ]
}

drift_memory_for_context

Get memories for current context with token efficiency.

{
  "intent": "add_feature",
  "focus": "authentication",
  "maxTokens": 2000,
  "compressionLevel": 2,
  "sessionId": "session_abc123"
}

Compression levels: 0 (IDs only), 1 (one-liners), 2 (with examples), 3 (full detail)

drift_memory_search

Search with session deduplication.

{
  "query": "password hashing",
  "types": ["tribal_knowledge", "pattern_rationale"],
  "minConfidence": 0.5,
  "sessionId": "session_abc123",
  "limit": 10
}

drift_memory_add

Add memory with automatic causal inference.

{
  "type": "tribal_knowledge",
  "content": "Always use bcrypt for password hashing",
  "source": "security_audit",
  "context": {
    "file": "src/auth/password.ts",
    "relatedMemories": ["mem_security_audit"]
  }
}

drift_memory_learn

Learn from corrections (full learning pipeline).

{
  "original": "Use MD5 for hashing",
  "correction": "MD5 is insecure. Use bcrypt.",
  "correctCode": "const hash = await bcrypt.hash(password, 10);",
  "context": {
    "file": "src/auth.ts",
    "intent": "fix_bug"
  }
}

Returns: Created memories, extracted principles, updated confidence.

drift_memory_feedback

Confirm, reject, or modify memories.

{
  "memoryId": "mem_abc123",
  "action": "confirmed"
}

Actions: confirmed, rejected, modified

For modifications:

{
  "memoryId": "mem_abc123",
  "action": "modified",
  "newContent": "Updated guidance..."
}

drift_memory_health

Comprehensive health report.

{
  "includeRecommendations": true,
  "includeMetrics": true
}

Returns: Detailed health metrics, validation backlog, consolidation opportunities.

drift_memory_explain

Get causal explanation for a memory.

{
  "memoryId": "mem_abc123",
  "includeNarrative": true,
  "maxDepth": 3
}

Returns: Causal chain and human-readable narrative.

drift_memory_predict

Get predicted memories for current context.

{
  "activeFile": "src/auth/login.ts",
  "recentFiles": ["src/auth/logout.ts"],
  "intent": "add_feature",
  "limit": 10
}

Returns: Ranked predictions with confidence scores and reasons.

drift_memory_conflicts

Detect conflicting memories.

{
  "memoryId": "mem_abc123"
}

Or scan all:

{
  "scanAll": true,
  "minSeverity": "medium"
}

drift_memory_graph

Visualize memory relationships.

{
  "memoryId": "mem_abc123",
  "direction": "both",
  "maxDepth": 3,
  "format": "mermaid"
}

Formats: json, mermaid, dot

drift_memory_validate

Validate memories and get healing suggestions.

{
  "limit": 5,
  "includePrompts": true
}

Returns: Memories needing validation with suggested prompts.

drift_memory_get

Get memory with optional causal chain.

{
  "memoryId": "mem_abc123",
  "includeCausalChain": true,
  "chainDepth": 3
}

drift_memory_query

Rich graph queries using MGQL (Memory Graph Query Language).

{
  "query": "MATCH (m:tribal) WHERE m.topic = 'security' RETURN m",
  "limit": 20
}

drift_memory_contradictions

Detect and resolve contradictions between memories.

{
  "action": "detect",
  "memoryId": "mem_abc123"
}

Actions: detect, resolve, list


Universal Memory Tools (V2)

These tools manage the 10 universal memory types introduced in Cortex V2.

drift_agent_spawn

Create and invoke reusable agent configurations.

{
  "action": "list"
}

Actions:

  • list β€” List all agent spawns
  • get β€” Get agent spawn details
  • create β€” Create new agent spawn
  • invoke β€” Invoke an agent spawn
  • delete β€” Delete an agent spawn

Create example:

{
  "action": "create",
  "name": "Code Reviewer",
  "slug": "code-reviewer",
  "description": "Reviews code for quality",
  "systemPrompt": "You are a thorough code reviewer...",
  "tools": ["readFile", "grepSearch", "getDiagnostics"],
  "triggerPatterns": ["review this", "code review"]
}

drift_workflow

Store and execute step-by-step processes.

{
  "action": "list"
}

Actions:

  • list β€” List all workflows
  • get β€” Get workflow details
  • create β€” Create new workflow
  • execute β€” Execute a workflow
  • delete β€” Delete a workflow

Create example:

{
  "action": "create",
  "name": "Deploy to Production",
  "slug": "deploy-production",
  "description": "Steps to deploy code to production",
  "steps": [
    { "order": 1, "name": "Run tests", "description": "npm test" },
    { "order": 2, "name": "Build", "description": "npm run build" },
    { "order": 3, "name": "Deploy", "description": "npm run deploy" }
  ],
  "triggerPhrases": ["deploy", "push to prod"]
}

drift_entity

Track projects, teams, services, and systems.

{
  "action": "list",
  "entityType": "service"
}

Actions:

  • list β€” List all entities
  • get β€” Get entity details
  • create β€” Create new entity
  • update β€” Update entity
  • delete β€” Delete entity

Create example:

{
  "action": "create",
  "entityType": "service",
  "name": "Auth Service",
  "keyFacts": ["Handles authentication", "Uses JWT", "Redis for sessions"],
  "status": "active"
}

drift_goal

Track objectives with progress.

{
  "action": "list",
  "status": "active"
}

Actions:

  • list β€” List all goals
  • get β€” Get goal details
  • create β€” Create new goal
  • update β€” Update goal progress
  • complete β€” Mark goal as complete
  • delete β€” Delete goal

drift_incident

Record postmortems and lessons learned.

{
  "action": "list",
  "severity": "critical"
}

Actions:

  • list β€” List all incidents
  • get β€” Get incident details
  • create β€” Create new incident
  • resolve β€” Mark incident as resolved
  • delete β€” Delete incident

Create example:

{
  "action": "create",
  "title": "Database outage 2024-01-15",
  "severity": "critical",
  "rootCause": "Connection pool exhaustion",
  "lessonsLearned": ["Always set connection limits", "Monitor pool usage"],
  "preventionMeasures": ["Add connection pool alerts"]
}

drift_skill

Track knowledge domains and proficiency.

{
  "action": "list",
  "domain": "frontend"
}

Actions:

  • list β€” List all skills
  • get β€” Get skill details
  • create β€” Create new skill
  • update β€” Update proficiency
  • delete β€” Delete skill

Proficiency levels: learning, beginner, competent, proficient, expert

drift_environment

Store environment configurations.

{
  "action": "list"
}

Actions:

  • list β€” List all environments
  • get β€” Get environment details
  • create β€” Create new environment
  • update β€” Update environment
  • delete β€” Delete environment

Create example:

{
  "action": "create",
  "name": "Production",
  "environmentType": "production",
  "warnings": ["⚠️ This is PRODUCTION - be careful!"],
  "endpoints": { "api": "https://api.example.com" }
}

drift_meeting

Record meeting notes and action items.

{
  "action": "list"
}

Actions:

  • list β€” List all meetings
  • get β€” Get meeting details
  • create β€” Create meeting notes
  • delete β€” Delete meeting

drift_conversation

Store conversation summaries.

{
  "action": "list"
}

Actions:

  • list β€” List all conversations
  • get β€” Get conversation details
  • create β€” Create conversation summary
  • delete β€” Delete conversation

Best Practices for AI Agents

1. Start with drift_context

For any code generation task, start here:

{
  "intent": "add_feature",
  "focus": "the area you're working on"
}

2. Use Surgical Tools for Precision

When you need exactly one thing:

// Need a signature?
{ "tool": "drift_signature", "symbol": "functionName" }

// Need callers?
{ "tool": "drift_callers", "function": "functionName" }

// Need imports?
{ "tool": "drift_imports", "symbol": "TypeName" }

3. Validate Before Committing

Always validate generated code:

{
  "tool": "drift_validate_change",
  "file": "path/to/file.ts",
  "content": "// generated code"
}

4. Use Pagination for Large Results

When results are paginated:

// First call
{ "limit": 20 }

// Next page
{ "limit": 20, "cursor": "returned_cursor" }

5. Check Hints for Next Steps

Every response includes hints:

{
  "hints": {
    "nextActions": ["What to do next"],
    "relatedTools": ["Other useful tools"],
    "warnings": ["Important warnings"]
  }
}

Infrastructure Features

Caching

Responses are cached for repeated queries. Cache is invalidated when:

  • Files change
  • Patterns are approved/ignored
  • Call graph is rebuilt

Rate Limiting

Prevents runaway tool calls. Default: 60 requests/minute.

Metrics

Usage metrics are collected for:

  • Tool call frequency
  • Response times
  • Cache hit rates
  • Error rates

Warmup

On startup, Drift warms up stores for instant responses:

  • Pattern store loaded
  • Call graph indexed
  • Boundary data cached

Clone this wiki locally