-
Notifications
You must be signed in to change notification settings - Fork 59
MCP Setup
Connect Drift to AI agents via Model Context Protocol (MCP).
# 1. Install
npm install -g driftdetect driftdetect-mcp
# 2. Scan your project
cd your-project
drift init
drift scan
# 3. Add to your AI tool's config:{
"mcpServers": {
"drift": {
"command": "driftdetect-mcp"
}
}
}4. Restart your AI tool
5. Test it: Ask "What patterns does Drift see in my codebase?"
MCP (Model Context Protocol) is a standard for connecting AI agents to external tools. Drift's MCP server gives AI agents like Claude, Cursor, Windsurf, and Kiro deep understanding of your codebase.
With Drift MCP, AI agents can:
- Understand YOUR patterns and conventions
- Generate code that fits your codebase
- Analyze impact before making changes
- Find security issues and data flows
- Suggest fixes that match your style
# CLI (for scanning)
npm install -g driftdetect
# MCP server (for AI integration)
npm install -g driftdetect-mcpcd your-project
drift init
drift scanPick your AI tool below:
Config file location:
-
Mac:
~/Library/Application Support/Claude/claude_desktop_config.json -
Windows:
%APPDATA%\Claude\claude_desktop_config.json
Add this:
{
"mcpServers": {
"drift": {
"command": "driftdetect-mcp"
}
}
}Restart Claude Desktop.
Config file: .cursor/mcp.json in your project folder
Add this:
{
"mcpServers": {
"drift": {
"command": "driftdetect-mcp"
}
}
}Restart Cursor.
Config: Settings β MCP Servers
Add a new server with command: driftdetect-mcp
Restart Windsurf.
Config file: .kiro/settings/mcp.json in your project folder
Add this:
{
"mcpServers": {
"drift": {
"command": "driftdetect-mcp",
"disabled": false,
"autoApprove": []
}
}
}Restart Kiro.
Config file: .vscode/mcp.json in your project folder
Add this:
{
"mcpServers": {
"drift": {
"command": "driftdetect-mcp"
}
}
}Restart VS Code.
If you don't want to install globally, use npx:
{
"mcpServers": {
"drift": {
"command": "npx",
"args": ["-y", "driftdetect-mcp@0.9.39"]
}
}
}Note: Pin the version to avoid unexpected updates.
Ask your AI agent:
"What patterns does Drift see in this codebase?"
If connected, it will call drift_status and show your pattern summary.
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β AI Agent ββββββΆβ Drift MCP ββββββΆβ Your Code β
β (Claude, etc.) βββββββ Server βββββββ (.drift/) β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
- AI agent receives your prompt
- Agent calls Drift MCP tools to understand your codebase
- Drift returns patterns, examples, and conventions
- Agent generates code that matches YOUR style
You: "Add a new API endpoint for user preferences"
AI (via Drift):
Based on your codebase patterns:
- Routes use
@Controllerdecorator with/api/v1prefix- Error responses follow
{ error: string, code: number }format- User endpoints require
@RequireAuth()middleware- Similar endpoints:
src/controllers/user.controller.tsHere's the implementation following your conventions...
Drift provides 50 MCP tools organized in 7 layers:
| Layer | Tools | Purpose |
|---|---|---|
| Orchestration |
drift_context, drift_package_context
|
Start here β curated context |
| Discovery |
drift_status, drift_capabilities, drift_projects
|
Quick overview |
| Surgical | 12 ultra-focused tools | Precise queries |
| Exploration |
drift_patterns_list, drift_security_summary, etc. |
Browse patterns |
| Detail |
drift_pattern_get, drift_code_examples, etc. |
Deep dives |
| Analysis |
drift_test_topology, drift_coupling, etc. |
Code health |
| Generation |
drift_suggest_changes, drift_validate_change, etc. |
AI assistance |
| Tool | When to Use |
|---|---|
drift_context |
Starting any task β returns curated context |
drift_status |
Quick health check |
drift_code_examples |
Need real examples from your code |
drift_impact_analysis |
Before making changes |
drift_validate_change |
After generating code |
Work across multiple codebases:
# Register projects
drift projects add ~/code/backend
drift projects add ~/code/frontend
# List registered projects
drift projects list
# Switch active project
drift projects switch backendThe MCP server can query any registered project using the project parameter:
{
"intent": "add_feature",
"focus": "authentication",
"project": "backend"
}# Set project path
export DRIFT_PROJECT_PATH=/path/to/project
# Enable debug logging
export DEBUG=drift:*{
"mcpServers": {
"drift": {
"command": "driftdetect-mcp",
"env": {
"DRIFT_PROJECT_PATH": "/path/to/project",
"DEBUG": "drift:mcp"
}
}
}
}driftdetect-mcp # Use active project
driftdetect-mcp /path/to/project # Analyze specific project
driftdetect-mcp --no-cache # Disable response caching
driftdetect-mcp --verbose # Enable verbose logging- Restart your AI client after config changes
- Check the config file path is correct for your OS
-
Verify the MCP server runs:
driftdetect-mcp --help
Run drift scan in your project first. The MCP server needs .drift/ data to work.
- First call may be slow (loading data)
- Subsequent calls use caching
- For large codebases:
drift scan --incremental
Some tools require pre-built data:
drift test-topology build
drift coupling build
drift error-handling buildCheck which project is active:
drift projects list
drift projects switch <project-name>Enable debug logging:
{
"mcpServers": {
"drift": {
"command": "driftdetect-mcp",
"env": {
"DEBUG": "drift:*"
}
}
}
}-
Scan regularly β Run
drift scanafter significant changes - Approve patterns β Approved patterns give better recommendations
-
Use
drift_contextβ Start with this tool for most tasks - Build analysis data β Run build commands for full analysis
- Register all projects β Multi-project support helps with monorepos
Run Drift as a containerized HTTP service:
# Clone and start
git clone https://github.com/dadbodgeoff/drift.git
cd drift
# Start with your project mounted
PROJECT_PATH=/path/to/your/project docker compose up -d
# Check health
curl http://localhost:3000/healthConfigure your MCP client to connect via HTTP/SSE:
- SSE endpoint:
http://localhost:3000/sse - Message endpoint:
http://localhost:3000/message
- Cortex V2 Overview
- Memory Setup Wizard
- Memory CLI
- Universal Memory Types
- Learning System
- Token Efficiency
- Causal Graphs
- Code Generation
- Predictive Retrieval
- Architecture
- Call Graph Analysis
- Impact Analysis
- Security Analysis
- Data Boundaries
- Test Topology
- Coupling Analysis
- Error Handling Analysis
- Wrappers Detection
- Environment Variables
- Constants Analysis
- Styling DNA
- Constraints
- Contracts
- Decision Mining
- Speculative Execution
- Watch Mode
- Trends Analysis
- Projects Management
- Package Context
- Monorepo Support
- Reports & Export
- Dashboard
- 10 Languages
- 21 Frameworks
- 16 ORMs
- 400+ Detectors
- 50+ MCP Tools
- 60+ CLI Commands
- 23 Memory Types