AI Orchestration MCP Server
by adakrupp
README.md
# AI Orchestration MCP Server
Production-grade Model Context Protocol (MCP) server for orchestrating multiple AI providers. Intelligently delegate tasks to local models (Ollama, llama.cpp) or cloud providers (OpenAI, Anthropic, Gemini) to optimize cost and performance.
[](LICENSE)
[](https://www.typescriptlang.org/)
[](https://nodejs.org/)
[](https://www.docker.com/)
[](https://hub.docker.com/r/adakrupp/ai-orchestration-mcp)
[](https://hub.docker.com/r/adakrupp/ai-orchestration-mcp)
[](https://hub.docker.com/r/adakrupp/ai-orchestration-mcp)
## β¨ Features
- π **Secure by Design**: No shell injection vulnerabilities - uses HTTP APIs and official SDKs
- π **5 AI Providers**: Ollama, Gemini, OpenAI, Anthropic, llama.cpp
- βοΈ **Flexible Configuration**: File-based config with environment variable support
- π **Comprehensive Logging**: Structured logging with sensitive data redaction
- π **Request History**: Track all requests and responses in JSONL format
- π³ **Docker Ready**: One-command deployment with docker-compose
- π **Plugin Architecture**: Easily add new providers
- π‘οΈ **Input Validation**: Comprehensive sanitization and validation
- π¦ **TypeScript**: Full type safety with strict mode
## π Quick Start
### Option 1: Docker Hub (Easiest)
```bash
# Pull the image
docker pull adakrupp/ai-orchestration-mcp:latest
# Download docker-compose.yml
curl -O https://raw.githubusercontent.com/adakrupp/ai-orchestration-mcp/main/docker-compose.yml
# Start services
docker compose up -d
# View logs
docker compose logs -f ai-orchestration-mcp
```
**That's it!** The server is now running with Ollama and ready to use with Claude Code.
### Option 2: Build from Source
```bash
# Clone repository
git clone https://github.com/adakrupp/ai-orchestration-mcp.git
cd ai-orchestration-mcp
# One-command setup
./docker-setup.sh
# View logs
docker compose logs -f ai-orchestration-mcp
```
π See [DOCKER.md](DOCKER.md) for complete Docker documentation.
### Option 3: Local Installation
```bash
# Clone and install
git clone https://github.com/adakrupp/ai-orchestration-mcp.git
cd ai-orchestration-mcp
npm install
# Build
npm run build
# Configure
cp config/ai-orchestration.example.json config/ai-orchestration.json
# Edit config/ai-orchestration.json with your settings
# Test
npm test
```
## π Table of Contents
- [Installation](#installation)
- [Configuration](#configuration)
- [Usage with Claude Code](#usage-with-claude-code)
- [Providers](#providers)
- [Architecture](#architecture)
- [Development](#development)
- [Security](#security)
- [Contributing](#contributing)
- [License](#license)
## π¦ Installation
### Prerequisites
- Node.js 18+ (or Docker)
- One or more AI providers:
- **Ollama**: Install from [ollama.ai](https://ollama.ai)
- **OpenAI**: Get API key from [platform.openai.com](https://platform.openai.com)
- **Anthropic**: Get API key from [console.anthropic.com](https://console.anthropic.com)
- **Gemini**: Get API key from [ai.google.dev](https://ai.google.dev)
- **llama.cpp**: Run [llama.cpp server](https://github.com/ggerganov/llama.cpp)
### Installation Methods
#### Docker Hub (Recommended)
```bash
docker pull adakrupp/ai-orchestration-mcp:latest
```
See [DOCKER.md](DOCKER.md) for complete Docker deployment guide.
#### Docker Build from Source
See [DOCKER.md](DOCKER.md) for building from source.
#### NPM Installation
```bash
# Install dependencies
npm install
# Install optional peer dependencies (as needed)
npm install openai @anthropic-ai/sdk
# Build TypeScript
npm run build
```
## βοΈ Configuration
### Configuration File
Create `config/ai-orchestration.json`:
```json
{
"version": "1.0",
"server": {
"name": "ai-orchestration-mcp",
"version": "2.0.0",
"logLevel": "info",
"historyEnabled": true
},
"providers": {
"ollama": {
"enabled": true,
"baseUrl": "http://localhost:11434",
"models": {
"coder": "qwen2.5-coder:7b",
"general": "qwen2.5:7b"
}
},
"openai": {
"enabled": true,
"apiKey": "${OPENAI_API_KEY}",
"defaultModel": "gpt-4o-mini"
}
},
"security": {
"maxPromptLength": 100000,
"maxResponseLength": 500000
}
}
```
### Environment Variables
Create `.env` file:
```env
OPENAI_API_KEY=sk-...
ANTHROPIC_API_KEY=sk-ant-...
GEMINI_API_KEY=...
```
### Configuration Discovery
The server searches for configuration in this order:
1. `--config` CLI argument
2. `AI_ORCHESTRATION_CONFIG` environment variable
3. `./config/ai-orchestration.json` (project directory)
4. `~/.config/ai-orchestration/config.json` (user config)
5. Built-in defaults
## π― Usage with Claude Code
### Method 1: Docker
Update your `.mcp.json`:
```json
{
"mcpServers": {
"ai-orchestration": {
"command": "docker",
"args": ["exec", "-i", "ai-orchestration-mcp", "node", "dist/index.js"]
}
}
}
```
### Method 2: Local
```json
{
"mcpServers": {
"ai-orchestration": {
"command": "node",
"args": ["/absolute/path/to/ai-orchestration-mcp/dist/index.js"]
}
}
}
```
### Available Tools
Once configured, Claude Code will have access to these tools:
#### For each enabled provider:
- **`use_<provider>`**: Send a query to the provider
```
use_ollama model="qwen2.5:7b" prompt="Explain async/await in JavaScript"
```
- **`list_<provider>_models`**: List available models
```
list_ollama_models
```
### Example Usage
```
User: "Use Ollama to explain what a Docker container is"
Claude: I'll use the local Ollama model for this task.
[Calls use_ollama with qwen2.5:7b]
User: "Now use OpenAI to write production-grade documentation for it"
Claude: I'll use OpenAI for the comprehensive documentation.
[Calls use_openai with gpt-4o-mini]
```
## π€ Providers
### Ollama (Local Models)
**Best for**: Simple tasks, code analysis, quick questions
- β
Free (runs locally)
- β
Privacy (data stays local)
- β
Fast (low latency)
- β Requires local resources
- β Limited compared to cloud models
**Setup**:
```bash
# Install Ollama
curl -fsSL https://ollama.ai/install.sh | sh
# Pull models
ollama pull qwen2.5:7b
ollama pull qwen2.5-coder:7b
```
### OpenAI
**Best for**: Complex reasoning, production code, detailed analysis
- β
Powerful models (GPT-4, GPT-4o)
- β
Good for coding tasks
- β
Function calling support
- β Costs per token
- β Data sent to OpenAI
**Setup**:
```bash
npm install openai
# Add to .env
OPENAI_API_KEY=sk-...
```
### Anthropic (Claude)
**Best for**: Long context tasks, analysis, complex reasoning
- β
Large context windows (200k tokens)
- β
Strong reasoning capabilities
- β
Good safety guardrails
- β Costs per token
- β Data sent to Anthropic
**Setup**:
```bash
npm install @anthropic-ai/sdk
# Add to .env
ANTHROPIC_API_KEY=sk-ant-...
```
### Gemini
**Best for**: Multimodal tasks, web research, creative writing
- β
Multimodal (text + images)
- β
Free tier available
- β
Fast responses
- β Less suitable for code
- β Data sent to Google
**Setup**:
```bash
# Install Gemini CLI
# See: https://github.com/google/gemini-cli
# Add to .env
GEMINI_API_KEY=...
```
### llama.cpp (Local HTTP Server)
**Best for**: Custom local models, complete privacy
- β
Run any GGUF model
- β
Complete privacy
- β
Customizable
- β Manual setup required
- β Resource intensive
**Setup**:
```bash
# Run llama.cpp server
./server -m model.gguf --port 8080
```
## ποΈ Architecture
```
βββββββββββββββββββββββββββββββββββββββ
β Claude Code (Client) β
ββββββββββββββββ¬βββββββββββββββββββββββ
β MCP Protocol
β (stdio)
ββββββββββββββββΌβββββββββββββββββββββββ
β AI Orchestration MCP Server β
β β
β βββββββββββββββββββββββββββββββ β
β β Provider Registry β β
β βββββββββββββββββββββββββββββββ β
β β
β ββββββββ ββββββββββ ββββββββββββ β
β βOllamaβ β OpenAI β βAnthropic β β
β ββββ¬ββββ βββββ¬βββββ ββββββ¬ββββββ β
βββββββΌββββββββββΌββββββββββββΌβββββββββ
β β β
βΌ βΌ βΌ
HTTP API REST API REST API
```
### Key Components
- **Server**: MCP protocol handler, routes requests to providers
- **Provider Registry**: Manages all AI providers
- **Providers**: Individual integrations (Ollama, OpenAI, etc.)
- **Config Loader**: Loads and validates configuration
- **Logger**: Structured logging with sensitive data redaction
- **History Tracker**: Records all requests/responses
### Security Features
- β
**No Shell Injection**: Uses HTTP APIs and spawn() without shell
- β
**Input Validation**: Comprehensive sanitization of all inputs
- β
**API Key Redaction**: Never logs sensitive credentials
- β
**Type Safety**: Full TypeScript with strict mode
- β
**Rate Limiting**: Optional rate limiting per provider
- β
**Max Length Limits**: Prevents oversized inputs/outputs
## π οΈ Development
### Setup Development Environment
```bash
# Install dependencies
npm install
# Run in dev mode (with auto-reload)
npm run dev
# Type check
npm run type-check
# Lint
npm run lint
# Format code
npm run format
```
### Testing
```bash
# Run all tests
npm test
# Unit tests only
npm run test:unit
# Integration tests
npm run test:int
# Coverage report
npm run test:coverage
```
### Adding a New Provider
1. Create provider directory:
```
src/providers/myprovider/
βββ index.ts # Provider implementation
βββ client.ts # API client
```
2. Implement BaseProvider:
```typescript
export class MyProvider extends BaseProvider {
readonly name = 'myprovider';
readonly capabilities = { /* ... */ };
async listModels(): Promise<string[]> { /* ... */ }
async execute(request: ProviderRequest): Promise<ProviderResponse> { /* ... */ }
async validateConfig(): Promise<boolean> { /* ... */ }
}
```
3. Register in `src/index.ts`:
```typescript
if (config.providers.myprovider?.enabled) {
const provider = new MyProvider(config.providers.myprovider);
registry.register(provider);
}
```
4. Add configuration types in `src/types/config.ts`
5. Add tests in `tests/unit/providers/myprovider.test.ts`
## π Security
### Reporting Vulnerabilities
Please report security vulnerabilities via [GitHub Security Advisories](https://github.com/adakrupp/ai-orchestration-mcp/security/advisories/new) or by opening a private issue.
### Security Best Practices
1. **API Keys**: Store in environment variables, never commit
2. **Configuration**: Use `.gitignore` to exclude config files
3. **Updates**: Keep dependencies up to date (`npm audit`)
4. **Logs**: Review logs for sensitive data exposure
5. **Rate Limiting**: Enable for production deployments
### Security Audit
```bash
# Check for vulnerabilities
npm audit
# Fix vulnerabilities
npm audit fix
```
## π€ Contributing
Contributions are welcome!
### Contribution Guide
1. Fork the repository
2. Create a feature branch (`git checkout -b feature/amazing-feature`)
3. Make your changes
4. Add tests
5. Run tests and linting (`npm test && npm run lint`)
6. Commit your changes (`git commit -m 'Add amazing feature'`)
7. Push to the branch (`git push origin feature/amazing-feature`)
8. Open a Pull Request
## π License
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
## π Acknowledgments
- [MCP Protocol](https://modelcontextprotocol.io/) by Anthropic
- [Ollama](https://ollama.ai/) for local model serving
- [OpenAI](https://openai.com/), [Anthropic](https://anthropic.com/), [Google](https://ai.google.dev/) for their APIs
- All contributors to this project
## π Documentation
- [Docker Deployment Guide](DOCKER.md) - Complete guide for Docker deployment
- [Example Configuration](config/ai-orchestration.example.json) - Configuration file reference
## π¬ Support
- **Issues**: [GitHub Issues](https://github.com/adakrupp/ai-orchestration-mcp/issues)
- **Discussions**: [GitHub Discussions](https://github.com/adakrupp/ai-orchestration-mcp/discussions)
- **Documentation**: [Full Docs](https://github.com/adakrupp/ai-orchestration-mcp/tree/main/docs)
---
**Made with β€οΈ for the AI community**
Maintenance
ActivityInactive
ResponsivenessNo recent community issues