README.md•16 kB
# Llama Maverick Hub MCP Server
**Author: Yobie Benjamin**
**Version: 0.2**
**Date: July 28, 2025**
## Overview
The Llama Maverick Hub MCP Server is a revolutionary orchestration platform that positions Llama Maverick as the central AI brain connecting to and coordinating multiple MCP-enabled services. Unlike traditional MCP servers that provide tools to AI models, this hub **makes Llama the orchestrator** that intelligently manages and routes requests across multiple MCP services like Stripe, GitHub, databases, and more.
### Key Innovation
This is a **Meta-MCP Server** that acts as both:
- **MCP Server**: Exposes unified tools to Claude Desktop or other MCP clients
- **MCP Client**: Connects to multiple external MCP services (Stripe, GitHub, etc.)
- **AI Orchestrator**: Uses Llama Maverick to make intelligent routing and workflow decisions
## Architecture
```
┌─────────────────┐
│ Claude Desktop │
│ (MCP Client) │
└────────┬────────┘
│ MCP Protocol
▼
┌─────────────────────────────────────┐
│ Llama Maverick Hub MCP Server │
│ ┌─────────────────────────────┐ │
│ │ Llama Maverick AI Brain │ │
│ │ (Orchestration & Routing) │ │
│ └─────────────────────────────┘ │
│ │ │ │ │
│ ┌──────▼───┬────▼───┬────▼───┐ │
│ │ Service │ Service│ Service│ │
│ │ Registry │ Router │ Manager│ │
│ └──────────┴────────┴────────┘ │
└─────────┬──────────┬──────────┬────┘
│ │ │
MCP Protocol MCP MCP Protocol
│ Protocol │
▼ ▼ ▼
┌──────────┐ ┌──────┐ ┌──────────┐
│ Stripe │ │GitHub│ │ Database │
│ MCP │ │ MCP │ │ MCP │
└──────────┘ └──────┘ └──────────┘
```
## Features
### 🧠 AI-Driven Orchestration
- **Intelligent Routing**: Llama analyzes requests and routes to the best service
- **Workflow Planning**: AI designs multi-step workflows across services
- **Error Recovery**: Smart error analysis and retry strategies
- **Result Synthesis**: Combines results from multiple services intelligently
### 🔗 Multi-Service Integration
- **Service Discovery**: Automatic discovery of MCP service capabilities
- **Unified Tool Access**: Single interface to tools from all connected services
- **Parallel Execution**: Query multiple services simultaneously
- **Service Health Monitoring**: Track availability and performance
### 🔄 Advanced Workflows
- **Multi-Step Operations**: Chain operations across different services
- **Dependency Management**: Handle complex step dependencies
- **Context Passing**: Share data between workflow steps
- **Retry Policies**: Configurable retry strategies per step
### 🎯 Real-World Integrations
- **Stripe MCP**: Complete payment workflows with orchestration
- **GitHub MCP**: Repository management with AI assistance
- **Database MCP**: Data operations with intelligent queries
- **Custom Services**: Easy integration of any MCP service
## Installation
### Prerequisites
1. **Node.js 18+** and npm
2. **Ollama** with Llama model installed
3. **Claude Desktop** (for MCP client)
4. **MCP Services** you want to connect (e.g., Stripe MCP)
### Quick Start
```bash
# Clone the repository
git clone https://github.com/yobieben/llama-maverick-hub-mcp.git
cd llama-maverick-hub-mcp
# Install dependencies
npm install
# Build the project
npm run build
# Configure services (edit config.json)
cp config.example.json config.json
# Start the hub server
npm start
```
### Installing Ollama and Llama
```bash
# Install Ollama
curl -fsSL https://ollama.ai/install.sh | sh
# Pull Llama model
ollama pull llama3.2
# Verify installation
ollama list
```
## Configuration
### Basic Configuration (config.json)
```json
{
"hub": {
"name": "llama-maverick-hub",
"version": "0.2.0",
"port": 8080,
"logLevel": "info"
},
"llama": {
"model": "llama3.2",
"baseUrl": "http://localhost:11434",
"contextWindow": 8192,
"defaultTemperature": 0.7
},
"services": [
{
"id": "stripe",
"name": "Stripe MCP",
"description": "Stripe payment processing",
"transport": "stdio",
"endpoint": "stripe-mcp",
"enabled": true,
"command": "npx",
"args": ["-y", "@stripe/mcp-server"],
"reconnectPolicy": {
"maxRetries": 5,
"retryDelayMs": 5000,
"backoffMultiplier": 2
}
},
{
"id": "github",
"name": "GitHub MCP",
"description": "GitHub repository management",
"transport": "stdio",
"endpoint": "github-mcp",
"enabled": true,
"command": "github-mcp-server",
"args": ["--token", "${GITHUB_TOKEN}"]
}
],
"orchestration": {
"maxConcurrentOperations": 10,
"defaultTimeout": 30000,
"retryPolicy": {
"maxRetries": 3,
"retryDelayMs": 1000
}
}
}
```
### Claude Desktop Configuration
Add to your Claude Desktop config:
```json
{
"mcpServers": {
"llama-hub": {
"command": "node",
"args": ["/path/to/llama-maverick-hub-mcp/dist/index.js"],
"env": {
"LLAMA_HUB_LOG_LEVEL": "info",
"STRIPE_API_KEY": "your_stripe_key",
"GITHUB_TOKEN": "your_github_token"
}
}
}
}
```
### Environment Variables
```bash
# Hub Configuration
LLAMA_HUB_NAME=llama-maverick-hub
LLAMA_HUB_PORT=8080
LLAMA_HUB_LOG_LEVEL=debug
# Llama Configuration
LLAMA_HUB_LLAMA_MODEL=llama3.2
LLAMA_HUB_LLAMA_BASE_URL=http://localhost:11434
# Service Configuration
LLAMA_HUB_SERVICE_STRIPE_ENABLED=true
LLAMA_HUB_SERVICE_STRIPE_COMMAND=npx
LLAMA_HUB_SERVICE_GITHUB_ENABLED=true
# Security
LLAMA_HUB_ENABLE_AUTH=false
LLAMA_HUB_API_KEYS=key1,key2
```
## Usage Examples
### Basic Tool Execution
When you interact with Claude Desktop, you can now access tools from all connected services:
```
User: "Create a new Stripe customer and set up a subscription"
Claude uses: stripe_create_customer, stripe_create_subscription
Hub routes to: Stripe MCP service
Llama assists: Validates data, handles errors
```
### Intelligent Routing
```
User: "Process a payment for this customer"
Llama analyzes:
- Customer location
- Payment amount
- Risk factors
Llama decides:
- Route to Stripe for low-risk
- Route to fraud service for high-risk
- Use alternative processor for specific regions
```
### Multi-Service Workflows
```
User: "Onboard a new customer with payment"
Hub executes workflow:
1. Create Stripe customer
2. Set up payment method
3. Create subscription
4. Store in database
5. Send welcome email
6. Update analytics
All orchestrated by Llama Maverick!
```
### Parallel Service Queries
```
User: "Get customer information from all systems"
Hub queries simultaneously:
- Stripe for payment data
- Database for profile
- Analytics for behavior
- Support for tickets
Llama synthesizes comprehensive report
```
## Advanced Features
### Custom Workflows
Create complex multi-service workflows:
```typescript
orchestrator.registerWorkflow({
id: 'customer-lifecycle',
name: 'Complete Customer Lifecycle',
description: 'Onboard, activate, and monitor customer',
steps: [
{
id: 'stripe-setup',
service: 'stripe',
tool: 'create_customer',
arguments: { /* ... */ }
},
{
id: 'database-store',
service: 'database',
tool: 'insert_record',
arguments: { /* ... */ },
dependsOn: ['stripe-setup']
},
{
id: 'email-welcome',
service: 'email',
tool: 'send_email',
arguments: { /* ... */ },
dependsOn: ['database-store']
}
]
});
```
### AI-Powered Decision Making
Llama Maverick makes intelligent decisions:
```typescript
// Llama analyzes request and determines best approach
const routing = await llamaService.analyzeRouting(
userRequest,
availableServices
);
// Llama plans multi-step workflow
const workflow = await llamaService.planWorkflow(
goal,
services,
tools
);
// Llama synthesizes results from multiple sources
const summary = await llamaService.synthesizeResults(
serviceResults,
originalRequest
);
```
### Service Health Monitoring
Automatic failover and recovery:
```typescript
// Registry tracks service health
registry.on('service:unhealthy', (service) => {
// Llama determines fallback strategy
const fallback = llamaService.determineFallback(service);
// Route to alternative service
orchestrator.reroute(service, fallback);
});
```
## Real-World Use Cases
### 1. E-Commerce Platform
```
Workflow: Complete Order Processing
- Validate inventory (Database MCP)
- Process payment (Stripe MCP)
- Update inventory (Database MCP)
- Create shipping label (Shipping MCP)
- Send confirmation (Email MCP)
- Update analytics (Analytics MCP)
```
### 2. SaaS Subscription Management
```
Workflow: Subscription Lifecycle
- Create customer (Stripe MCP)
- Provision resources (Cloud MCP)
- Set up monitoring (Monitoring MCP)
- Configure billing (Stripe MCP)
- Send onboarding (Email MCP)
```
### 3. Financial Services
```
Workflow: Loan Application
- Credit check (Credit MCP)
- Risk assessment (Risk MCP)
- Document verification (Document MCP)
- Approval workflow (Workflow MCP)
- Fund disbursement (Banking MCP)
```
### 4. Developer Tools
```
Workflow: CI/CD Pipeline
- Code analysis (GitHub MCP)
- Run tests (Testing MCP)
- Build artifacts (Build MCP)
- Deploy to cloud (Cloud MCP)
- Update monitoring (Monitoring MCP)
```
## API Reference
### Hub Tools
#### hub_execute_workflow
Execute a predefined multi-service workflow.
```json
{
"name": "hub_execute_workflow",
"arguments": {
"workflowId": "customer-onboarding",
"parameters": {
"email": "customer@example.com",
"plan": "premium"
}
}
}
```
#### hub_smart_route
Use Llama AI to intelligently route requests.
```json
{
"name": "hub_smart_route",
"arguments": {
"query": "Process payment for high-risk customer",
"context": {
"amount": 1000,
"currency": "USD",
"risk_score": 85
}
}
}
```
#### hub_parallel_query
Query multiple services in parallel.
```json
{
"name": "hub_parallel_query",
"arguments": {
"services": ["stripe", "database", "analytics"],
"query": "Get customer profile"
}
}
```
### Service Tools
All tools from connected services are available with service prefix:
- `stripe_create_customer`
- `stripe_create_charge`
- `github_create_repo`
- `github_create_issue`
- `database_query`
- `database_insert`
## Development
### Project Structure
```
llama-maverick-hub-mcp/
├── src/
│ ├── index.ts # Main server entry point
│ ├── orchestrator/
│ │ └── hub-orchestrator.ts # Core orchestration logic
│ ├── registry/
│ │ └── service-registry.ts # Service management
│ ├── clients/
│ │ └── mcp-client-manager.ts # MCP client connections
│ ├── services/
│ │ └── llama-service.ts # Llama AI integration
│ ├── config/
│ │ └── config-manager.ts # Configuration management
│ └── integrations/
│ └── stripe-integration.ts # Stripe-specific workflows
├── config.json # Hub configuration
├── package.json # Node.js dependencies
├── tsconfig.json # TypeScript configuration
└── README.md # This file
```
### Adding New Services
1. **Define Service Configuration**:
```json
{
"id": "myservice",
"name": "My Service MCP",
"transport": "stdio",
"command": "my-service-mcp",
"enabled": true
}
```
2. **Create Integration Module** (optional):
```typescript
export class MyServiceIntegration {
registerWorkflows() {
// Define service-specific workflows
}
}
```
3. **Register with Hub**:
```typescript
const integration = new MyServiceIntegration(orchestrator);
integration.registerWorkflows();
```
### Testing
```bash
# Run tests
npm test
# Run specific test
npm test -- --grep "orchestrator"
# Test with coverage
npm run test:coverage
```
### Debugging
Enable debug logging:
```bash
export LLAMA_HUB_LOG_LEVEL=debug
npm start
```
View service connections:
```bash
# Check service status
curl http://localhost:8080/status
# View service registry
curl http://localhost:8080/services
```
## Monitoring
### Metrics
The hub exposes metrics for monitoring:
- Service availability
- Request latency
- Workflow execution time
- Error rates
- Llama inference time
### Health Checks
```bash
# Hub health
curl http://localhost:8080/health
# Service health
curl http://localhost:8080/health/stripe
```
### Logging
Structured logging with Winston:
```typescript
logger.info('Workflow executed', {
workflowId: 'customer-onboarding',
duration: 1234,
steps: 6,
success: true
});
```
## Troubleshooting
### Common Issues
#### Llama Connection Failed
```
Error: Failed to connect to Ollama
Solution: Ensure Ollama is running: ollama serve
```
#### Service Not Connecting
```
Error: Failed to connect to service: stripe
Solution: Check service command and arguments in config
```
#### Workflow Timeout
```
Error: Workflow execution timeout
Solution: Increase timeout in orchestration config
```
### Debug Mode
Enable verbose logging:
```typescript
// In code
logger.level = 'debug';
// Via environment
LLAMA_HUB_LOG_LEVEL=debug npm start
```
## Security
### Best Practices
1. **API Key Management**: Use environment variables for sensitive keys
2. **Service Isolation**: Run services in separate processes
3. **Rate Limiting**: Configure per-service rate limits
4. **Audit Logging**: Log all workflow executions
5. **Error Handling**: Never expose internal errors to clients
### Authentication
Enable authentication in config:
```json
{
"security": {
"enableAuth": true,
"apiKeys": ["key1", "key2"]
}
}
```
## Performance
### Optimization Tips
1. **Cache Service Discoveries**: Reduce repeated capability queries
2. **Parallel Execution**: Use `hub_parallel_query` for multi-service operations
3. **Connection Pooling**: Reuse MCP client connections
4. **Workflow Optimization**: Minimize step dependencies
5. **Llama Tuning**: Adjust temperature for faster inference
### Benchmarks
Typical performance metrics:
- Service connection: < 100ms
- Tool execution: < 500ms
- Workflow step: < 1s
- Llama inference: < 2s
- Full workflow: < 10s
## Contributing
We welcome contributions! Please see [CONTRIBUTING.md](CONTRIBUTING.md) for guidelines.
### Areas for Contribution
- New service integrations
- Workflow templates
- Performance optimizations
- Documentation improvements
- Test coverage
## License
MIT License - see [LICENSE](LICENSE) file
## Support
- **Issues**: [GitHub Issues](https://github.com/yobieben/llama-maverick-hub-mcp/issues)
- **Discussions**: [GitHub Discussions](https://github.com/yobieben/llama-maverick-hub-mcp/discussions)
- **Email**: yobie.benjamin@example.com
## Acknowledgments
- Anthropic for the MCP protocol
- Meta for Llama models
- Ollama for local model hosting
- Stripe for payment MCP example
- The open-source community
---
**Built with ❤️ by Yobie Benjamin**
*Orchestrating the future of AI-driven service integration*