Skip to main content
Glama

Context Pods

by conorluddy
ARCHITECTURE.mdโ€ข16 kB
# Context-Pods Architecture ## Overview Context-Pods is designed as a TurboRepo-optimized monorepo using npm workspaces to manage multiple packages, templates, and examples. The architecture emphasizes performance, modularity, comprehensive testing, and production-ready MCP server generation with a sophisticated Meta-MCP Server at its core. ## Directory Structure ``` ContextPods/ โ”œโ”€โ”€ packages/ # Core packages (npm workspaces) โ”‚ โ”œโ”€โ”€ cli/ # Command-line interface โ”‚ โ”‚ โ”œโ”€โ”€ src/ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ cli.ts # Main CLI entry point โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ commands/ # CLI command implementations โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ generate.ts # Template generation โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ wrap.ts # Script wrapping โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ list.ts # Server listing โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ dev.ts # Development server โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ build.ts # Build operations โ”‚ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ test.ts # Testing operations โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ types/ # CLI-specific types โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ utils/ # CLI utilities โ”‚ โ”‚ โ”œโ”€โ”€ tests/ # Comprehensive CLI tests (90%+ coverage) โ”‚ โ”‚ โ””โ”€โ”€ bin/ # Executable scripts โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ core/ # Core utilities and engine โ”‚ โ”‚ โ”œโ”€โ”€ src/ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ template-engine.ts # Template processing engine โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ template-selector.ts # Template selection logic โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ path-resolution.ts # Path utilities โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ schemas.ts # Zod validation schemas โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ types.ts # Core type definitions โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ errors.ts # Error handling โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ logger.ts # Logging utilities โ”‚ โ”‚ โ””โ”€โ”€ tests/ # Comprehensive tests (90%+ coverage) โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ server/ # Meta-MCP Server package โ”‚ โ”‚ โ”œโ”€โ”€ src/ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ index.ts # MCP server entry point โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ tools/ # MCP tools implementation โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ create-mcp.ts # Server generation tool โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ wrap-script.ts # Script wrapping tool โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ list-mcps.ts # Server listing tool โ”‚ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ validate-mcp.ts # Validation tool โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ registry/ # Server registry management โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ database.ts # SQLite database operations โ”‚ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ models.ts # Data models โ”‚ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ operations.ts # CRUD operations โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ config/ # Configuration management โ”‚ โ”‚ โ”œโ”€โ”€ templates/ # Built-in template collection โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ basic/ # Basic TypeScript template โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ typescript-advanced/ # Advanced TypeScript template โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ python-basic/ # Python template โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ rust-basic/ # Rust template โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ shell-wrapper/ # Shell script wrapper โ”‚ โ”‚ โ””โ”€โ”€ tests/ # Comprehensive tests (95%+ coverage) โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ testing/ # Testing framework package โ”‚ โ”‚ โ”œโ”€โ”€ src/ โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ protocol/ # MCP protocol validation โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ wrappers/ # Script wrapper testing โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ performance/ # Performance benchmarking โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ generation/ # Template generation testing โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ utils/ # Testing utilities โ”‚ โ”‚ โ””โ”€โ”€ tests/ # Framework tests (95%+ coverage) โ”‚ โ”‚ โ”‚ โ”œโ”€โ”€ templates/ # Template management package โ”‚ โ”‚ โ”œโ”€โ”€ src/ โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ index.ts # Template validation and utilities โ”‚ โ”‚ โ”œโ”€โ”€ templates/ # Template repository โ”‚ โ”‚ โ””โ”€โ”€ tests/ # Template tests (85%+ coverage) โ”‚ โ”‚ โ”‚ โ””โ”€โ”€ create/ # NPX entry package โ”‚ โ”œโ”€โ”€ bin/ # NPX executable โ”‚ โ””โ”€โ”€ tests/ # Create package tests (75%+ coverage) โ”‚ โ”œโ”€โ”€ docs/ # Comprehensive documentation โ”‚ โ”œโ”€โ”€ getting-started.md # User onboarding guide โ”‚ โ”œโ”€โ”€ templates.md # Template system guide โ”‚ โ”œโ”€โ”€ testing.md # Testing framework guide โ”‚ โ”œโ”€โ”€ api-reference.md # Complete API reference โ”‚ โ”œโ”€โ”€ ARCHITECTURE.md # This file โ”‚ โ”œโ”€โ”€ META_MCP_GUIDE.md # Meta-MCP Server guide โ”‚ โ”œโ”€โ”€ TEMPLATE_DEVELOPMENT.md # Template development guide โ”‚ โ”œโ”€โ”€ TROUBLESHOOTING.md # Common issues and solutions โ”‚ โ””โ”€โ”€ USAGE_EXAMPLES.md # Real-world usage examples โ”‚ โ”œโ”€โ”€ turbo.json # TurboRepo configuration โ”œโ”€โ”€ package.json # Root workspace configuration โ”œโ”€โ”€ tsconfig.json # Root TypeScript configuration โ”œโ”€โ”€ .eslintrc.json # ESLint configuration โ”œโ”€โ”€ .prettierrc.json # Prettier configuration โ”œโ”€โ”€ CONTRIBUTING.md # Contribution guidelines โ”œโ”€โ”€ CLAUDE.md # Claude Code development instructions โ””โ”€โ”€ README.md # Project overview ``` ## Core Concepts ### 1. Packages The monorepo includes six production packages with comprehensive test coverage: - **@context-pods/core** (90%+ coverage): Template engine, path resolution, validation schemas, and core utilities - **@context-pods/cli** (90%+ coverage): Full-featured command-line interface with TurboRepo integration and caching - **@context-pods/server** (95%+ coverage): Meta-MCP Server with tools, registry management, and protocol handling - **@context-pods/testing** (95%+ coverage): Comprehensive testing framework for MCP protocol compliance and script wrapper validation - **@context-pods/templates** (85%+ coverage): Template validation, management, and multi-language support - **@context-pods/create** (75%+ coverage): NPX runner for seamless installation and setup ### 2. Templates Templates are sophisticated blueprints for generating production-ready MCP servers: - **Multi-Language Support**: TypeScript, Python, Rust, and Shell templates - **Variable System**: Advanced Handlebars-style templating with validation - **Template Metadata**: Rich `template.json` files with dependencies, scripts, and MCP configuration - **Optimization Features**: TurboRepo integration, hot reload, shared dependencies, and build caching - **Built-in Templates**: Five production-ready templates covering different use cases and complexity levels - **Template Validation**: Comprehensive validation system ensuring template integrity and MCP compliance ### 3. Meta-MCP Server The Meta-MCP Server exposes Context-Pods functionality through the MCP protocol itself: - **MCP Tools**: `create-mcp`, `wrap-script`, `list-mcps`, `validate-mcp` - **Server Registry**: SQLite-based registry for managing generated servers - **Protocol Compliance**: Full MCP 2024-11-05 protocol implementation - **Claude Desktop Integration**: Seamless integration with Claude Desktop configuration - **Development Workflow**: Built-in development server with hot reload and debugging ### 4. Testing Framework Comprehensive testing capabilities for MCP server validation: - **Protocol Compliance**: Validates against official MCP schemas using Zod - **Script Wrapper Testing**: Multi-language script testing (Python, TypeScript, Rust, Shell) - **Performance Benchmarking**: Load testing and performance analysis - **Integration Testing**: End-to-end server communication testing - **Report Generation**: HTML and JUnit XML reports for CI/CD integration ## Build System ### TurboRepo Optimization - **Intelligent Caching**: Build and test results are cached for maximum performance - **Parallel Execution**: Tasks run in parallel across packages when possible - **Dependency Awareness**: Only rebuilds packages when their dependencies change - **Remote Caching**: Support for shared caches across development teams ### TypeScript Configuration - **Composite Projects**: Uses TypeScript project references for efficient incremental builds - **Strict Mode**: Enforces strict type safety across all packages - **ES Modules**: Modern JavaScript modules (ESM) with proper import/export patterns - **Path Mapping**: Simplified imports between packages using TypeScript path mapping ### npm Workspaces + TurboRepo Combined benefits: - **Dependency Hoisting**: Shared dependencies optimized at root level - **Cross-Package Development**: Live development with automatic rebuilds - **Unified Commands**: Single commands orchestrate complex multi-package operations - **Build Optimization**: Incremental builds with intelligent change detection - **Testing Integration**: Coordinated test execution with coverage aggregation ### Build Scripts Optimized root-level scripts: - `npm run build`: TurboRepo-optimized parallel builds - `npm run test`: Comprehensive test suite with coverage reporting - `npm run lint`: ESLint with auto-fixing across all packages - `npm run format`: Prettier formatting with consistent style - `npm run dev`: Development mode with hot reload and file watching - `npm run clean`: Clean all build artifacts and caches ## Development Workflow ### 1. Template-Based Generation 1. **Template Selection**: Choose from optimized templates or create custom ones 2. **Variable Processing**: Advanced template engine with validation and type checking 3. **Code Generation**: Fast, reliable generation with comprehensive error handling 4. **MCP Validation**: Automatic protocol compliance checking 5. **Claude Desktop Integration**: Automatic configuration generation ### 2. Script Wrapping Workflow 1. **Script Analysis**: Automatic language detection and wrapper selection 2. **Template Application**: Apply appropriate wrapper template 3. **Integration Testing**: Validate wrapped script functionality 4. **Protocol Compliance**: Ensure MCP standard compliance ### 3. Meta-MCP Server Development 1. **Registry Management**: Track and manage all generated servers 2. **Live Development**: Hot reload and debugging capabilities 3. **Testing Integration**: Continuous validation during development 4. **Performance Monitoring**: Built-in performance analysis ## Design Principles ### Performance First - TurboRepo optimization for build and test performance - Intelligent caching across all operations - Parallel processing where possible - Minimal runtime overhead ### Developer Experience Excellence - Comprehensive error messages with actionable suggestions - Multi-level logging with debug capabilities - Extensive documentation with examples - IDE integration with full TypeScript support - Hot reload and live development features ### Production Readiness - 90%+ test coverage across all packages - Generated servers follow MCP protocol standards - Comprehensive error handling and validation - Security best practices built-in - CI/CD ready with automated testing ### Extensibility & Modularity - Clean package boundaries with well-defined APIs - Template system supports any MCP server pattern - Plugin-friendly architecture for future extensions - Multi-language support with consistent patterns - Registry system for server lifecycle management ## Future Enhancements As the project continues to evolve, the architecture supports: 1. **Template Marketplace**: Community-driven template sharing and discovery 2. **Advanced Template Features**: Conditional logic, dynamic dependencies, multi-file templates 3. **Cloud Integration**: Remote template repositories and shared caches 4. **IDE Extensions**: VS Code and other editor integrations 5. **Enterprise Features**: Team management, access control, and audit logging 6. **Performance Optimization**: Even faster builds and test execution 7. **Multi-Protocol Support**: Support for other protocol standards beyond MCP ## Dependencies ### Core Dependencies - **TypeScript**: Type safety and modern JavaScript features across all packages - **Zod**: Runtime schema validation for MCP protocol compliance - **@modelcontextprotocol/sdk**: Official MCP SDK for server implementations - **TurboRepo**: Build system optimization and caching - **Vitest**: Fast, modern unit testing framework with coverage reporting ### CLI & Development Dependencies - **Commander.js**: Robust CLI argument parsing and command handling - **Inquirer.js**: Interactive command-line prompts - **Chalk**: Terminal string styling and colors - **Ora**: Elegant terminal spinners and progress indicators - **Chokidar**: Efficient file watching for development mode - **Execa**: Process execution with better error handling ### Template & Generation Dependencies - **Handlebars**: Advanced template processing with helpers - **fs-extra**: Enhanced file system operations - **YAML**: YAML parsing for configuration files - **glob**: File pattern matching for template processing ### Testing Dependencies - **Better-SQLite3**: Fast, synchronous SQLite database operations - **@types/\***: TypeScript definitions for all major dependencies - **ESLint & Prettier**: Code quality, formatting, and consistency - **C8**: Code coverage reporting ### Meta-MCP Server Dependencies - **SQLite**: Registry database for server management - **Node.js Built-ins**: Process management, file system, and networking ## Security Considerations ### Template Security - Templates are validated before processing to prevent malicious code injection - Variable validation prevents directory traversal and other attacks - Generated code follows security best practices automatically - No execution of arbitrary code during generation process ### Registry Security - SQLite database with proper data validation and sanitization - Secure file path handling for server registration - Environment variable protection and validation - Clear audit trails for all server operations ### Generated Server Security - Generated servers include built-in input validation - Proper error handling prevents information leakage - Environment variable management with secure defaults - MCP protocol compliance ensures secure communication patterns ## Testing Strategy ### Package-Level Testing Each package maintains comprehensive test coverage: - **Unit Tests**: Individual function and class testing - **Integration Tests**: Cross-component interaction testing - **End-to-End Tests**: Full workflow validation - **Performance Tests**: Load and benchmark testing ### Cross-Package Testing - **Template Generation**: Validate generated servers across all templates - **Protocol Compliance**: Ensure all generated servers meet MCP standards - **Multi-Language Support**: Test script wrapping across all supported languages - **Registry Operations**: Validate server lifecycle management ### Continuous Integration - **Pre-commit Hooks**: Code quality and basic validation - **Build Validation**: Ensure all packages build correctly - **Test Execution**: Run full test suite on all changes - **Coverage Reporting**: Maintain high test coverage standards - **Performance Monitoring**: Track build and test performance over time This architecture provides a solid foundation for the Context-Pods ecosystem, supporting both current functionality and future growth while maintaining high standards for performance, reliability, and developer experience.

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/conorluddy/ContextPods'

If you have feedback or need assistance with the MCP directory API, please join our Discord server