MCP Agent with various tools
Project description
Multi-Agent Framework with MCP Integration
This is a multi-agent framework built using LangChain and LangGraph, integrated with MCP (Model Context Protocol) tools, and with a Gradio interface for interaction.
✨ New Features
🔍 Structured Logging with Loguru
- Professional logging using loguru library
- Structured log messages with timestamps, log levels, and agent identification
- Color-coded console output for better readability
- Configurable log levels (DEBUG, INFO, WARNING, ERROR)
- Emoji-coded agent identification for easy tracking:
- 🤖 [COORDINATOR]: Coordination decisions
- 🔍 [RESEARCHER]: Research activities
- ✍️ [WRITER]: Content creation
- 📊 [ANALYST]: Data analysis
- 🚀 [SYSTEM]: System-level events
🎯 Role-Based Tool Access
Each agent now has specific tools based on their role:
- Researcher Agent:
calculate,multiply,sum_numbers,get_weather - Writer Agent:
generate_image,classify_image - Analyst Agent:
segment_image,detect_objects,classify_image - Coordinator Agent: No direct tools (focuses on orchestration)
Features
- MCP Integration: Agents can discover and use tools from MCP servers
- Coordinator Agent: Analyzes user queries and routes to appropriate specialized agents
- Researcher Agent: Uses MCP tools for information gathering
- Writer Agent: Uses MCP tools for content creation
- Analyst Agent: Uses MCP tools for data analysis
- Gradio UI: Interactive web interface to communicate with the agents
- Comprehensive Logging: Detailed logs of agent interactions and tool usage
Setup & CI/CD
-
Install dependencies:
cd /home/bingjie/workspace/EyeAgent-mcp/eyeagent uv sync
-
Set up your OpenAI API key:
- Edit the
.envfile and add your OpenAI API key:OPENAI_API_KEY=your_actual_api_key_here
- Edit the
-
Configure logging (optional):
- The framework uses loguru for structured logging
- Default log level is INFO
- Logs are displayed in console with colors and timestamps
- You can modify logging configuration in
multiagent_framework.py
-
Ensure MCP server is running:
- The framework expects an MCP server running at
http://localhost:8001/mcp/ - You can test the MCP server using the
main_client.pyscript
- The framework expects an MCP server running at
Running the Framework
Run the multi-agent system with the Gradio interface:
cd /home/bingjie/workspace/EyeAgent-mcp/eyeagent
uv run python run_multiagent.py
The Gradio interface will be available at http://localhost:7860.
How it Works
🔄 Agent Workflow with Loguru Logging
-
System Initialization:
2024-01-15 10:30:15.123 | INFO | __main__:main:45 - 🚀 [SYSTEM] Starting multi-agent process for query: "Calculate 2 + 3" 2024-01-15 10:30:15.124 | INFO | __main__:main:46 - 📋 [SYSTEM] Total MCP tools available: 8 -
Coordinator Analysis:
2024-01-15 10:30:15.125 | INFO | __main__:coordinator_agent:78 - 🤖 [COORDINATOR] Starting coordination process... 2024-01-15 10:30:15.126 | INFO | __main__:coordinator_agent:80 - 📋 [COORDINATOR] Available MCP tools: calculate, multiply, sum_numbers, get_weather, ... 2024-01-15 10:30:15.127 | INFO | __main__:coordinator_agent:82 - 💭 [COORDINATOR] Analyzing user query: Calculate 2 + 3 2024-01-15 10:30:15.128 | INFO | __main__:coordinator_agent:85 - 🎯 [COORDINATOR] Selected agent: researcher -
Specialized Agent Execution:
2024-01-15 10:30:15.129 | INFO | __main__:researcher_agent:112 - 🔍 [RESEARCHER] Starting research process... 2024-01-15 10:30:15.130 | INFO | __main__:researcher_agent:114 - 🛠️ [RESEARCHER] Available tools for researcher: calculate, multiply, sum_numbers, get_weather 2024-01-15 10:30:15.131 | INFO | __main__:researcher_agent:116 - 💭 [RESEARCHER] Analyzing query for research: Calculate 2 + 3 2024-01-15 10:30:15.132 | INFO | __main__:researcher_agent:120 - 📝 [RESEARCHER] Researcher LLM response: {"tool_name": "calculate", "arguments": {"expression": "2 + 3"}} 2024-01-15 10:30:15.133 | INFO | __main__:researcher_agent:125 - 🔧 [RESEARCHER] Calling tool: calculate with args: {'expression': '2 + 3'} 2024-01-15 10:30:15.134 | SUCCESS | __main__:researcher_agent:130 - ✅ [RESEARCHER] Tool result: 5 2024-01-15 10:30:15.135 | INFO | __main__:researcher_agent:132 - 📤 [RESEARCHER] Final response: Research result: 5 -
System Completion:
2024-01-15 10:30:15.136 | SUCCESS | __main__:main:52 - 🎉 [SYSTEM] Process completed. Final response: Research result: 5...
Architecture
CI/CD
PyPI 发布使用标签策略:
eyeagent-vX.Y.Z- 推送前更新
pyproject.toml中版本。
文档 (GitHub Pages) 构建:
- 主分支推送自动构建
mkdocs.eyeagent.yml&mkdocs.eyetools.yml。 - 访问:https://beiyuouo.github.io/EyeAgent-mcp/eyeagent/ 与
/eyetools/。
所需仓库 Secrets:
PYPI_TOKEN_EYEAGENTPYPI_TOKEN_EYETOOLS
The system uses LangGraph to create an asynchronous state graph with the following nodes:
- Coordinator: Routes tasks to appropriate agents and provides tool context
- Researcher: Handles information gathering using role-specific MCP tools
- Writer: Handles content creation using role-specific MCP tools
- Analyst: Handles data analysis using role-specific MCP tools
Each agent is powered by GPT-4o-mini through LangChain and can dynamically discover and use MCP tools based on their assigned role.
MCP Server Requirements
The framework expects the MCP server to provide tools that agents can use. Example tools might include:
- Math calculation tools (
calculate,multiply,sum_numbers) - Data processing tools (
get_weather) - Image processing tools (
classify_image,segment_image,detect_objects,generate_image)
Make sure your MCP server is running and accessible before starting the multi-agent framework.
Loguru Logging Benefits
The framework uses loguru for professional-grade logging with the following advantages:
- Structured Logging: Each log entry includes timestamp, log level, module, function, and line number
- Color Coding: Different log levels have distinct colors for easy identification
- Emoji Integration: Agent-specific emojis help track which agent is performing actions
- Configurable Levels: DEBUG, INFO, WARNING, ERROR, SUCCESS levels available
- Performance: Minimal performance impact compared to print statements
- Thread Safety: Safe for concurrent agent execution
- Easy Filtering: Can filter logs by agent type or log level
Log Analysis
The structured logs help you understand:
- Agent decision-making process with precise timestamps
- Tool selection logic with detailed context
- MCP tool execution results with success/failure status
- Error handling and debugging with stack traces
- Performance monitoring with execution timing
- Concurrent execution tracking in multi-agent scenarios
Check the console output when running queries to see the complete agent interaction flow with professional loguru formatting!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file eyeagent-0.1.0.tar.gz.
File metadata
- Download URL: eyeagent-0.1.0.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0a6c42dcbac99e91150919ebe7dd5d393e98f74cf7db305dd5188ade3c83e4e7
|
|
| MD5 |
766da8de0b2899f01ec4c661c1a0f388
|
|
| BLAKE2b-256 |
2a9c0bef382f2fbd06c89881eabffa2ca9c608566325cbd1136f8d3d22cb8f85
|
File details
Details for the file eyeagent-0.1.0-py3-none-any.whl.
File metadata
- Download URL: eyeagent-0.1.0-py3-none-any.whl
- Upload date:
- Size: 4.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b89bec89dc8483c687d51edfe0005d9baf0f1e66cb135128659964a7020428b8
|
|
| MD5 |
0b800674beb84084d77f456dffd19117
|
|
| BLAKE2b-256 |
6431e037262eb91d3831fafa17ce7af10fba7d36d81b6f97dbc3bdb4326f687a
|