From 40574fb0b9e32ecdbce548facae68123c95b813d Mon Sep 17 00:00:00 2001 From: jjyaoao Date: Thu, 13 Mar 2025 11:09:18 +0800 Subject: [PATCH] add run_mcp instructions and new requirements --- owl/run_mcp.py | 75 ++++++++++++++++++++++++++- owl/utils/mcp/mcp_servers_config.json | 7 ++- requirements.txt | 3 +- 3 files changed, 81 insertions(+), 4 deletions(-) diff --git a/owl/run_mcp.py b/owl/run_mcp.py index a2d5832..84c201d 100644 --- a/owl/run_mcp.py +++ b/owl/run_mcp.py @@ -1,3 +1,74 @@ +"""MCP Multi-Agent System Example + +This example demonstrates how to use MCP (Model Context Protocol) with CAMEL agents +for advanced information retrieval and processing tasks. + +Environment Setup: +1. Configure the required dependencies of owl library. + +2. Go Environment (v1.23.2+): + ```bash + # Verify Go installation + go version + + # Add Go binary path to PATH + export PATH=$PATH:~/go/bin + # Note: Add to ~/.bashrc or ~/.zshrc for persistence + ``` + +3. Playwright Setup: + ```bash + # Install Node.js and npm first + npm install -g @executeautomation/playwright-mcp-server + npx playwright install-deps + + # Configure in mcp_servers_config.json: + { + "mcpServers": { + "playwright": { + "command": "npx", + "args": ["-y", "@executeautomation/playwright-mcp-server"] + } + } + } + ``` + +4. MCP Filesystem Server Setup: + ```bash + # Install MCP filesystem server + go install github.com/mark3labs/mcp-filesystem-server@latest + npm install -g @modelcontextprotocol/server-filesystem + + # Configure mcp_servers_config.json in owl/utils/mcp/ + { + "mcpServers": { + "filesystem": { + "command": "mcp-filesystem-server", + "args": [ + "/home/your_path", + "/home/your_path" + ], + "type": "filesystem" + } + } + } + ``` + +Usage: +1. Ensure all MCP servers are properly configured in mcp_servers_config.json +2. Run this script to create a multi-agent system that can: + - Access and manipulate files through MCP filesystem server + - Perform web automation tasks using Playwright + - Process and generate information using GPT-4o +3. The system will execute the specified task while maintaining security through + relative paths and controlled access + +Note: +- All file operations are restricted to configured directories +- System uses GPT-4o for both user and assistant roles +- Supports asynchronous operations for efficient processing +""" + import asyncio from pathlib import Path from typing import List @@ -9,7 +80,7 @@ from camel.toolkits import FunctionTool from camel.types import ModelPlatformType, ModelType from camel.logger import set_log_level -from utils.async_role_playing import OwlRolePlaying, run_society +from utils.enhanced_role_playing import OwlRolePlaying, run_society from utils.mcp.mcp_toolkit_manager import MCPToolkitManager @@ -71,7 +142,7 @@ async def main(): question = ( "I'd like a academic report about Guohao Li, including his research " - "direction, published papers (up to 20), institutions, etc." + "direction, published papers (At least 3), institutions, etc." "Then organize the report in Markdown format and save it to my desktop" ) diff --git a/owl/utils/mcp/mcp_servers_config.json b/owl/utils/mcp/mcp_servers_config.json index accd678..f51fac0 100644 --- a/owl/utils/mcp/mcp_servers_config.json +++ b/owl/utils/mcp/mcp_servers_config.json @@ -7,10 +7,15 @@ "/Users/username/Downloads" ] }, + "playwright": { + "command": "npx", + "args": ["-y", "@executeautomation/playwright-mcp-server"] + }, "simple-arxiv": { "command": "python", "args": ["-m", "mcp_simple_arxiv"] } }, "mcpWebServers": {} -} \ No newline at end of file +} + diff --git a/requirements.txt b/requirements.txt index 644a765..3a3e5e3 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,4 +3,5 @@ chunkr-ai>=0.0.41 docx2markdown>=0.1.1 gradio>=3.50.2 mcp==1.3.0 -mcp-simple-arxiv==0.2.2 \ No newline at end of file +mcp-simple-arxiv==0.2.2 +mcp-server-fetch==2025.1.17 \ No newline at end of file