MCP Agent Orchestration System
A state-based agent orchestration system using the Model Context Protocol (MCP).
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
Using uv (recommended)
# 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 machineorchestrator_client.py- Client demonstrating the orchestration flowrequirements.txt- Dependencies for the project.gitignore- Git ignore file
Project Structure
orchestrator.py- The main MCP server implementing the state machineorchestrator_client.py- Client demonstrating the orchestration flowrequirements.txt- Dependencies for the project
Running the Orchestration System
- Start the orchestration server directly for testing:
python orchestrator.py
- 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
-
Open your Claude for Desktop configuration file:
macOS/Linux:
# Create or edit the configuration file code ~/Library/Application\ Support/Claude/claude_desktop_config.jsonWindows:
# Path may vary depending on your Windows version code %APPDATA%\Claude\claude_desktop_config.json -
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.
-
Save the configuration file and restart Claude for Desktop.
3. Using the Orchestrator in Claude
Once configured, you can:
- Open Claude for Desktop
- Click on the MCP server icon in the sidebar
- Select "agent-orchestrator" from the list of available servers
- 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
- Add the state to the
AgentStateenum inorchestrator.py - Create a prompt function for the new state
- Update the transition logic in
_get_available_transitions() - 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.
関連サーバー
Scout Monitoring MCP
スポンサーPut performance and error data directly in the hands of your AI assistant.
Alpha Vantage MCP Server
スポンサーAccess financial market data: realtime & historical stock, ETF, options, forex, crypto, commodities, fundamentals, technical indicators, & more
Code Graph RAG MCP
Code Rag with Graph - local only installation
Composer Package README MCP Server
Fetches comprehensive information about Composer packages from Packagist, including READMEs, metadata, and search functionality.
TeamCity MCP Server
MCP server for JetBrains TeamCity with 87 tools for builds, tests, agents, and CI/CD pipeline management.
MCP-RAGNAR
A local MCP server implementing Retrieval-Augmented Generation (RAG) with sentence window retrieval and support for multiple file types.
MCP Terminal Server
A secure command-line interface server for the Model Context Protocol (MCP) that allows AI models to interact with a user's terminal.
LangSmith MCP Server
An MCP server for fetching conversation history and prompts from the LangSmith observability platform.
BloodHound-MCP
integration that connects BloodHound with AI through MCP, allowing security professionals to analyze Active Directory attack paths using natural language queries instead of Cypher.
Jupyter MCP Server
Interact with Jupyter notebooks running in any JupyterLab environment, supporting real-time control and smart execution of notebook cells.
ailist-mcp
Search and discover Ai projects from Claude Code. Browse 1,400+ MCP servers, tools, and agents. Submit projects via your Ai agent.
JSON MCP
MCP server empowers LLMs to interact with JSON files efficiently. With JSON MCP, you can split, merge, etc.