Skip to main content
Glama

MCP Agent Orchestration System

by aviz85

MCP Agent Orchestration System

A Python implementation of a state-based agent orchestration system using the Model Context Protocol (MCP).

What is MCP?

The Model Context Protocol (MCP) allows applications to provide context for LLMs in a standardized way, separating the concerns of providing context from the actual LLM interaction. With MCP, you can build servers that expose:

  • Resources: Data sources that provide information to LLMs
  • Tools: Functions that allow LLMs to perform actions
  • Prompts: Reusable templates for LLM interactions

Installation

Prerequisites

  • Python 3.10 or higher
  • MCP Python SDK 1.2.0 or higher

Setting Up Your Environment

# Install uv curl -LsSf https://astral.sh/uv/install.sh | sh # Create a new directory for our project uv init mcp-agents-orchestra cd mcp-agents-orchestra # Create virtual environment and activate it uv venv source .venv/bin/activate # On Unix/macOS .venv\Scripts\activate # On Windows # Install dependencies uv add "mcp[cli]" httpx
Using pip
# Create a new directory for our project mkdir mcp-agents-orchestra cd mcp-agents-orchestra # Create a virtual environment python -m venv venv source venv/bin/activate # On Unix/macOS venv\Scripts\activate # On Windows # Install dependencies pip install "mcp[cli]" httpx

Clone or Download Project Files

Place the project files in your directory:

  • orchestrator.py - The main MCP server implementing the state machine
  • orchestrator_client.py - Client demonstrating the orchestration flow
  • requirements.txt - Dependencies for the project
  • .gitignore - Git ignore file

Project Structure

  • orchestrator.py - The main MCP server implementing the state machine
  • orchestrator_client.py - Client demonstrating the orchestration flow
  • requirements.txt - Dependencies for the project

Running the Orchestration System

  1. Start the orchestration server directly for testing:
python orchestrator.py
  1. In a separate terminal, run the client to see the orchestration in action:
python orchestrator_client.py

Integrating with Claude for Desktop

1. Install Claude for Desktop

Make sure you have Claude for Desktop installed. You can download the latest version from Anthropic's website.

2. Configure Claude for Desktop

  1. Open your Claude for Desktop configuration file:macOS/Linux:
    # Create or edit the configuration file code ~/Library/Application\ Support/Claude/claude_desktop_config.json
    Windows:
    # Path may vary depending on your Windows version code %APPDATA%\Claude\claude_desktop_config.json
  2. Add the orchestrator server configuration:
    { "mcpServers": { "agent-orchestrator": { "command": "python", "args": [ "/ABSOLUTE/PATH/TO/YOUR/PROJECT/orchestrator.py" ] } } }
    Replace the path with the absolute path to your orchestrator.py file.
  3. Save the configuration file and restart Claude for Desktop.

3. Using the Orchestrator in Claude

Once configured, you can:

  1. Open Claude for Desktop
  2. Click on the MCP server icon in the sidebar
  3. Select "agent-orchestrator" from the list of available servers
  4. Start interacting with the orchestration system

Claude will be able to:

  • Transition between different agent states
  • Store and retrieve information from the knowledge base
  • Maintain conversation context across state transitions
  • Access state-specific prompts

Agent States

The orchestration system implements a state machine with the following states:

  • IDLE: Waiting for instructions
  • PLANNING: Creating a structured plan for a task
  • RESEARCHING: Gathering information needed for a task
  • EXECUTING: Carrying out planned actions
  • REVIEWING: Evaluating results and determining next steps
  • ERROR: Handling errors or unexpected situations

Customizing the System

Adding New States

  1. Add the state to the AgentState enum in orchestrator.py
  2. Create a prompt function for the new state
  3. Update the transition logic in _get_available_transitions()
  4. Add handlers for the new state in resource access functions

Creating Custom Tools

Add new tools by creating functions decorated with @mcp.tool():

@mcp.tool() def my_custom_tool(arg1: str, arg2: int, ctx: Context) -> str: """Description of what this tool does Args: arg1: Description of arg1 arg2: Description of arg2 """ # Implementation here return "Result"

Development and Testing

Using the MCP CLI

The MCP CLI provides tools for development and testing:

# Install MCP CLI if you haven't already pip install "mcp[cli]" # Test your server with the MCP Inspector mcp dev orchestrator.py # Install in Claude Desktop mcp install orchestrator.py

Manual Testing with Python

from mcp import ClientSession, StdioServerParameters from mcp.client.stdio import stdio_client async with stdio_client(StdioServerParameters(command="python", args=["orchestrator.py"])) as (read, write): async with ClientSession(read, write) as session: await session.initialize() # Test state transitions await session.call_tool("transition_state", arguments={"new_state": "PLANNING"})

Resources

License

This project is licensed under the MIT License - see the LICENSE file for details.

-
security - not tested
F
license - not found
-
quality - not tested

local-only server

The server can only run on the client's local machine because it depends on local resources.

基于状态的代理编排系统,允许在不同状态(IDLE、PLANNING、REVIEWING、EXECUTING、REVIEWING、ERROR)之间转换,同时保持对话上下文并提供特定于状态的提示。

  1. 什么是 MCP?
    1. 安装
      1. 先决条件
      2. 设置您的环境
      3. 克隆或下载项目文件
    2. 项目结构
      1. 运行编排系统
        1. 与 Claude 桌面版集成
          1. 1. 安装 Claude 桌面版
          2. 2. 配置 Claude 桌面版
          3. 3. 在 Claude 中使用 Orchestrator
        2. 代理状态
          1. 定制系统
            1. 添加新州
            2. 创建自定义工具
          2. 开发和测试
            1. 使用 MCP CLI
            2. 使用 Python 进行手动测试
          3. 资源
            1. 执照

              Related MCP Servers

              • -
                security
                A
                license
                -
                quality
                A lightweight framework for building and orchestrating AI agents through the Model Context Protocol, enabling users to create scalable multi-agent systems using only configuration files.
                Last updated -
                MIT License
                • Apple
                • Linux
              • -
                security
                F
                license
                -
                quality
                An agentic AI system that orchestrates multiple specialized AI tools to perform business analytics and knowledge retrieval, allowing users to analyze data and access business information through natural language queries.
                Last updated -
                2
              • -
                security
                F
                license
                -
                quality
                A master control platform that orchestrates intelligent agents with a plug-and-play architecture, allowing users to manage and coordinate multiple AI agents through a unified system.
                Last updated -
              • -
                security
                F
                license
                -
                quality
                A master control program that orchestrates intelligent agents with a plug-and-play architecture, enabling seamless coordination and management of AI agent workflows.
                Last updated -

              View all related MCP servers

              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/aviz85/mcp-agents-orchestra'

              If you have feedback or need assistance with the MCP directory API, please join our Discord server