Skip to content

sirmaxworld/smeCon

Repository files navigation

Multi-Agent Orchestrator

A sophisticated multi-agent orchestration system built with AutoGen, LangChain, and LangGraph. Deploy on Railway as a service to assign tasks and run an MCP server.

Features

  • Multi-Agent System: Orchestrates specialized AI agents (Planner, Coder, Researcher, Reviewer, Executor)
  • LangGraph Integration: State-based workflow management with checkpointing
  • MCP Server: Model Context Protocol server for agent communication
  • REST API: FastAPI-based service for task submission and management
  • Railway Ready: Configured for easy deployment on Railway
  • Task Queue: Background task processing with status tracking
  • Authentication: API key-based security

Architecture

┌─────────────────┐     ┌─────────────────┐
│   REST API      │     │   MCP Server    │
│  (FastAPI)      │     │  (WebSocket)    │
└────────┬────────┘     └────────┬────────┘
         │                       │
         └───────────┬───────────┘
                     │
         ┌───────────▼───────────┐
         │    Orchestrator       │
         │   (LangGraph)         │
         └───────────┬───────────┘
                     │
     ┌───────────────┼───────────────┐
     │               │               │
┌────▼────┐    ┌────▼────┐    ┌────▼────┐
│ Planner │    │  Coder  │    │Researcher│
└─────────┘    └─────────┘    └─────────┘
                     │
              ┌──────┴──────┐
         ┌────▼────┐  ┌────▼────┐
         │Reviewer │  │Executor │
         └─────────┘  └─────────┘

Quick Start

Local Development

  1. Clone the repository and install dependencies:
cd multi-agent-orchestrator
pip install -r requirements.txt
  1. Copy the environment template:
cp .env.example .env
  1. Edit .env with your API keys:
OPENAI_API_KEY=your_openai_key
ANTHROPIC_API_KEY=your_anthropic_key
API_KEY=your_api_key_for_auth
SECRET_KEY=your_secret_key
  1. Run with Docker Compose:
docker-compose up

Or run directly:

# Start all services
python main.py all

# Or run separately
python main.py api      # Start REST API
python main.py mcp      # Start MCP server

Deploy to Railway

  1. Fork this repository

  2. Connect to Railway:

railway login
railway link
  1. Set environment variables in Railway dashboard:

    • OPENAI_API_KEY
    • ANTHROPIC_API_KEY
    • API_KEY
    • SECRET_KEY
    • DATABASE_URL (auto-provisioned by Railway)
    • REDIS_URL (auto-provisioned by Railway)
  2. Deploy:

railway up

API Usage

Submit a Task

curl -X POST https://your-app.railway.app/tasks \
  -H "Authorization: Bearer your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "task": "Create a Python function that calculates fibonacci numbers",
    "metadata": {
      "language": "python",
      "style": "recursive"
    }
  }'

Check Task Status

curl https://your-app.railway.app/tasks/{task_id} \
  -H "Authorization: Bearer your-api-key"

List Available Agents

curl https://your-app.railway.app/agents \
  -H "Authorization: Bearer your-api-key"

MCP Server Usage

Connect to the MCP server via WebSocket:

const ws = new WebSocket('ws://localhost:8001');

ws.on('open', () => {
  // Initialize connection
  ws.send(JSON.stringify({
    jsonrpc: '2.0',
    method: 'initialize',
    params: {},
    id: '1'
  }));

  // Execute a task
  ws.send(JSON.stringify({
    jsonrpc: '2.0',
    method: 'execute_task',
    params: {
      task: 'Analyze this code for security vulnerabilities',
      metadata: { priority: 'high' }
    },
    id: '2'
  }));
});

Agents

  • Orchestrator: Coordinates other agents and manages workflow
  • Planner: Decomposes complex tasks into actionable steps
  • Coder: Implements solutions and writes code
  • Researcher: Gathers information and conducts analysis
  • Reviewer: Reviews code quality and suggests improvements
  • Executor: Safely executes code and runs tests

Configuration

Edit src/config.py or use environment variables:

  • MAX_ITERATIONS: Maximum workflow iterations (default: 20)
  • AUTO_EXECUTE_CODE: Enable automatic code execution (default: true)
  • SAVE_CHECKPOINTS: Enable workflow checkpointing (default: true)
  • LOG_LEVEL: Logging level (default: INFO)

Development

Run Tests

pytest tests/

Code Formatting

black src/
flake8 src/
mypy src/

Add New Agents

  1. Create agent class in src/agents/specialized.py
  2. Add to orchestrator in src/orchestration/graph.py
  3. Update workflow routing logic

Security

  • API endpoints require Bearer token authentication
  • Code execution happens in isolated environments
  • Input validation on all endpoints
  • Rate limiting recommended for production

License

MIT License - see LICENSE file for details

About

Multi-agent orchestrator template - Clean setup for reusable AI agent projects

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors