CoolFace
Apppublic

MCP-1st-Birthday/conductor-mcp

sourceHugging Facemitupdated 10mo agoView on Hugging Face
0likes
App README

๐Ÿ† MCP Hackathon Submission

๐ŸŽฌ Demo Video

![Watch the Demo](https://youtu.be/nP4xgbKMX8Q)

[โ–ถ๏ธ Watch Full Demo on YouTube](https://youtu.be/nP4xgbKMX8Q)

๐Ÿ“ฑ Social Media

LinkedIn Post: View on LinkedIn

๐Ÿ“– Project Description

This project is a prototype for a National AI Operating System designed to manage complex, country-level operations by treating AI Agents as a hierarchical workforce. It combines the reliability of Orkes Conductor with the flexibility of Generative AI using the Model Context Protocol (MCP).

Why This Matters

  • โ€”Nation-Scale Orchestration: Manages AI agents like a government workforce - from strategic planning at the executive level down to specialized task execution
  • โ€”Enterprise-Grade Reliability: Leverages Orkes Conductor's proven orchestration capabilities for mission-critical operations
  • โ€”Dynamic Intelligence: Meta-Agent system that understands natural language and automatically plans complex multi-agent workflows
  • โ€”Security-First Design: OAuth 2.1 + PKCE authentication with human-in-the-loop controls for sensitive operations

Conductor MCP Supervisor: Hierarchical Multi-Agent Ecosystem

This project showcases a hierarchical orchestrator ecosystem with specialized AI managers built on Model Context Protocol (MCP) for Orkes Conductor. Each orchestrator has unique personality via system prompts and specialized algorithms via class inheritance, enabling true organizational AI hierarchy.

๐Ÿ—๏ธ Hierarchical Orchestrator Architecture

mermaid
graph TD
    CEO[CEO Orchestrator<br/>Port: 7860<br/>Strategic Oversight]
    CTO[CTO Orchestrator<br/>Port: 7870<br/>Technical Architecture]
    COO[COO Orchestrator<br/>Port: 7900<br/>Operations Excellence]
    WeatherMgr[Weather Manager<br/>Port: 7890<br/>Weather Domain Expertise]
    
    CEO --> CTO
    CEO --> COO
    CTO --> WeatherMgr
    
    FinancialAgent[FinancialAgent<br/>Port: 8001]
    ConductorAgent[ConductorAgent<br/>Port: 8002]
    WeatherAgent[WeatherAgent<br/>Port: 8004]
    
    CTO --> FinancialAgent
    CTO --> ConductorAgent
    WeatherMgr --> WeatherAgent
    
    classDef orchestrator fill:#e1f5fe,stroke:#01579b,stroke-width:3px
    classDef worker fill:#f3e5f5,stroke:#4a148c,stroke-width:2px
    
    class CEO,CTO,COO,WeatherMgr orchestrator
    class FinancialAgent,ConductorAgent,WeatherAgent worker

๐ŸŒŸ Specialized Orchestrator Features

  • โ€”Personality via System Prompts: Each orchestrator has role-specific prompts loaded from files
  • โ€”Custom Algorithms: Specialized subclasses override core methods for domain expertise
  • โ€”Dynamic Class Loading: Runtime instantiation based on configuration
  • โ€”Hierarchical Communication: Parent-child orchestrator relationships
  • โ€”Role-Based Decision Making: Each level has unique approval workflows

๐Ÿš€ Key Features

  • โ€”โœ… Dynamic Agent Registration - Agents can register/unregister at runtime
  • โ€”โœ… Meta-Agent Intelligence - Natural language task planning and execution
  • โ€”โœ… Hierarchical Orchestrators - Specialized AI managers with unique personalities
  • โ€”โœ… System Prompt Specialization - Role-based behavior via environment prompts
  • โ€”โœ… Custom Algorithm Classes - Domain-specific orchestrator implementations
  • โ€”โœ… Ecosystem Launcher - Automated hierarchy deployment
  • โ€”โœ… Multi-Agent Coordination via Supervisor Pattern
  • โ€”โœ… Conductor Workflow Integration as MCP tools
  • โ€”โœ… OAuth 2.1 + PKCE enhanced security
  • โ€”โœ… Auto-Discovery - Tools from all registered agents automatically available
  • โ€”โœ… Human-in-the-Loop elicitation for sensitive operations

๐Ÿ—๏ธ Architecture: Dynamic Agent Ecosystem with Meta-Agent

mermaid
graph TB
    Supervisor[MCP Supervisor<br/>Port 7860<br/>Agent Registry & Meta-Agent]
    
    FinancialAgent[FinancialAgent<br/>Port 8001<br/>Stock Price & Sentiment Tools]
    ConductorAgent[ConductorAgent<br/>Port 8002<br/>Workflow Tools]
    WeatherAgent[WeatherAgent<br/>Port 8004<br/>Weather Tools]
    CustomAgent[CustomAgent<br/>Port 8005<br/>Your Tools]
    
    ExternalClient[External MCP Client]
    ThirdParty[Third-Party Agent]
    UserPrompt[Natural Language<br/>"Get AAPL price and sentiment"]
    
    Supervisor --> FinancialAgent
    Supervisor --> ConductorAgent
    Supervisor --> WeatherAgent
    Supervisor --> CustomAgent
    
    ExternalClient --> Supervisor
    UserPrompt -->|Meta-Agent| Supervisor
    Supervisor -->|AI Planning| Supervisor
    
    ThirdParty -.->|Auto-Register| Supervisor
    
    classDef supervisor fill:#e1f5fe,stroke:#01579b,stroke-width:3px
    classDef agent fill:#f3e5f5,stroke:#4a148c
    classDef external fill:#fff3e0,stroke:#e65100
    classDef ai fill:#e8f5e8,stroke:#2e7d32
    
    class Supervisor supervisor
    class FinancialAgent,ConductorAgent,WeatherAgent,CustomAgent agent
    class ExternalClient,ThirdParty external
    class UserPrompt ai

๐Ÿš€ Quick Start

Complete Hierarchical Ecosystem (Recommended)

bash
# Launch the entire hierarchical orchestrator ecosystem
python launch_ecosystem.py

# Or with specific configuration
python launch_ecosystem.py --config company_structure.example.json

# Dry run to see what would be launched
python launch_ecosystem.py --dry-run

Individual Agent Development & Testing

For development, testing, or understanding individual agent operations:

bash
# Individual agent launchers (examples for development)
python _examples/individual_launchers/run_agents.py start FinancialAgent
python _examples/individual_launchers/weather_agent_launcher.py

# See _examples/individual_launchers/README.md for detailed usage

Creating Custom Agents

For detailed guide on building third-party agents:

๐Ÿ‘‰ [Read the Agent Developer Guide](AGENT_DEVELOPER_GUIDE.md) - Complete tutorial with examples

Deployment Options

For production deployment strategies:

๐Ÿ‘‰ [See DEPLOYMENT.md](DEPLOYMENT.md) - Docker, Kubernetes, and cloud deployment ๐Ÿ‘‰ [Security Compliance](SECURITY_COMPLIANCE_VALIDATION.md) - OAuth 2.1 + PKCE, audit features

Implementation Details

For technical architecture and design decisions:

๐Ÿ‘‰ [Implementation Summary](IMPLEMENTATION_SUMMARY.md) - System design, patterns, trade-offs ๐Ÿ‘‰ [Agent Developer Guide](AGENT_DEVELOPER_GUIDE.md) - Creating custom worker agents

๐Ÿ”ง Agent Registration Endpoints

Register an Agent

bash
curl -X POST http://localhost:7860/registry/register \
  -H "Content-Type: application/json" \
  -d '{
    "agent_name": "MyCustomAgent",
    "agent_address": "http://localhost:8005",
    "tools": [
      {
        "name": "my_tool",
        "description": "My custom tool",
        "inputSchema": {
          "type": "object",
          "properties": {"input": {"type": "string"}}
        }
      }
    ],
    "description": "My custom third-party agent",
    "version": "1.0.0"
  }'

Unregister an Agent

bash
curl -X POST http://localhost:7860/registry/unregister \
  -H "Content-Type: application/json" \
  -d '{"agent_name": "MyCustomAgent"}'

๐Ÿงช API Testing

Discover All Available Tools

bash
curl http://localhost:7860/mcp/tools/list

Call a Weather Tool (delegated to WeatherAgent)

bash
curl -X POST http://localhost:7860/mcp/tools/call \
  -H "Content-Type: application/json" \
  -d '{
    "name": "get_weather",
    "arguments": {"location": "New York", "units": "celsius"}
  }'

Call a Stock Price Tool (delegated to FinancialAgent)

bash
curl -X POST http://localhost:7860/mcp/tools/call \
  -H "Content-Type: application/json" \
  -d '{
    "name": "get_stock_price",
    "arguments": {"symbol": "AAPL"}
  }'

Meta-Agent: Natural Language Task Execution

bash
curl -X POST http://localhost:7860/mcp/execute_task \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Berapa harga saham Apple dan bagaimana sentimen pasar saat ini?"
  }'

Check Agent Status

bash
curl http://localhost:7860/health/agents

๐Ÿ› ๏ธ Creating Specialized Orchestrators

1. Create Custom Orchestrator Class

python
# conductor_mcp_server/orchestrators/my_orchestrator.py
from conductor_mcp_server.orchestrators import MCPHandler, ExecutionPlan

class MyOrchestrator(MCPHandler):
    def __init__(self, conductor_client, settings):
        super().__init__(conductor_client, settings)
        logger.info("MyOrchestrator initialized - Custom logic enabled")
    
    async def _execute_plan(self, plan: ExecutionPlan, user):
        """Override plan execution with custom logic"""
        logger.info("MyOrchestrator - Executing plan with custom oversight")
        
        # Add custom validation or approval step
        custom_step = ExecutionStep(
            tool_name="custom_validation",
            arguments={"validation_type": "my_domain"},
            step_id="my_custom_step"
        )
        
        plan.steps.insert(0, custom_step)
        
        # Execute using parent method
        results = await super()._execute_plan(plan, user)
        
        # Add custom assessment
        results.append({
            "step_id": "my_custom_assessment",
            "tool_name": "custom_oversight",
            "result": {"custom_status": "validated"},
            "step_number": len(plan.steps) + 1
        })
        
        return results

2. Create System Prompt File

bash
# prompts/my_role_prompt.txt
You are a specialized manager with expertise in:
- Custom domain knowledge
- Specific decision-making patterns
- Unique approval workflows
- Domain-specific compliance requirements

Your responsibilities include:
1. Domain-specific oversight
2. Specialized risk assessment
3. Custom approval processes
4. Expert-level decision making

When handling tasks:
- Apply domain-specific expertise
- Follow specialized protocols
- Consider unique risk factors
- Follow custom approval workflows

3. Configure in company_structure.json

json
{
  "name": "My Special Manager",
  "type": "orchestrator",
  "port": 8000,
  "description": "My specialized domain manager",
  "system_prompt_file": "prompts/my_role_prompt.txt",
  "orchestrator_class": "conductor_mcp_server.orchestrators.MyOrchestrator",
  "subordinates": [...]
}

4. Launch with Ecosystem

bash
# Use the ecosystem launcher
python launch_ecosystem.py --config company_structure.json

๐Ÿ› ๏ธ Creating Custom Agents

1. Use the Template

python
from conductor_mcp_server.agents.base import AbstractWorkerAgent, WorkerAgentConfig

class MyCustomAgent(AbstractWorkerAgent):
    def __init__(self, settings):
        config = WorkerAgentConfig(
            agent_name="MyCustomAgent",
            port=8005,
            host="0.0.0.0",
            description="My custom third-party agent",
            version="1.0.0"
        )
        super().__init__(config, settings)
    
    async def initialize(self):
        self._register_my_tools()
    
    def _register_my_tools(self):
        self.register_tool(
            name="my_tool",
            description="My custom tool description",
            input_schema={...},
            implementation=self._my_tool_implementation
        )

2. Add Auto-Registration

python
async def register_agent_with_supervisor(agent_name, agent_url, tools, supervisor_url):
    # Auto-register with supervisor
    registration_payload = {...}
    # ... registration logic

3. Run Your Agent

bash
python my_custom_agent.py

๐Ÿ“Š Available Agents & Tools

Default Agents (via run_agents.py)

  • โ€”FinancialAgent (Port 8001): get_stock_price, get_multiple_prices
  • โ€”ConductorAgent (Port 8002): start_workflow, get_workflow_status

Third-Party Examples

  • โ€”WeatherAgent (Port 8004): get_weather, get_forecast

Dynamic Discovery

  • โ€”All tools from registered agents automatically available via /mcp/tools/list
  • โ€”Tool calls automatically routed to correct agent
  • โ€”Real-time agent health monitoring

๐Ÿ” Security Features

OAuth 2.1 + PKCE

  • โ€”Enhanced security with PKCE (Proof Key for Code Exchange)
  • โ€”PAR (Pushed Authorization Requests) protection
  • โ€”Dynamic client registration
  • โ€”Token rotation and refresh

Resource Security

  • โ€”File System: file:// URIs with path validation
  • โ€”Database: db:// URIs with operation control
  • โ€”Agent Context: agent:// URIs for inter-agent sharing

Human-in-the-Loop

  • โ€”Sensitive operation detection
  • โ€”Workflow pausing for confirmation
  • โ€”Elicitation prompts for risky operations

๐Ÿ“Š Monitoring

  • โ€”Supervisor Health: /health - System status
  • โ€”Agent Status: /health/agents - All registered agents
  • โ€”Tool Discovery: /mcp/tools/list - Available tools from all agents
  • โ€”Metrics: /metrics - Prometheus format metrics
  • โ€”OpenTelemetry: Distributed tracing enabled
  • โ€”Structured Logging: JSON format with correlation IDs

๐ŸŽฏ Use Cases

1. Dynamic Agent Ecosystem

FinancialAgent + WeatherAgent + CustomAgent
    โ†“
Automatic Tool Discovery & Routing
    โ†“
Unified MCP Interface

2. Third-Party Integration

External Service โ†’ Custom Agent โ†’ Supervisor
    โ†“
Tools Available to All Clients

3. Plugin Architecture

New Requirement โ†’ New Agent โ†’ Auto-Register โ†’ Available Immediately

๐Ÿ› ๏ธ Technical Stack

  • โ€”FastAPI: High-performance async web framework
  • โ€”MCP Protocol: Model Context Protocol for agent communication
  • โ€”Orkes Conductor: Workflow orchestration engine
  • โ€”OAuth 2.1 + PKCE: Enhanced security standards
  • โ€”OpenTelemetry: Distributed tracing and monitoring
  • โ€”AsyncIO: High-performance concurrent programming
  • โ€”Pydantic: Data validation and serialization

๐Ÿ“– API Documentation

  • โ€”Swagger UI: /docs - Interactive API testing
  • โ€”Agent Registry: /registry/* - Dynamic agent management
  • โ€”MCP Endpoints: /mcp/* - Standard MCP protocol endpoints
  • โ€”Health Checks: /health/* - System monitoring
  • โ€”MCP Spec: Model Context Protocol

๐Ÿš€ Deployment

The ecosystem is designed for easy deployment:

  1. 1.Supervisor: Single instance handling registration and routing
  2. 2.Agents: Can be deployed independently on any infrastructure
  3. 3.Auto-Discovery: Agents register automatically, no manual configuration
  4. 4.Scalability: Add/remove agents without restarting supervisor

Built for the future of AI agent coordination - truly dynamic and extensible!

๐Ÿ—๏ธ Architecture

mermaid
graph TB
    Agent1[AI Agent 1<br/>Portfolio Manager]
    Agent2[AI Agent 2<br/>Risk Analysis]
    Agent3[AI Agent 3<br/>Notifications]
    
    Gateway[MCP Gateway<br/>Centralized Auth<br/>Rate Limiting]
    
    Server[FastAPI MCP Server<br/>Conductor Integration]
    Conductor[Orkes Conductor<br/>Workflow Orchestration]
    
    Worker1[Stock Price<br/>Worker]
    Worker2[Risk Analysis<br/>Worker]
    Worker3[Alert<br/>Worker]
    
    Agent1 --> Gateway
    Agent2 --> Gateway  
    Agent3 --> Gateway
    
    Gateway --> Server
    Server --> Conductor
    Conductor --> Worker1
    Conductor --> Worker2
    Conductor --> Worker3
    
    classDef agent fill:#e1f5fe,stroke:#01579b
    classDef server fill:#f3e5f5,stroke:#4a148c
    classDef conductor fill:#e8f5e8,stroke:#1b5e20
    
    class Agent1,Agent2,Agent3 agent
    class Gateway,Server server
    class Conductor,Worker1,Worker2,Worker3 conductor

๐Ÿ”ง Quick Start (Local Development)

bash
# Clone and install
git clone https://huggingface.co/spaces/galuh1300d/conductor-mcp
cd conductor-mcp

# Install dependencies  
pip install -r requirements.txt

# Start the MCP server
uvicorn conductor_mcp_server.main:app --host 0.0.0.0 --port 7860

# Run demo client
python conductor_mcp_server/demo_client.py

๐Ÿงช API Testing

Discover Available Tools

bash
curl http://localhost:7860/mcp/tools

Call a Stock Price Tool

bash
curl -X POST http://localhost:7860/mcp/tools/call \
  -H "Content-Type: application/json" \
  -d '{
    "name": "get_stock_price", 
    "arguments": {"symbol": "AAPL"}
  }'

Multi-Agent Workflow Demo

bash
curl http://localhost:7860/demo

๐Ÿ”’ Security Features

OAuth 2.1 + PKCE

  • โ€”Enhanced security with PKCE (Proof Key for Code Exchange)
  • โ€”PAR (Pushed Authorization Requests) protection
  • โ€”Dynamic client registration
  • โ€”Token rotation and refresh

Resource Security

  • โ€”File System: file:// URIs with path validation
  • โ€”Database: db:// URIs with operation control
  • โ€”Agent Context: agent:// URIs for inter-agent sharing

Human-in-the-Loop

  • โ€”Sensitive operation detection
  • โ€”Workflow pausing for confirmation
  • โ€”Elicitation prompts for risky actions

๐Ÿ“Š Monitoring

  • โ€”Health Endpoint: /health - System status
  • โ€”Metrics: /metrics - Prometheus format metrics
  • โ€”OpenTelemetry: Distributed tracing enabled
  • โ€”Structured Logging: JSON format with correlation IDs

๐ŸŽฏ Hackathon Use Cases

1. Portfolio Management Workflow

Portfolio Agent โ†’ Risk Analysis Agent โ†’ Notification Agent
     โ†“
Conductor Workflow Orchestration
     โ†“
Real-time Stock Data + Risk Alerts

2. Multi-Agent Decision Making

Agent A (Research) โ†’ Agent B (Analysis) โ†’ Agent C (Execution)
     โ†“
Consensus Building via MCP Protocol
     โ†“
Automated Workflow Execution

3. Human-in-the-Loop Operations

Sensitive Operation Detected โ†’ Elicitation Request โ†’ Human Approval
     โ†“
Workflow Continuation or Cancellation

๐Ÿ› ๏ธ Technical Stack

  • โ€”FastAPI: High-performance async web framework
  • โ€”MCP Protocol: Model Context Protocol for agent communication
  • โ€”Orkes Conductor: Workflow orchestration engine
  • โ€”OAuth 2.1 + PKCE: Enhanced security standards
  • โ€”OpenTelemetry: Distributed tracing and monitoring
  • โ€”Redis: Caching and rate limiting
  • โ€”Pydantic: Data validation and serialization

๐Ÿ“– Documentation

๐Ÿค Hackathon Focus

This demo showcases real-world AI agent coordination through:

  1. 1.Standardized Communication: MCP protocol enables different AI systems to work together
  2. 2.Workflow Integration: Conductor orchestrates complex multi-agent workflows
  3. 3.Security First: OAuth 2.1 + PKCE for production-ready security
  4. 4.Production Ready: Comprehensive monitoring, logging, and error handling
  5. 5.Human-in-the-Loop: Critical operations require human approval

Perfect for demonstrating enterprise-grade multi-agent systems!


Built for the hackathon - showcasing the future of AI agent coordination

Force rebuild Fri Nov 21 14:27:50 WIB 2025