Smart MCP
A global framework for creating reusable command shortcuts and slash commands that work across any directory. It enables systematic code refactoring, debugging, and auditing through a hierarchical configuration system with global defaults and project-specific overrides.
README
Smart MCP
SuperClaude-style global MCP framework for custom instruction shortcuts. Create reusable command shortcuts that work from ANY directory.
What is Smart MCP?
Smart MCP is a Model Context Protocol (MCP) server that provides:
- Slash Commands - Global
/sm:*commands accessible from any directory - Smart Tool -
smMCP tool for executing custom instruction shortcuts - Hierarchical Configuration - Global defaults with project-specific overrides
Current Implementation
| Component | Status | Lines | Description |
|---|---|---|---|
| MCP Server | ✅ Production | ~100 | Python server with hierarchical shortcuts loading |
| /sm:refactor | ✅ Ready | 183 lines | Surgical refactoring with golden-master testing |
| /sm:debug | ✅ Ready | 129 lines | 7-step systematic debugging process |
| /sm:audit | ✅ Ready | 204 lines | 8-stage repository assessment |
| /sm:introspect | ✅ Ready | 247 lines | Meta-cognitive solution analysis |
Latest Update: Fixed /sm:introspect synchronization bug - all 4 commands now fully global (2025-11-06)
Features
- Global Architecture: Works from any directory once configured
- Hierarchical Shortcuts: Global defaults + project-specific overrides
- Single Tool Interface: All shortcuts accessible via one
smtool - Slash Commands:
/sm:refactor,/sm:debug,/sm:audit,/sm:introspectwork everywhere - JSON-Based Storage: Easy to read and edit shortcut definitions
- Variable Substitution: Use
{task},{file},{context}, or{target}placeholders - Extensible: Add global or project-specific shortcuts
Architecture
Dual-Interface System
Smart MCP uses a two-stage architecture combining Claude Code slash commands with an MCP server:
┌─────────────────────────────────────────────┐
│ Stage 1: Slash Commands (.md files) │
│ Location: ~/.claude/commands/sm/*.md │
│ Purpose: Discovery, documentation, metadata │
└─────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────┐
│ Stage 2: MCP Server (shortcuts.json) │
│ Location: ~/.claude/smart_mcp/shortcuts.json│
│ Purpose: Instruction storage, variables │
└─────────────────────────────────────────────┘
File Structure
~/.claude/ # Global SuperClaude configuration
├── smart_mcp/
│ └── shortcuts.json # Global instruction storage (REQUIRED)
├── commands/sm/
│ ├── refactor.md # /sm:refactor interface (REQUIRED)
│ ├── debug.md # /sm:debug interface (REQUIRED)
│ ├── audit.md # /sm:audit interface (REQUIRED)
│ └── introspect.md # /sm:introspect interface (REQUIRED)
├── MCP_SmartMCP.md # Integration documentation
└── CLAUDE.md # Global working contract
Project (Optional Override):
$CWD/shortcuts.json # Project-specific shortcuts
Synchronization Requirement
CRITICAL: Both components must be deployed together:
- ✅
.md filein~/.claude/commands/sm/(interface) - ✅ Entry in
~/.claude/smart_mcp/shortcuts.json(implementation)
Missing either component will cause the command to fail.
Merge Strategy: Project-local shortcuts override global (like .gitignore)
Quick Start
Installation
- Install the MCP server:
git clone https://github.com/btangonan/smart_mcp.git
cd smart_mcp
./scripts/install.sh
- Configure Claude Desktop:
{
"mcpServers": {
"smart-mcp": {
"type": "stdio",
"command": "python3",
"args": ["/absolute/path/to/smart_mcp/smart_mcp.py"],
"env": {}
}
}
}
- Restart Claude Desktop
Usage
Slash Commands (Global)
/sm:refactor auth.ts # Surgical refactoring with testing
/sm:debug login-error # 7-step debugging process
/sm:audit # Repository assessment
/sm:introspect # Meta-cognitive analysis
Smart Tool (Via MCP)
// In Claude Code conversations
sm { "shortcut": "refactor", "context": "auth.ts" }
sm { "shortcut": "debug", "context": "login-error" }
Available Commands
/sm:refactor
Purpose: Surgical refactoring with golden-master testing and fitness functions
Use When:
- Need to improve code quality without changing behavior
- Want systematic refactoring with safety validation
- Reducing technical debt methodically
Key Features:
- Pre/post behavior capture for safety
- Fitness functions for quality metrics
- Incremental improvements with validation
/sm:debug
Purpose: 7-step systematic debugging process
Use When:
- Facing complex bugs or unexpected behavior
- Need structured approach to problem-solving
- Want to avoid debugging anti-patterns
Key Features:
- Evidence-based hypothesis generation
- Systematic root cause analysis
- Solution validation framework
/sm:audit
Purpose: 8-stage comprehensive repository assessment
Use When:
- Need to assess codebase health
- Preparing for technical debt reduction
- Evaluating project maturity
Key Features:
- LOC discipline analysis
- Validation coverage assessment
- Secrets hygiene scanning
- Maturity scoring (0-3 scale)
/sm:introspect
Purpose: Meta-cognitive analysis for solution soundness evaluation
Use When:
- Unsure if solving the RIGHT problem
- Need to validate approach before implementation
- Want to detect cognitive biases
Key Features:
- Naive-agent perspective reset
- Alternative hypothesis generation (min 3)
- Cognitive bias detection
- Soundness scoring with recommendations
Configuration
Global Shortcuts
Located at ~/.claude/smart_mcp/shortcuts.json:
{
"shortcuts": {
"refactor": {
"description": "Surgical refactoring with golden-master testing",
"instruction": "..."
},
"debug": {
"description": "7-step debugging process",
"instruction": "..."
},
"audit": {
"description": "Repository assessment",
"instruction": "..."
},
"introspect": {
"description": "Meta-cognitive analysis",
"instruction": "..."
}
}
}
Project-Specific Shortcuts
Create shortcuts.json in your project directory:
{
"shortcuts": {
"deploy": {
"description": "Deploy to staging",
"instruction": "Deploy {target} to staging environment with pre-flight checks"
},
"refactor": {
"description": "Custom refactor for this project",
"instruction": "Project-specific refactoring rules..."
}
}
}
Merge Behavior:
deploy- Available only in this project (new shortcut)refactor- Uses project version (overrides global)debug,audit,introspect- Use global versions (no override)
Management Scripts
Backup Global Files
./scripts/backup.sh # Copy ~/.claude/ → global/
./scripts/backup.sh --commit # Backup and auto-commit
./scripts/backup.sh --dry-run # Preview changes
Install Global Files
./scripts/install.sh # Copy global/ → ~/.claude/
./scripts/install.sh --force # Overwrite without prompt
./scripts/install.sh --dry-run # Preview installation
Sync and Check Status
./scripts/sync.sh # Check sync status
./scripts/sync.sh --to-global # Force ~/.claude/ → global/
./scripts/sync.sh --to-claude # Force global/ → ~/.claude/
Documentation
- FOR_FUTURE_CLAUDE.md - Complete system overview for new agents
- GLOBAL_SETUP.md - Detailed installation and setup guide
- IMPLEMENTATION_SUMMARY.md - Technical architecture details
Troubleshooting
Slash commands not appearing
Problem: /sm:refactor shows "command not found"
Solution:
# Verify files exist
ls ~/.claude/commands/sm/
# Should show: audit.md, debug.md, introspect.md, refactor.md
# If missing, run: ./scripts/install.sh
MCP tool not available
Problem: sm tool returns "No such tool available"
Solution:
- Check Claude Desktop config has correct absolute path to
smart_mcp.py - Restart Claude Desktop completely
- Start new Claude Code session
- If still failing, check MCP server logs
Shortcuts not loading
Problem: sm tool works but returns empty or old shortcuts
Solution:
# Verify shortcuts.json exists
cat ~/.claude/smart_mcp/shortcuts.json
# Check for JSON syntax errors
python3 -m json.tool ~/.claude/smart_mcp/shortcuts.json
# If corrupted, restore from repo
./scripts/install.sh --force
Chroma MCP race condition
Problem: First Chroma call fails with "No such tool available"
Solution: This is handled automatically by global CLAUDE.md Session Lifecycle rules - waits 2 seconds and retries once. If persists, verify Chroma MCP server is configured in Claude Desktop.
Development
Project Structure
smart_mcp/
├── smart_mcp.py # MCP server with hierarchical loading
├── shortcuts.json # Example/override shortcuts
├── CLAUDE.md # Project-specific contract
├── README.md # This file
├── .claude/
│ └── commands/sm/ # Reference commands (deprecated)
├── global/ # Version-controlled global files
│ ├── CLAUDE.md # Global SuperClaude framework
│ ├── commands/sm/ # Canonical slash commands
│ ├── smart_mcp/shortcuts.json
│ └── MCP_SmartMCP.md
├── scripts/ # Management scripts
│ ├── install.sh
│ ├── backup.sh
│ └── sync.sh
├── docs/ # Documentation
└── archive/ # Obsolete planning documents
Adding New Slash Commands
IMPORTANT: Both .md file AND shortcuts.json entry are required. Missing either breaks the command.
Step-by-Step Process:
-
Create .md file:
global/commands/sm/commandname.md--- name: commandname description: "Brief one-line description" category: gitignored complexity: basic|intermediate|advanced mcp-servers: [sequential, chroma] personas: [architect, auditor] --- # Documentation sections # See existing commands for template ## Invocation This command executes: `Use the sm tool with shortcut='commandname' and context='$ARGS'` -
Add to shortcuts.json:
global/smart_mcp/shortcuts.json{ "shortcuts": { "commandname": { "description": "Same as .md description", "instruction": "Full instruction framework with {task} {context} placeholders" } } } -
Deploy:
./scripts/install.sh(copies to ~/.claude/) -
Verify:
ls ~/.claude/commands/sm/commandname.md grep "commandname" ~/.claude/smart_mcp/shortcuts.json # CRITICAL: Test from outside repo to verify global deployment cd /tmp && /sm:commandname test -
Commit:
./scripts/backup.sh --commit
Project-Local Shortcut (override global):
- Create
shortcuts.jsonin project directory - Add shortcuts (same format as global)
- Project shortcuts override global (hierarchical merge)
Creating Slash Commands
- Create markdown file in
~/.claude/commands/sm/ - Add YAML frontmatter:
---
tags: project, gitignored
---
- Write command instructions
- Optionally add to shortcuts.json for
smtool access
Benefits
✅ Global Accessibility - Commands work from ANY directory
✅ SuperClaude Integration - Follows /sc:* command pattern
✅ Hierarchical Config - Global defaults + project overrides
✅ Version Controlled - Global files backed up in repo
✅ Zero Duplication - No copying commands to every project
✅ Extensible - Easy to add custom shortcuts
✅ Maintainable - Clear separation of global vs project config
Limitations
- Absolute Paths Required - Claude Desktop config needs absolute path to
smart_mcp.py - Restart Required - Claude Desktop restart needed for config/shortcut changes
- JSON Validation - Invalid JSON in shortcuts.json fails silently
- No Hot Reload - Shortcut changes require new Claude Code session
Contributing
- Fork the repository
- Create feature branch
- Make changes
- Test with
./scripts/install.sh --dry-run - Backup and commit:
./scripts/backup.sh --commit - Submit pull request
License
MIT License - See LICENSE file for details
Credits
Built with the SuperClaude framework pattern for global Claude Code configuration.
Changelog
2025-10-23
- Added Chroma MCP race condition fix to global CLAUDE.md
- Cleaned up documentation structure
- Archived obsolete planning documents
- Updated README to reflect actual implementation
2025-10-19
- Added
/sm:introspectcommand for meta-cognitive analysis - Enhanced global file management with backup/sync scripts
2025-10-17
- Transformed to global SuperClaude-style framework
- Implemented hierarchical shortcuts loading
- Created global slash commands (/sm:refactor, /sm:debug, /sm:audit)
- Added comprehensive documentation
2025-10-16
- Initial project creation
- Basic MCP server implementation
- Project-local slash commands
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。