Local MCP server for code guidance and workflow automation
npm install code-guider-mcpAn AI-powered local Model Context Protocol (MCP) server that provides intelligent code guidance, workflow automation, and quality assurance for your development projects. Features hybrid storage with Drizzle ORM for fast CRUD operations and vector storage for semantic search, AI-driven insights, and Anubis-inspired role-based workflow execution. Optimized for Bun runtime with native SQLite for maximum performance.
- π§ AI-Powered Analysis: Intelligent code analysis with semantic understanding
- π Hybrid Storage: Drizzle ORM for fast CRUD operations + vector storage for semantic search
- π Multi-Project Support: Global and project-specific databases with automatic project detection
- π Global + Local Mode: Global templates/workflows + project-specific customization
- π Workflow Automation: Define and execute AI-enhanced code generation workflows
- π Template System: Reusable code templates with AI-powered suggestions
- β
Quality Rules: Automated code quality checking with pattern recognition
- π― Context-Aware: Provides guidance based on file type and project context
- π§ MCP Integration: Works with any MCP-compatible client
- π TypeScript: Full TypeScript support with type safety
- π Similar Code Detection: Find similar code patterns across your codebase
- π Complexity Analysis: AI-powered code complexity scoring
- π₯ Role-Based Execution: Anubis-inspired role system with Product Manager, Architect, Senior Developer, and Code Review roles
- π Execution Tracking: Comprehensive workflow execution tracking with state management
- π― Context Preservation: Seamless role transitions with full context preservation
- π€ Multi-Agent Support: Optimized templates for Cursor, Copilot, RooCode, and KiloCode
- βΈοΈ Pause/Resume: Pause and resume workflow executions at any time
- π Execution Metrics: Detailed metrics and performance tracking
- β‘ Performance: 3-10x faster operations with Drizzle ORM + Bun SQLite optimization
- π LibSQL Powered: Built with LibSQL for cross-platform compatibility and optimal performance
- π¦ Zero Native Dependencies: Pure JavaScript/TypeScript with no native compilation required
- π€ AI Migration: Natural language migration commands that intelligently transform and migrate data
- π Smart Transformation: AI-powered data transformation with validation and rollback capabilities
- π‘οΈ Safe Migration: Built-in backup, dry-run, and validation features for safe data migration
#### Option 1: npm (Recommended - Easiest)
``bashInstall globally
npm install -g code-guider-mcp
#### Option 2: Local Development
`bash
Clone the repository
git clone
cd code-guiderInstall dependencies
npm installBuild the project
npm run buildRun database migration (first time only)
npm run migrateStart the MCP server
npm start
`$3
#### With npm (Global Installation)
`bash
Start with defaults
code-guider-mcpStart on specific port
code-guider-mcp --port 8080Run migration only
code-guider-mcp --migrateOpen database studio
code-guider-mcp --studioShow help
code-guider-mcp --help
`#### With Local Development
`bash
Start the MCP server
npm start
`$3
Code Guider supports both global and project-specific modes:
#### Project Modes
1. Global Mode (
--global): Uses global database for all projects
2. Project Mode (default): Uses project-specific database
3. Auto-detect: Automatically detects project type and initializes#### Project Management Commands
`bash
Initialize a project (auto-detects type)
code-guider-mcp --initInitialize specific project
code-guider-mcp --init /path/to/projectList all projects
code-guider-mcp --list-projectsUse global storage
code-guider-mcp --globalUse specific project
code-guider-mcp /path/to/project
`#### Project Structure
`
~/.code-guider/ # Global storage
βββ global.db # Global database
βββ config.json # Global configuration
βββ projects/
βββ projects.json # Project registry/path/to/project/ # Project-specific storage
βββ .guidance/
βββ guidance.db # Project database
`$3
#### With npm (Global Installation)
`json
{
"mcpServers": {
"code-guidance": {
"command": "code-guider-mcp"
}
}
}
`#### With Local Development
`json
{
"mcpServers": {
"code-guidance": {
"command": "node",
"args": ["dist/index.js"],
"cwd": "/path/to/code-guider"
}
}
}
`Architecture
$3
1. MCP Server (
src/mcp-server.ts): Main server implementation with tool handlers
2. Hybrid Storage (src/hybrid-storage.ts): Combines Drizzle ORM for fast CRUD + VectorStorage for AI features
3. Drizzle Storage (src/db/drizzle-storage.ts): Optimized database operations with SQLite
4. Vector Storage (src/vector-storage.ts): AI-powered semantic search and embeddings
5. Guidance Engine (src/guidance-engine.ts): Workflow execution and code analysis
6. Type Definitions (src/types.ts): TypeScript interfaces for all data structures$3
`
.guidance/
βββ guidance.db # SQLite database with hybrid storage
β βββ workflows # Drizzle ORM table (fast CRUD)
β βββ templates # Drizzle ORM table (fast CRUD)
β βββ quality_rules # Drizzle ORM table (fast CRUD)
β βββ project_config # Drizzle ORM table (fast CRUD)
β βββ workflows_vector # Vector embeddings for semantic search
β βββ templates_vector # Vector embeddings for semantic search
β βββ quality_rules_vector # Vector embeddings for semantic search
βββ config/ # Legacy file-based config (auto-migrated)
β βββ project.json
βββ workflows/ # Legacy JSON files (auto-migrated to DB)
βββ templates/ # Legacy YAML files (auto-migrated to DB)
βββ rules/ # Legacy JSON files (auto-migrated to DB)
`$3
- Drizzle ORM: 3-10x faster CRUD operations with type-safe queries
- Vector Storage: AI-powered semantic search and similarity matching
- Automatic Migration: Seamless migration from file-based to hybrid storage
- Performance: Optimized database operations with indexing and caching
- Type Safety: Full TypeScript support with compiled queries
Hybrid Storage Implementation
The code-guider now uses a hybrid storage approach that combines the best of both worlds:
$3
- 3-10x faster CRUD operations compared to file-based storage
- Type-safe queries with full TypeScript support
- Database indexing for optimized lookups
- ACID transactions for data integrity
- Connection pooling and query optimization
$3
- Semantic search using vector embeddings
- Similarity matching for finding related code
- AI-powered suggestions based on content similarity
- Pattern recognition across your codebase
$3
The system automatically migrates from the legacy file-based storage to the new hybrid approach:
`bash
Run migration (first time only)
npm run migrate
`This will:
1. Create the SQLite database with proper schema
2. Migrate existing workflows, templates, and rules
3. Generate vector embeddings for semantic search
4. Preserve all existing data and functionality
$3
| Operation | File-based | Hybrid Storage | LibSQL | Improvement |
| ------------------ | ----------------- | --------------- | ----------------- | ----------------- |
| Write (100 items) | 50-100ms | 10-20ms | 3-8ms | 6-15x faster |
| Read (100 items) | 20-50ms | 5-15ms | 2-5ms | 4-20x faster |
| Search (100 items) | 30-80ms | 2-10ms | 1-3ms | 10-25x faster |
| Build Time | 2-5s (tsc) | 1-2s (tsc) | 200-500ms (bun) | 4-10x faster |
| Memory Usage | High (all data) | Low (streaming) | Minimal (pure JS) | 5-50x less |
| Concurrent Reads | Poor (file locks) | Excellent (WAL) | Excellent (WAL) | 3-10x better |
MCP Functions
The Code Guider MCP Server provides 13 consolidated functions that replace the previous 47 individual functions, offering a cleaner and more organized API:
$3
- Actions:
list, get, create, execute
- Purpose: Unified workflow management operations
- Example: { action: 'list', search: 'authentication' }$3
- Actions:
list, create
- Purpose: Unified template management operations
- Example: { action: 'create', template: {...} }$3
- Types:
guidance, validation, ai_analysis, similar_code
- Purpose: Unified code analysis operations
- Example: { analysisType: 'ai_analysis', filePath: '...', projectPath: '...' }$3
- Actions:
list, create
- Purpose: Unified quality rules management
- Example: { action: 'create', rule: {...} }$3
- Types:
workflows, templates, code
- Purpose: Unified semantic search across different content types
- Example: { type: 'workflows', query: 'user authentication' }$3
- Actions:
execute, execute_ai, execute_roles, status, pause, resume
- Purpose: Unified execution management operations
- Example: { action: 'execute_roles', workflowId: '...', projectPath: '...' }$3
- Actions:
list, guidance
- Purpose: Unified role management operations
- Example: { action: 'guidance', roleId: 'architect' }$3
- Types:
data, workflows, templates, quality_rules
- Purpose: Unified AI-powered migration operations
- Example: { type: 'data', instruction: 'migrate all workflows to new format' }$3
- Actions:
list, init, auto_init, info, sync
- Purpose: Unified project management operations with Anubis-style auto-detection
- Example: { action: 'auto_init', projectPath: '/path/to/project' }$3
- Actions:
save, search, list, get, stats
- Purpose: Unified memory management operations
- Example: { action: 'save', content: '...', type: 'best_practice', category: 'technical' }$3
- Actions:
enhance_request, init_project, list, create
- Purpose: Unified memory rules management
- Example: { action: 'enhance_request', request: '...', context: {...} }$3
- Purpose: Get detailed metrics for a workflow execution
- Example:
{ executionId: 'exec_123' }$3
- Purpose: Transition to a different role in workflow execution
- Example:
{ executionId: 'exec_123', toRoleId: 'architect' }Benefits of Consolidation
1. Reduced Function Count: 72% reduction (47 β 13 functions)
2. More MCP Slots: 27 additional slots for other MCP servers
3. Cleaner API: Logical grouping of related operations
4. Easier Maintenance: Fewer functions to maintain
5. Better Organization: Related operations grouped together
6. Consistent Interface: All functions follow similar patterns
Usage Examples
$3
#### Project Management (Anubis-Style Auto-Detection)
`typescript
// π Auto-initialize project with full tech stack detection
const project = await mcpClient.callTool('manage_projects', {
action: 'auto_init',
projectPath: '/path/to/your/project',
});// This will automatically:
// β
Scan your project files
// β
Detect React + TypeScript + Vite + Tailwind + Prisma + Jest
// β
Create project-specific memory rules
// β
Set up tech stack-specific workflows
// β
Initialize project database
// Get detailed project info
const info = await mcpClient.callTool('manage_projects', {
action: 'info',
projectPath: '/path/to/your/project',
});
// Results show full tech stack:
// π§ Tech Stack:
// Frameworks: react, next
// Languages: typescript, javascript
// Tools: vite, tailwindcss, jest, testing-library
// Databases: prisma
// Deployment: vercel
`#### Workflow Management
`typescript
// List workflows
const workflows = await mcpClient.callTool('manage_workflows', {
action: 'list',
search: 'authentication'
});// Create a new workflow
const newWorkflow = await mcpClient.callTool('manage_workflows', {
action: 'create',
workflow: {
name: 'React Component Generator',
description: 'Generate React components with TypeScript',
steps: [...],
qualityChecks: [...]
}
});
// Execute a workflow
const result = await mcpClient.callTool('manage_workflows', {
action: 'execute',
workflowId: 'react-component',
projectPath: '/path/to/project',
variables: { ComponentName: 'UserProfile' }
});
`#### Code Analysis
`typescript
// AI-powered code analysis
const analysis = await mcpClient.callTool('analyze_code', {
analysisType: 'ai_analysis',
filePath: '/path/to/component.tsx',
projectPath: '/path/to/project',
projectType: 'react',
});// Get code guidance
const guidance = await mcpClient.callTool('analyze_code', {
analysisType: 'guidance',
filePath: '/path/to/component.tsx',
projectPath: '/path/to/project',
});
// Find similar code
const similarCode = await mcpClient.callTool('analyze_code', {
analysisType: 'similar_code',
filePath: '/path/to/component.tsx',
projectPath: '/path/to/project',
limit: 5,
});
`#### Semantic Search
`typescript
// Search workflows
const workflows = await mcpClient.callTool('semantic_search', {
type: 'workflows',
query: 'create a user authentication component',
limit: 5,
});// Search templates
const templates = await mcpClient.callTool('semantic_search', {
type: 'templates',
query: 'API endpoint with error handling',
limit: 3,
});
// Search code patterns
const codePatterns = await mcpClient.callTool('semantic_search', {
type: 'code',
query: 'React hooks pattern',
filePath: '/path/to/component.tsx',
projectPath: '/path/to/project',
});
`#### Execution Management
`typescript
// Execute with roles
const result = await mcpClient.callTool('manage_execution', {
action: 'execute_roles',
workflowId: 'react-component',
projectPath: '/path/to/project',
agentType: 'cursor',
variables: { ComponentName: 'UserProfile' },
});// Get execution status
const status = await mcpClient.callTool('manage_execution', {
action: 'status',
executionId: 'exec-123',
});
// Pause execution
await mcpClient.callTool('manage_execution', {
action: 'pause',
executionId: 'exec-123',
reason: 'User requested pause',
});
`#### Memory Management
`typescript
// Save a memory
await mcpClient.callTool('manage_memories', {
action: 'save',
content: 'Use React.memo for expensive components',
type: 'best_practice',
category: 'technical',
tags: ['react', 'performance'],
});// Search memories
const memories = await mcpClient.callTool('manage_memories', {
action: 'search',
query: 'React performance optimization',
scope: 'global',
limit: 10,
});
// Get memory statistics
const stats = await mcpClient.callTool('manage_memories', {
action: 'stats',
});
`#### AI Migration
`typescript
// Migrate data with AI
const migration = await mcpClient.callTool('ai_migrate', {
type: 'data',
instruction:
'migrate all workflows to new format with enhanced quality checks',
source: 'file-based',
target: 'hybrid-storage',
options: { dryRun: true, backup: true },
});// Migrate workflows
const workflowMigration = await mcpClient.callTool('ai_migrate', {
type: 'workflows',
transformation: 'add new quality checks and update step format',
filters: { tags: ['react', 'component'] },
});
`Migration Notes
- All existing functionality is preserved
- Performance impact is negligible
- The consolidation uses action/type parameters to differentiate operations
- Error handling and validation remain the same
- All return formats remain unchanged
Development
$3
`
src/
βββ index.ts # Entry point
βββ mcp-server.ts # MCP server implementation
βββ hybrid-storage.ts # Hybrid storage implementation
βββ storage-interface.ts # Unified storage interface
βββ storage.ts # Legacy file-based storage
βββ vector-storage.ts # AI-powered vector storage
βββ guidance-engine.ts # Workflow execution engine
βββ db/
β βββ connection.ts # Database connection management
β βββ drizzle-storage.ts # Drizzle ORM operations
β βββ schema.ts # Database schema definitions
βββ enhanced-workflow-engine.ts # Enhanced workflow execution
βββ execution-tracker.ts # Workflow execution tracking
βββ ai-guidance-engine.ts # AI-powered guidance engine
βββ role-manager.ts # Role-based workflow management
βββ migrate.ts # Database migration script
βββ types.ts # TypeScript type definitions
`$3
-
npm run build - Build the project using TypeScript compiler
- npm run build:all - Build all entry points (index.js and migrate.js)
- npm run dev - Build and run the server
- npm start - Run the built server
- npm run migrate - Run database migration (first time setup)
- npm run db:generate - Generate Drizzle migrations
- npm run db:migrate - Apply Drizzle migrations
- npm run db:studio - Open Drizzle Studio (database GUI)
- npm test - Run tests with Jest
- npm run lint - Run Biome linting on src/
- npm run lint:fix - Fix linting issues automatically
- npm run format - Format code with Biome
- npm run check - Run both linting and formatting checks
- npm run check:fix - Fix both linting and formatting issues
- npm run check:all - Check entire project
- npm run format:all - Format entire project
- npm run lint:all - Lint entire projectNote: All scripts use npm and standard Node.js tools. The migration script automatically handles the transition from file-based storage to hybrid storage with LibSQL.
$3
The Code Guider now includes intelligent migration tools that understand natural language instructions:
- Natural Language Commands: Tell the AI what to migrate in plain English
- Smart Transformation: AI automatically transforms data based on your instructions
- Safe Migration: Built-in backup, dry-run preview, and validation features
- Flexible Filtering: Migrate specific data based on tags, dates, types, and patterns
- Rollback Support: Automatic backup creation before any migration
- Validation: Post-migration validation ensures data integrity
Example Commands:
- "migrate all workflows to new format with enhanced quality checks"
- "convert templates to new schema and add missing fields"
- "update quality rules severity levels and merge duplicates"
- "transform React component templates to use new variable syntax"
$3
The project has been fully migrated to use LibSQL instead of better-sqlite3:
- Cross-platform compatibility - works with both Bun and Node.js
- Zero native dependencies - no compilation issues
- SQLite-compatible - drop-in replacement for SQLite
- Better performance than better-sqlite3
- Simplified deployment with no native module requirements
$3
The project uses TypeScript compiler for reliable and consistent builds:
- Standard TypeScript compilation for maximum compatibility
- Type checking during build process
- Incremental compilation for faster subsequent builds
- Source maps for better debugging experience
- Cross-platform compatibility with all Node.js environments
$3
1. Define the tool in
mcp-server.ts in the ListToolsRequestSchema handler
2. Add the tool handler in the CallToolRequestSchema handler
3. Implement the tool logic
4. Update documentationCode Quality & Formatting
$3
This project uses Biome for linting and formatting, providing a fast and comprehensive code quality solution optimized for Node.js:
#### Features
- β‘ Ultra-fast: 10-100x faster than ESLint + Prettier
- π§ All-in-one: Linting, formatting, and import organization
- π― Zero config: Works out of the box with sensible defaults
- π Node.js optimized: Native integration with Node.js runtime
- π Comprehensive rules: 200+ linting rules for code quality
- π¨ Consistent formatting: Automatic code formatting and style enforcement
#### Configuration
The project includes a comprehensive
biome.json configuration that enforces:Code Quality Rules:
- β
No unused imports, variables, or functions
- β
No unused classes, interfaces, types, or enums
- β
No unused constants or parameters
- β
DRY (Don't Repeat Yourself) code enforcement
- β
No commented code (except TODO comments)
- β
Consistent code style and formatting
File Coverage:
- TypeScript and JavaScript files
- Scripts directory
- Configuration files
- Excludes test files, build artifacts, and dependencies
Formatting Standards:
- 2-space indentation
- Single quotes for strings
- Semicolons always
- 100 character line width
- LF line endings
- Trailing commas (ES5 style)
#### Available Scripts
`bash
Linting
npm run lint # Lint src/ directory
npm run lint:fix # Fix linting issues automatically
npm run lint:all # Lint entire project
npm run lint:all:fix # Fix all linting issuesFormatting
npm run format # Format src/ directory
npm run format:all # Format entire projectCombined checks
npm run check # Check src/ (lint + format)
npm run check:fix # Fix src/ (lint + format)
npm run check:all # Check entire project
npm run check:all:fix # Fix entire projectPre-commit hooks
npm run pre-commit:install # Install pre-commit hooks
npm run pre-commit:run # Run pre-commit checks
npm run pre-commit # Install and run pre-commit checks
`#### Pre-commit Hooks
The project includes pre-commit hooks that automatically run:
1. Biome Check: Linting and formatting validation
2. TypeScript Check: Type checking with
tsc --noEmit
3. Test Check: Run test suite
4. Format Check: Ensure code is properly formattedTo set up pre-commit hooks:
`bash
Install pre-commit hooks
npm run pre-commit:installRun all checks manually
npm run pre-commit:run
`#### IDE Integration
For the best development experience, install the Biome extension in your IDE:
- VS Code: Biome extension
- Cursor: Built-in support
- WebStorm/IntelliJ: Biome plugin
#### Configuration Details
The
biome.json configuration includes:- Extended config: Uses
@canonical/biome-config for consistency
- Comprehensive rules: 200+ linting rules across correctness, style, suspicious, complexity, performance, and security
- File patterns: Includes TypeScript, JavaScript, and JSON files
- Test overrides: Relaxed rules for test files
- Import organization: Automatic import sorting and organization
- Format consistency: Unified formatting across all file types#### Performance Benefits
- 10-100x faster than ESLint + Prettier
- Single tool instead of multiple tools
- Native Node.js integration for optimal performance
- Parallel processing for large codebases
- Incremental checking for faster subsequent runs
Configuration
$3
The project configuration is stored in
.guidance/config/project.json:`json
{
"name": "my-project",
"type": "react",
"frameworks": ["react", "typescript"],
"languages": ["typescript", "javascript"],
"qualityRules": ["no-unused-imports", "no-any-types"],
"workflows": ["react-component", "api-endpoint"],
"templates": ["react-component", "api-endpoint"]
}
``1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests if applicable
5. Submit a pull request
MIT License - see LICENSE file for details
For questions and support, please open an issue on GitHub.