Provides containerization support for the MCP server, allowing consistent environment setup and execution with proper API key configuration.
Integration with Google Gemini models through API keys, enabling the MCP to use Gemini models for creative tasks, comparative analysis, and general-purpose tasks.
Powers the MCP's core functionality for LLM interactions, agentic behavior, and orchestration, enabling modular prompt handling and task delegation.
Integration with OpenAI models (GPT) through API keys, allowing the MCP to use ChatGPT/GPT-4 for structured sections and conversation starters.
Master Control Program (MCP)
This directory contains the implementation of the Master Control Program (MCP) based on the architectural design outlined in mcp_architecture.md
. The MCP is designed to act as an orchestrator, breaking down user prompts into actionable tasks and delegating them to specialized agents (Roo Modes) using LangChain.
Project Structure
Setup and Installation
- Python Environment: Ensure you have Python 3.9+ installed.
- Dependencies: Install the required Python packages. You can create a
requirements.txt
file with the following content and then install them:Then run: - API Keys: The LLM models require API keys. It is highly recommended to set these as environment variables.
- For Google Gemini models, set
GOOGLE_API_KEY
. - For OpenAI models (if used), set
OPENAI_API_KEY
. - For Anthropic Claude models (if used), set
ANTHROPIC_API_KEY
.
Example (for Linux/macOS):
Replace
"your_google_api_key_here"
with your actual API key. - For Google Gemini models, set
How to Use
The MCP is designed to be integrated into the 'roo code' VS Code extension environment. For demonstration purposes, each core module (prompt_ingestion.py
, task_decomposition.py
, orchestration_engine.py
) contains an if __name__ == "__main__":
block with example usage.
To see the MCP in action, you can run the orchestration_engine.py
script directly:
Alternatively, you can run it using Docker for a consistent environment.
Running with Docker
- Build the Docker image: Navigate to the
aula 4/mcp/
directory in your terminal and build the image. - Run the Docker container:Important: Replace
"your_google_api_key_here"
with your actual Google API key. If you are using other LLMs (OpenAI, Anthropic), ensure you pass their respective API keys as environment variables (e.g.,-e OPENAI_API_KEY="..."
).
This will simulate the end-to-end flow:
- Prompt Ingestion: An example user prompt is processed to extract intent and entities.
- Task Decomposition: The request is broken down into a list of subtasks.
- Agent Routing: Each subtask is routed to a suitable Roo Mode (e.g., 'code', 'architect').
- Orchestration: The
OrchestrationEngine
simulates delegating tasks to the respective Roo Modes using a mockswitch_mode
tool.
You will see console output demonstrating the flow, including the simulated mode switches and the recommended LLM for each task.
Key Features
- Modular Design: Clear separation of concerns into distinct modules.
- LangChain Integration: Leverages LangChain for LLM interactions, agentic behavior, and orchestration.
- Dynamic Task Decomposition: LLM-powered agents break down complex requests into manageable subtasks.
- Intelligent Agent Routing: Routes tasks to the most appropriate Roo Mode based on their
Role Definition
. - LLM Recommendation: Suggests the best LLM type (e.g., Gemini, Claude, GPT-4) for each specific task based on its characteristics, as configured in
config/settings.py
andconfig/llm_config.py
. - Centralized LLM Configuration:
config/llm_config.py
provides a single place to manage LLM model names and API key environment variables.
LLM Recommendation Logic
The MCP recommends LLMs based on a mapping defined in config/settings.py
. This mapping associates task types (e.g., code.generate
, design.architecture
) with conceptual LLM strengths:
- Gemini: Best for creative tasks, comparative analysis, and general-purpose tasks.
- ChatGPT/GPT-4: Ideal for structured sections and conversation starters.
- Claude: Strong in reasoning frameworks and handling longer contexts.
- Others: A fallback for tasks that don't require specific LLM strengths, defaulting to a general-purpose model.
The config/llm_config.py
then maps these conceptual types to actual model names (e.g., "Gemini" maps to "gemini-pro" by default, but can be configured to "gemini-1.5-pro" or "gemini-1.5-flash").
Future Enhancements
- Direct VS Code Integration: Implement actual
switch_mode
calls and receive real task completion signals from the VS Code extension. - Active LLM Retrieval: Develop an API or mechanism to fetch the currently active LLM model within the Roo Code VS Code environment.
- Advanced Error Handling: More robust error recovery and retry mechanisms.
- Persistent State: Implement a way to save and load the MCP's state and task progress.
- User Interface Feedback: Provide more detailed feedback to the user through the VS Code UI during orchestration.
Exposing MCP as a Roo MCP Server
The current MCP implementation is a set of Python modules designed for demonstration and simulation. To allow Roo Code to connect to this MCP as a server and utilize its capabilities (e.g., for prompt ingestion, task decomposition, agent routing), additional steps are required to transform it into a functional server that adheres to the Model Context Protocol (MCP).
There are two primary ways to expose this MCP as a server:
1. As a Local (Stdio) Server
This is the recommended approach for locally running tools. Roo Code manages the lifecycle of the server, running it as a background process and communicating with it via standard input/output (stdio).
Here's a conceptual outline for adapting this project to a local Stdio server:
- Install MCP SDK for Python (if available):
- If a Python version of
@modelcontextprotocol/sdk
exists, you would install it. Otherwise, you'd need to implement the Stdio transport logic manually (reading from stdin, writing to stdout).
- If a Python version of
- Create a Server Entry Point:
- Create a new Python script (e.g.,
mcp/server.py
) that initializes the MCP components and exposes their functionalities as tools.
- Create a new Python script (e.g.,
- Define Tools:
- Use the MCP SDK's
Tool
or a custom mechanism to define the MCP's capabilities (e.g.,ingest_prompt
,decompose_task
,route_task
,execute_plan
) as callable functions.
- Use the MCP SDK's
- Implement Stdio Transport:
- The server script would continuously read incoming messages from
stdin
, process them, and write responses tostdout
. This is the core of the Stdio transport.
- The server script would continuously read incoming messages from
2. As a Remote (HTTP/SSE) Server
This approach involves running the MCP as a standalone web server, which Roo Code connects to via HTTP. This is suitable if you want to run the MCP on a different machine or as a separate, long-running service.
Here's a conceptual outline of how this could be achieved:
- Implement a Web Server:
- Introduce a web framework like Flask or FastAPI to create HTTP endpoints.
- Example:
pip install flask
orpip install fastapi uvicorn
.
- Define MCP Endpoints:
- Expose endpoints that conform to the MCP specification. The
mcp_architecture.md
mentions/mcp/delegate
. You would also need endpoints for tool discovery (e.g.,/mcp/tools
) and potentially resource access. - These endpoints would internally call the
PromptIngestion
,TaskDecomposition
, andAgentRouter
components.
- Expose endpoints that conform to the MCP specification. The
- Tool Registration:
- The MCP server would need to define its own capabilities (e.g., "ingest_prompt", "decompose_task", "route_task", "execute_plan") as tools that Roo can discover and use. This would involve returning a structured list of tools via a dedicated endpoint.
- Dockerfile Update:
- Modify the
Dockerfile
to run the web server application (e.g.,CMD ["uvicorn", "main:app", "--host", "0.0.0.0", "--port", "8000"]
if using FastAPI). - Ensure the Docker container exposes the necessary port (e.g.,
EXPOSE 8000
).
- Modify the
Example Conceptual main.py
(using FastAPI):
Configuring Roo Code to use the MCP Server
To enable Roo Code to connect to the local MCP server you just created, you need to add its configuration to the mcp_settings.json
file.
- Locate
mcp_settings.json
:- On Linux, this file is typically located at:
/home/sony/.vscode-server/data/User/globalStorage/rooveterinaryinc.roo-cline/settings/mcp_settings.json
- On Linux, this file is typically located at:
- Add the Server Configuration:
- Open the
mcp_settings.json
file. - Inside the
"mcpServers"
object, add a new entry for"roo-mcp-server"
. Ensure you replace the placeholder path with the actual path to yourindex.js
file.
- Justification: This configuration tells Roo Code how to start and communicate with your local MCP server.
"command": "node"
: Specifies that the server should be run using Node.js."args": ["/home/sony/www/ia/mcp/server/build/index.js"]
: Provides the full path to the compiled JavaScript entry point of your MCP server."disabled": false
: Ensures the server is active and enabled."alwaysAllow": []
and"disabledTools": []
: These are default settings, indicating no tools are always allowed without confirmation and no tools are explicitly disabled.
- Open the
- Save the File:
- Save the
mcp_settings.json
file. Roo Code will automatically detect the changes and attempt to connect to the new server.
- Save the
Once configured, Roo Code will recognize the roo-mcp-server
and its exposed tools (like greet
). You can then interact with these tools directly through your prompts.
```
This server cannot be installed
An orchestration system that breaks down user prompts into actionable tasks and delegates them to specialized agents (Roo Modes) using LangChain.
Related MCP Servers
- AsecurityFlicenseAqualityEnables creation, management, and templating of prompts through a simplified SOLID architecture, allowing users to organize prompts by category and fill in templates at runtime.Last updated -6161TypeScript
- -securityAlicense-qualityServes prompt templates through a standardized protocol for transforming basic user queries into optimized prompts for AI systems.Last updated -6PythonApache 2.0
- -securityFlicense-qualityA Model Context Protocol server that enables conversational LLMs to delegate complex research tasks to specialized AI agents powered by various OpenRouter models, coordinated by a Claude orchestrator.Last updated -16JavaScript
- -securityFlicense-qualityA state-based agent orchestration system that allows transitions between different states (IDLE, PLANNING, RESEARCHING, EXECUTING, REVIEWING, ERROR) while maintaining conversation context and providing state-specific prompts.Last updated -2Python