Skip to main content
Glama

Context Pods

by conorluddy
templates.mdโ€ข11.5 kB
# Templates Guide Context-Pods provides a rich set of templates to accelerate your MCP server development. Each template is designed for specific use cases and languages, providing you with a solid foundation to build upon. ## Available Templates ### TypeScript Templates #### 1. `basic` - Simple TypeScript Server **Best for**: First-time MCP developers, simple tool servers ```bash npx @context-pods/create generate --template basic --language typescript ``` **Features**: - Single file server implementation - Basic tool and resource examples - Minimal dependencies - Perfect for learning MCP concepts **Structure**: ``` โ”œโ”€โ”€ src/ โ”‚ โ””โ”€โ”€ index.ts # Complete server in one file โ”œโ”€โ”€ package.json # Minimal dependencies โ””โ”€โ”€ README.md # Getting started guide ``` #### 2. `typescript-advanced` - Full-Featured TypeScript Server **Best for**: Production servers, complex integrations, enterprise use ```bash npx @context-pods/create generate --template typescript-advanced --language typescript ``` **Features**: - Modular architecture with separate tool/resource files - Built-in logging and error handling - Input validation utilities - Performance monitoring hooks - TurboRepo optimization - Comprehensive testing setup **Structure**: ``` โ”œโ”€โ”€ src/ โ”‚ โ”œโ”€โ”€ index.ts # Server entry point โ”‚ โ”œโ”€โ”€ server.ts # MCP server implementation โ”‚ โ”œโ”€โ”€ tools/ # Tool implementations โ”‚ โ”‚ โ”œโ”€โ”€ index.ts # Tool registry โ”‚ โ”‚ โ”œโ”€โ”€ data-tools.ts # Data manipulation tools โ”‚ โ”‚ โ”œโ”€โ”€ file-tools.ts # File system tools โ”‚ โ”‚ โ””โ”€โ”€ utility-tools.ts # General utilities โ”‚ โ”œโ”€โ”€ resources/ # Resource providers โ”‚ โ”‚ โ””โ”€โ”€ index.ts # Resource registry โ”‚ โ””โ”€โ”€ utils/ # Shared utilities โ”‚ โ”œโ”€โ”€ helpers.ts # Common functions โ”‚ โ”œโ”€โ”€ logger.ts # Logging utilities โ”‚ โ””โ”€โ”€ validation.ts # Input validation โ”œโ”€โ”€ EXAMPLES.md # Usage examples โ””โ”€โ”€ package.json # Full dependency set ``` ### Python Templates #### 3. `python-basic` - Python MCP Server **Best for**: Data science, ML integration, Python-native libraries ```bash npx @context-pods/create generate --template python-basic --language python ``` **Features**: - Async/await support with asyncio - Built-in data science tool examples - Integration with popular Python libraries - Virtual environment setup - pytest testing framework **Structure**: ``` โ”œโ”€โ”€ src/ โ”‚ โ”œโ”€โ”€ __init__.py โ”‚ โ”œโ”€โ”€ server.py # Main server implementation โ”‚ โ”œโ”€โ”€ tools.py # Tool implementations โ”‚ โ””โ”€โ”€ resources.py # Resource providers โ”œโ”€โ”€ requirements.txt # Python dependencies โ”œโ”€โ”€ main.py # Entry point โ””โ”€โ”€ README.md # Python-specific guide ``` **Key Libraries Included**: - `requests` - HTTP client - `pandas` - Data manipulation - `numpy` - Numerical computing - `asyncio` - Async support ### Rust Templates #### 4. `rust-basic` - High-Performance Rust Server **Best for**: System-level tools, high-performance computing, CLI tool wrappers ```bash npx @context-pods/create generate --template rust-basic --language rust ``` **Features**: - Tokio async runtime - Serde JSON serialization - Error handling with `anyhow` - Memory safety and performance - Built-in CLI integration examples **Structure**: ``` โ”œโ”€โ”€ src/ โ”‚ โ”œโ”€โ”€ main.rs # Entry point โ”‚ โ”œโ”€โ”€ server.rs # MCP server implementation โ”‚ โ”œโ”€โ”€ tools.rs # Tool implementations โ”‚ โ””โ”€โ”€ resources.rs # Resource providers โ”œโ”€โ”€ Cargo.toml # Rust dependencies โ””โ”€โ”€ README.md # Rust-specific guide ``` ### Shell Templates #### 5. `shell-wrapper` - Shell Script MCP Server **Best for**: Wrapping existing CLI tools, system administration, legacy script integration ```bash npx @context-pods/create generate --template shell-wrapper --language shell ``` **Features**: - POSIX shell compatibility - CLI tool integration examples - Process management utilities - Error handling and logging - Environment variable management **Structure**: ``` โ”œโ”€โ”€ mcp-server.sh # Main server script โ”œโ”€โ”€ scripts/ # Individual tool scripts โ”‚ โ”œโ”€โ”€ hello.sh # Hello world example โ”‚ โ”œโ”€โ”€ file-ops.sh # File operations โ”‚ โ””โ”€โ”€ system-info.sh # System information โ””โ”€โ”€ README.md # Shell-specific guide ``` ## Template Selection Guide ### Choosing the Right Template | Use Case | Recommended Template | Reason | | --------------- | --------------------------------------- | ------------------------------- | | Learning MCP | `basic` | Simple, minimal setup | | Production API | `typescript-advanced` | Full features, enterprise-ready | | Data Science | `python-basic` | NumPy, Pandas integration | | System Tools | `rust-basic` | Performance, memory safety | | CLI Integration | `shell-wrapper` | Direct script wrapping | | Web Services | `typescript-advanced` | HTTP client, validation | | File Processing | `rust-basic` or `typescript-advanced` | Performance or ecosystem | | Database Access | `python-basic` or `typescript-advanced` | Library availability | ### Language Comparison | Feature | TypeScript | Python | Rust | Shell | | ------------------ | ---------- | --------- | --------- | ------- | | Learning Curve | Medium | Easy | Hard | Easy | | Performance | Good | Medium | Excellent | Medium | | Ecosystem | Excellent | Excellent | Growing | Limited | | Type Safety | Excellent | Optional | Excellent | None | | Async Support | Native | Native | Native | Basic | | Package Management | npm | pip | cargo | Manual | ## Template Customization ### Template Variables Each template supports customization through variables: ```bash # Generate with custom variables npx @context-pods/create generate \ --template typescript-advanced \ --variables '{"serverName":"my-api","description":"Custom API server"}' ``` **Common Variables**: - `serverName` - Name of the MCP server - `description` - Server description - `authorName` - Author information - `authorEmail` - Contact email - `version` - Initial version number - `license` - License type (MIT, Apache, etc.) ### Advanced Customization #### Custom Tool Categories For `typescript-advanced` template: ```typescript // Customize tool categories in template variables { "toolCategories": [ "file-operations", "data-processing", "api-integration" ] } ``` #### Python Package Selection For `python-basic` template: ```python # Customize Python dependencies { "pythonPackages": [ "requests", "pandas", "numpy", "scikit-learn" ] } ``` #### Rust Feature Flags For `rust-basic` template: ```toml # Customize Cargo features { "rustFeatures": [ "serde_json", "tokio", "reqwest", "clap" ] } ``` ## Template Development ### Creating Custom Templates See [TEMPLATE_DEVELOPMENT.md](TEMPLATE_DEVELOPMENT.md) for detailed instructions on: - Template structure requirements - Variable system usage - File generation patterns - Validation and testing - Contributing new templates ### Template Validation All templates undergo rigorous validation: ```bash # Validate a template npx @context-pods/testing validate-template ./my-template # Test template generation npx @context-pods/testing test-template ./my-template --all-languages ``` ## Migration Between Templates ### Upgrading Templates When upgrading to newer template versions: 1. **Generate a fresh server** with the new template 2. **Compare the structures** to identify changes 3. **Migrate your custom code** to the new structure 4. **Test thoroughly** with the testing framework ### Converting Between Languages To convert an existing server to a different language: 1. **Generate a new server** in the target language 2. **Map your tools and resources** to the new structure 3. **Implement equivalent functionality** using language-specific patterns 4. **Validate with testing framework** ## Template Examples ### Basic Usage Examples Each template includes comprehensive examples: #### TypeScript Advanced ```typescript // Example: Weather API integration export async function getWeather(args: { location: string }) { const response = await fetch(`https://api.weather.com/v1/current.json?q=${args.location}`); return { temperature: await response.json() }; } ``` #### Python Basic ```python # Example: Data processing async def process_data(args: dict) -> dict: import pandas as pd df = pd.DataFrame(args['data']) return {'processed': df.describe().to_dict()} ``` #### Rust Basic ```rust // Example: File operations pub async fn read_file(args: serde_json::Value) -> Result<serde_json::Value> { let path = args["path"].as_str().unwrap(); let content = tokio::fs::read_to_string(path).await?; Ok(json!({ "content": content })) } ``` #### Shell Wrapper ```bash # Example: System information get_system_info() { echo "{ \"os\": \"$(uname -s)\", \"kernel\": \"$(uname -r)\", \"memory\": \"$(free -h | grep '^Mem:' | awk '{print $2}')\" }" } ``` ## Best Practices ### Template Selection Best Practices 1. **Start Simple**: Begin with `basic` templates for learning 2. **Match Your Stack**: Choose languages you're comfortable with 3. **Consider Performance**: Use Rust for high-performance scenarios 4. **Leverage Ecosystems**: Python for data science, TypeScript for web APIs 5. **Plan for Growth**: Advanced templates support scaling better ### Development Best Practices 1. **Follow Template Structure**: Don't deviate from established patterns 2. **Use Built-in Utilities**: Leverage template-provided logging, validation 3. **Test Early and Often**: Use the testing framework throughout development 4. **Document Your Changes**: Update README files as you customize 5. **Version Control**: Commit template changes incrementally ## Troubleshooting Templates ### Common Issues #### Template Generation Fails ```bash # Check template validity npx @context-pods/testing validate-template ./template-name # Verify all required files exist ls -la template-name/ ``` #### Missing Dependencies ```bash # For TypeScript templates npm install # For Python templates pip install -r requirements.txt # For Rust templates cargo build ``` #### MCP Compliance Issues ```bash # Validate generated server npx @context-pods/testing validate-mcp ./generated-server # Check specific compliance issues npx @context-pods/testing validate-mcp ./generated-server --verbose ``` ## Next Steps - **Getting Started**: New to Context-Pods? Start with our [Getting Started Guide](getting-started.md) - **API Reference**: Dive deeper with the [API Reference](api-reference.md) - **Testing**: Learn the [Testing Framework](testing.md) - **Contributing**: Help improve templates with our [CONTRIBUTING.md](../CONTRIBUTING.md) guide Happy templating! ๐ŸŽจ

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