UNPKG

mcp-context-engineering

Version:

The intelligent context optimization system for AI coding assistants. Built with Cole's PRP methodology, Context Portal knowledge graphs, and production-ready MongoDB architecture.

303 lines (237 loc) β€’ 9.38 kB
# Universal Context Engineering MCP Server [![TypeScript](https://img.shields.io/badge/TypeScript-007ACC?style=for-the-badge&logo=typescript&logoColor=white)](https://www.typescriptlang.org/) [![MongoDB](https://img.shields.io/badge/MongoDB-4EA94B?style=for-the-badge&logo=mongodb&logoColor=white)](https://www.mongodb.com/) [![Node.js](https://img.shields.io/badge/Node.js-43853D?style=for-the-badge&logo=node.js&logoColor=white)](https://nodejs.org/) [![MCP](https://img.shields.io/badge/MCP-Protocol-blue?style=for-the-badge)](https://modelcontextprotocol.io/) **The intelligent context optimization system for AI coding assistants** Transform your AI coding experience with systematic context engineering that gets smarter over time. Built with Cole's proven PRP methodology, Context Portal knowledge graphs, and production-ready MongoDB architecture. --- ## 🌟 **Why Universal Context Engineering?** Traditional AI coding assistants work with static context. This MCP server creates **dynamic, intelligent context** that: - πŸ“ˆ **Learns and improves** from every interaction - 🎯 **Optimizes for your specific AI agent** (Cursor, Windsurf, Claude Code, etc.) - 🧠 **Applies proven methodologies** (Cole's PRP + Context Portal patterns) - πŸš€ **Scales with MongoDB** for production workloads - πŸ”— **Builds knowledge graphs** of successful patterns --- ## ⚑ **Quick Start** ### Prerequisites - Node.js 18.12+ - MongoDB (local or Atlas) - AI coding assistant with MCP support ### 1. Install & Setup ```bash git clone https://github.com/romiluz13/mcp-context-engineering.git cd mcp-context-engineering npm install cp .env.example .env ``` ### 2. Configure Environment Edit `.env` with your settings: ```env MONGODB_URI=mongodb://localhost:27017 MONGODB_DATABASE=universal_context_engineering VOYAGE_API_KEY=your_voyage_ai_key OPENAI_API_KEY=your_openai_key ``` ### 3. Build & Start ```bash npm run build npm start ``` ### 4. Add to Your AI Agent **For Claude Code/Desktop:** ```json { "mcpServers": { "universal-context-engineering": { "command": "node", "args": ["dist/src/index.js"], "cwd": "/path/to/mcp-context-engineering", "env": { "MONGODB_URI": "mongodb://localhost:27017", "MONGODB_DATABASE": "universal_context_engineering", "VOYAGE_API_KEY": "your_key", "OPENAI_API_KEY": "your_key" } } } } ``` **For Cursor/Windsurf:** Similar configuration in your MCP settings. --- ## 🎯 **Core Features** ### πŸ“‹ **MCP Tools Available** | Tool | Purpose | What It Does | |------|---------|--------------| | `generate_universal_prp` | **Generate Smart PRPs** | Creates comprehensive implementation plans using Cole's methodology | | `get_universal_context` | **Retrieve Context** | Gets optimized context for your specific AI agent and project | | `search_similar_patterns` | **Find Patterns** | Semantic search for similar successful implementations | | `store_context_pattern` | **Save Patterns** | Stores successful patterns for future learning | | `update_pattern_effectiveness` | **Learning Loop** | Updates pattern effectiveness based on results | | `get_cross_agent_insights` | **Analytics** | Cross-agent performance insights and recommendations | ### πŸ€– **Universal AI Agent Support** - **Cursor**: Concise, action-focused context - **Windsurf**: Step-by-step with comprehensive error handling - **Claude Code**: Full PRP methodology with detailed analysis - **Generic**: Balanced approach for any MCP-compatible agent --- ## πŸš€ **Example Usage** ### Generate a Universal PRP ```javascript { "tool": "generate_universal_prp", "arguments": { "feature_description": "Implement JWT authentication with role-based access control", "project_context": { "project_id": "my-web-app", "tech_stack": ["react", "typescript", "express", "mongodb"], "complexity_preference": "medium" }, "agent_type": "claude_code", "research_depth": "comprehensive" } } ``` ### Get Project Context ```javascript { "tool": "get_universal_context", "arguments": { "project_id": "my-web-app", "agent_type": "cursor", "query": "authentication patterns", "min_effectiveness": 7 } } ``` ### Search Similar Patterns ```javascript { "tool": "search_similar_patterns", "arguments": { "query": "JWT authentication implementation", "filters": { "tech_stacks": ["react", "express"], "complexity": "medium" }, "agent_type": "windsurf" } } ``` --- ## πŸ—οΈ **Architecture** ``` β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ AI Agent β”‚ β”‚ MCP Server β”‚ β”‚ MongoDB β”‚ β”‚ (Cursor, etc.) │◄──►│ Context Engine │◄──►│ Knowledge β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚ Base β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚ Vector Search β”‚ β”‚ (Voyage AI) β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ ``` **Core Components:** - **MCP Server**: TypeScript-based with comprehensive error handling - **Context Engine**: Cole's PRP methodology + Context Portal patterns - **Knowledge Base**: MongoDB with vector search capabilities - **Learning System**: Effectiveness tracking and continuous improvement - **Universal Optimizer**: Agent-specific context formatting --- ## πŸ“Š **What Makes It Special** ### 🧠 **Cole's PRP Methodology** Systematic approach: **Research** β†’ **Blueprint** β†’ **Validation** - Comprehensive codebase analysis - External research integration - Step-by-step implementation plans - Quality validation frameworks ### πŸ•ΈοΈ **Context Portal Knowledge Graphs** - Relationship-aware context connections - Decision tracking and history - Pattern dependencies and conflicts - Cross-project knowledge sharing ### πŸ“ˆ **Learning Intelligence** - Tracks what works for each AI agent - Improves recommendations over time - Cross-agent effectiveness insights - Continuous pattern optimization --- ## βš™οΈ **Configuration** ### Environment Variables ```env # MongoDB Configuration MONGODB_URI=mongodb://localhost:27017 MONGODB_DATABASE=universal_context_engineering # AI Services (Required) VOYAGE_API_KEY=your_voyage_ai_key OPENAI_API_KEY=your_openai_key # Optional Configuration NODE_ENV=development LOG_LEVEL=info DEBUG_MONGODB_OPERATIONS=false VECTOR_DIMENSIONS=1024 ``` ### MongoDB Setup **Local MongoDB:** ```bash # Install MongoDB locally brew install mongodb/brew/mongodb-community brew services start mongodb/brew/mongodb-community ``` **MongoDB Atlas:** - Create cluster at [MongoDB Atlas](https://cloud.mongodb.com/) - Get connection string - Update `MONGODB_URI` in `.env` --- ## πŸ› οΈ **Development** ### Scripts ```bash npm run dev # Development with hot reload npm run build # TypeScript compilation npm run start # Production server npm run test # Run tests npm run lint # Code linting npm run format # Code formatting ``` ### Project Structure ``` src/ β”œβ”€β”€ config/ # Environment configuration β”œβ”€β”€ context/ # Context engineering logic β”‚ └── methodology/ # PRP generation & research β”œβ”€β”€ mcp/ # MCP server implementation β”œβ”€β”€ mongodb/ # Database models & operations β”‚ β”œβ”€β”€ models/ # Data schemas β”‚ └── operations/ # CRUD operations └── index.ts # Server entry point ``` --- ## 🀝 **Contributing** We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines. ### Quick Contributing Steps: 1. Fork the repository 2. Create feature branch (`git checkout -b amazing-feature`) 3. Commit changes (`git commit -m 'Add amazing feature'`) 4. Push to branch (`git push origin amazing-feature`) 5. Open Pull Request --- ## πŸ“œ **License** This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details. --- ## πŸ†˜ **Support** - **Documentation**: Check the `/docs` folder for detailed guides - **Issues**: [GitHub Issues](https://github.com/romiluz13/mcp-context-engineering/issues) - **Discussions**: [GitHub Discussions](https://github.com/romiluz13/mcp-context-engineering/discussions) --- ## πŸ† **Acknowledgments** - **Cole's PRP Methodology** - Systematic context engineering approach - **Context Portal** - Knowledge graph patterns and relationship management - **MongoDB MCP Community** - Production-ready database integration patterns - **Model Context Protocol** - Universal AI agent communication standard --- ## 🌟 **Star History** [![Star History Chart](https://api.star-history.com/svg?repos=romiluz13/mcp-context-engineering&type=Date)](https://star-history.com/#romiluz13/mcp-context-engineering&Date) --- **πŸš€ Transform your AI coding experience with intelligent context engineering!** *Built with ❀️ for the AI coding community*