Package Exports
- @stackguide/mcp-server
- @stackguide/mcp-server/dist/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@stackguide/mcp-server) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
StackGuide MCP Server
Dynamic context loading for AI coding assistants. Works with Cursor and GitHub Copilot.
๐ Quick Start
Cursor (.cursor/mcp.json):
{
"mcpServers": {
"stackguide": {
"command": "npx",
"args": ["-y", "@stackguide/mcp-server"]
}
}
}VS Code (.vscode/mcp.json): Same config as above.
๐ฌ Usage
Just talk naturally:
- "Set up my project" โ Auto-configures with interactive wizard
- "Review my code" โ Analyzes with AST-powered Quick Fixes
- "Generate a component" โ Creates boilerplate code
- "Check project health" โ Returns health score (A-F)
- "Analyze my project" โ Auto-configuration intelligence
- "Browse React rules" โ Shows community rules
- "Configure rules" โ NEW! Customize analysis rules
๐ ๏ธ Tools (13 total)
Core Tools
| Tool | Description | Example |
|---|---|---|
setup |
Configure project with wizard | setup or setup type:"react-typescript" |
context |
View current configuration | context or context full:true |
rules |
List, search, get rules | rules action:"search" query:"security" |
knowledge |
Access patterns & solutions | knowledge action:"get" query:"architecture" |
review |
Review code with Quick Fixes | review file:"src/index.ts" focus:"security" |
Advanced Features
| Tool | Description | Example |
|---|---|---|
generate |
Generate boilerplate code | generate type:"component" name:"UserCard" |
health |
Project health score (A-F) | health detailed:true |
analyze |
NEW! Project intelligence | analyze action:"full" path:"./my-project" |
Integration Tools
| Tool | Description | Example |
|---|---|---|
cursor |
Browse cursor.directory | cursor action:"browse" query:"react" |
docs |
Fetch web documentation | docs action:"fetch" url:"https://..." |
config |
Save/load configurations | config action:"save" name:"my-project" |
custom_rule |
Create custom rules | custom_rule action:"create" name:"..." content:"..." |
help |
Get help | help or help topic:"generate" |
New in v2.4.0: Advanced Features
๐ญ Template Generator
Generate boilerplate for components, hooks, services, tests, API routes, models, and utilities:
generate type:"component" name:"UserCard"
generate type:"hook" name:"useAuth"
generate type:"service" name:"ApiService"
generate type:"test" name:"UserCard" options:{"framework":"vitest"}
generate type:"api" name:"Users" options:{"framework":"nextjs"}๐ง Quick Fix Suggestions
Code review now includes actionable Quick Fixes:
๐ด [SEC001] Avoid using eval() - it can execute arbitrary code
- Line: 15
- Code: `eval(userInput)`
- ๐ง Quick Fix: Replace eval() with JSON.parse()
- Replace: `eval(` โ With: `JSON.parse(`๐ฅ Project Health Score
Get a comprehensive health analysis with grade (A-F):
health detailed:trueReturns:
- Overall score (0-100) with grade
- Category breakdown (Configuration, Code Quality, Structure, Docs, Testing)
- Critical issues and recommendations
๐ง Interactive Setup Wizard
Setup now provides tailored recommendations:
{
"wizard": {
"recommendations": {
"suggestedTools": ["ESLint", "Prettier", "TypeScript strict mode"],
"vsCodeExtensions": ["ES7+ React snippets", "Error Lens"],
"tips": ["Use functional components", "Memoize with useMemo"]
},
"nextSteps": ["Run `context`", "Run `review`", "Run `health`"]
}
}๐ New in v3.7.0: Configurable Rules Engine
Custom Rules CRUD
Create, update, delete, and manage custom rules with full persistence:
# Create custom rule
rules action:"create" rule:{"id":"MY-001", "name":"Custom Rule", "description":"...", "severity":"warning", "pattern":"console\\.log"}
# Update rule
rules action:"update" ruleId:"MY-001" updates:{"severity":"error"}
# Delete rule
rules action:"delete" ruleId:"MY-001"
# List all rules (builtin + custom)
rules action:"list" category:"security"
# Import/Export rules
rules action:"export" format:"json"
rules action:"import" rules:[...]Rule Overrides
Override builtin rule behavior without modifying them:
# Disable a rule
rules action:"override" ruleId:"TS-SEC001" override:{"enabled":false}
# Change severity
rules action:"override" ruleId:"TS-PERF002" override:{"severity":"error"}
# Custom message
rules action:"override" ruleId:"TS-BP001" override:{"customMessage":"Use arrow functions in this project"}
# File-specific overrides
rules action:"override" ruleId:"TS-SEC002" override:{"filePatterns":["!**/tests/**"]}
# Remove override
rules action:"clearOverride" ruleId:"TS-SEC001"Rule Settings
Configure global rule behavior:
# Get current settings
rules action:"settings"
# Update settings
rules action:"updateSettings" settings:{"enableBuiltin":true, "enableCustom":true, "defaultSeverity":"warning"}๐ New in v3.6.0: Input Validation (Zod)
All tool inputs are now validated with Zod schemas:
- Type-safe inputs: All parameters are validated against schemas
- Helpful error messages: Clear validation errors with path information
- Path sanitization: Prevents path traversal attacks
- Automatic sanitization: Sensitive data is masked in logs
// Example validation error
{
"success": false,
"error": "Validation failed",
"issues": [
{ "path": ["file"], "message": "Required" },
{ "path": ["focus"], "message": "Invalid enum value. Expected 'security' | 'performance' | 'best-practices'" }
]
}๐ New in v3.5.0: AST-Powered Analysis (Tree-sitter)
Real Semantic Code Analysis
Code review now uses tree-sitter for accurate AST-based analysis:
review file:"src/index.ts" focus:"security"Supported Languages: TypeScript, JavaScript, Python, Go, Rust
Analysis Categories:
- ๐ Security: eval detection, SQL injection, XSS, hardcoded secrets
- โก Performance: nested loops, inefficient operations
- โจ Best Practices: any usage, console.log in production, unused vars
- ๐๏ธ Maintainability: function complexity, file length
Code Metrics:
{
"metrics": {
"linesOfCode": 150,
"functions": 12,
"classes": 3,
"imports": 8,
"exports": 5,
"complexity": 24,
"maxNesting": 4
}
}๐ New in v3.4.0: Architecture Improvements
SQLite Persistence
All configuration now persists across sessions:
config action:"save" name:"my-project"
config action:"load" name:"my-project"
config action:"list"
config action:"delete" name:"my-project"Real Filesystem Access
Analyze actual project files:
analyze action:"full" path:"./src"
health detailed:trueHTTP Client with Caching
Rate-limited API calls with automatic caching:
docs action:"fetch" url:"https://react.dev/reference/react"
cursor action:"browse" query:"nextjs"New in v3.3.0: Auto-Configuration Intelligence ๐ง
Project Intelligence Analysis
Get comprehensive analysis with actionable recommendations:
analyze action:"full" path:"./my-project"
analyze action:"structure" # Analyze only project structure
analyze action:"config" # Analyze only configurations
analyze action:"dependencies" # Analyze only dependencies
analyze action:"generate" configType:"eslint" # Generate optimal config
analyze action:"apply" # Apply all auto-fixesReturns:
- Overall Score (0-100) with grade (A-F)
- Structure Analysis: Missing dirs/files, directory organization
- Configuration Analysis: Missing ESLint, Prettier, TSConfig recommendations
- Dependency Analysis: Missing packages, security advisories
- Priority Actions: Sorted by impact with estimated effort
- Suggested Workflow: Step-by-step improvement plan
{
"overallScore": 72,
"grade": "C",
"priorityActions": [
{ "action": "Add ESLint configuration", "priority": "high", "impact": "Improves code quality" },
{ "action": "Add tests directory", "priority": "medium", "impact": "Enables testing" }
],
"suggestedWorkflow": [
{ "step": 1, "action": "Run `analyze action:generate configType:eslint`" },
{ "step": 2, "action": "Run `analyze action:generate configType:prettier`" }
]
}Enhanced Setup with Intelligence
Setup now includes quick intelligence analysis:
{
"intelligence": {
"structureScore": 85,
"configScore": 60,
"dependencyScore": 90,
"quickWins": ["Add .prettierrc for consistent formatting"]
}
}๐ Supported Stacks
python-django ยท python-fastapi ยท python-flask ยท react-node ยท react-typescript ยท vue-node ยท nextjs ยท express ยท nestjs ยท laravel ยท rails ยท golang ยท rust
๐ Examples
# Auto-setup with wizard
setup
# Generate React component
generate type:"component" name:"Dashboard"
# Review with AST-powered Quick Fixes
review file:"src/App.tsx" focus:"performance"
# Check project health
health
# Analyze project intelligence
analyze action:"full"
analyze action:"generate" configType:"prettier"
# Browse and import community rules
cursor action:"popular"
cursor action:"import" slug:"typescript-best-practices"
# Configure rules
rules action:"list" category:"security"
rules action:"create" rule:{"id":"MY-001", "name":"No TODO", "pattern":"TODO", "severity":"info"}
rules action:"override" ruleId:"TS-SEC001" override:{"severity":"error"}๐๏ธ Architecture
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ MCP Server โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Router (handler registration + validation) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Handlers (setup, review, generate, health, etc.) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Services Layer โ
โ โโโ AST Analysis (tree-sitter multi-language) โ
โ โโโ Rules Engine (builtin + custom + overrides) โ
โ โโโ Code Analyzer (semantic analysis) โ
โ โโโ Rule Manager (data loading) โ
โ โโโ Auto Detect (project type detection) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ Infrastructure โ
โ โโโ Validation (Zod schemas) โ
โ โโโ Persistence (SQLite storage) โ
โ โโโ ProjectFs (filesystem abstraction) โ
โ โโโ HttpClient (rate-limited + cached) โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ๐งช Testing
# Run all tests
npm test
# With coverage
npm run test:coverage
# Watch mode
npm run test:watchTest Statistics: 659 tests across 35 test files
๐ API Reference
Tool Parameters
setup
| Parameter | Type | Description |
|---|---|---|
type |
string | Project type (optional, auto-detected) |
path |
string | Project path (default: current dir) |
review
| Parameter | Type | Description |
|---|---|---|
file |
string | Required. File path to review |
content |
string | File content (optional, read from file) |
focus |
string | security | performance | best-practices |
detailed |
boolean | Include code metrics |
generate
| Parameter | Type | Description |
|---|---|---|
type |
string | Required. component | hook | service | test | api | model | util |
name |
string | Required. Name for generated code |
options |
object | Framework-specific options |
rules
| Parameter | Type | Description |
|---|---|---|
action |
string | Required. list | search | get | create | update | delete | override | clearOverride | settings | import | export |
ruleId |
string | Rule ID (for get/update/delete/override) |
rule |
object | Rule definition (for create) |
override |
object | Override settings |
category |
string | Filter by category |
health
| Parameter | Type | Description |
|---|---|---|
detailed |
boolean | Include category breakdown |
path |
string | Project path |
analyze
| Parameter | Type | Description |
|---|---|---|
action |
string | Required. full | structure | config | dependencies | generate | apply |
path |
string | Project path |
configType |
string | For generate: eslint | prettier | tsconfig |
๐ค Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing) - Run tests (
npm test) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing) - Open a Pull Request
๐ License
MIT