diff --git a/.copilot-instructions.md b/.copilot-instructions.md index b0934f2..d2d0979 100644 --- a/.copilot-instructions.md +++ b/.copilot-instructions.md @@ -64,15 +64,30 @@ This project implements a hierarchical MCP (Model Context Protocol) server syste ### Code Structure ``` -src/ -├── mcp_server/ # Main MCP server implementation -├── agents/ # AutoGen agent implementations -│ ├── moderator.py # Moderator agent -│ ├── base_agent.py # Base class for specialized agents -│ └── specialized/ # Specialized agent implementations -├── config/ # Configuration management -├── utils/ # Utility functions -└── main.py # Entry point +├── src/ # Source code +│ ├── mcp_server/ # Main MCP server implementation +│ ├── agents/ # AutoGen agent implementations +│ │ ├── moderator.py # Moderator agent +│ │ ├── base_agent.py # Base class for specialized agents +│ │ └── specialized/ # Specialized agent implementations +│ ├── config/ # Configuration management +│ ├── utils/ # Utility functions +│ ├── web_ui/ # Web UI for configuration management +│ │ ├── api/ # REST API endpoints +│ │ ├── static/ # CSS, JS, images +│ │ └── templates/ # HTML templates +│ └── main.py # Entry point +├── config/ # Configuration files +│ ├── example-config.yml # Example configuration +│ └── config.yml # Actual configuration (not in git) +├── tests/ # Test files +│ ├── unit/ # Unit tests +│ └── integration/ # Integration tests +├── logs/ # Log files (not in git) +├── docs/ # Documentation +├── requirements.txt # Python dependencies +├── requirements-dev.txt # Development dependencies +└── .venv/ # Virtual environment ``` ### Configuration Format @@ -96,12 +111,15 @@ routing_rules: ``` ### Key Technologies -- **Python 3.12+** +- **Python 3.12+** (3.13+ preferred when available) - **AutoGen**: Multi-agent framework - **MCP SDK**: Model Context Protocol implementation +- **FastAPI**: Modern web framework for Web UI - **Pydantic**: Configuration validation - **PyYAML**: Configuration parsing - **AsyncIO**: Asynchronous operations +- **SQLAlchemy**: Database ORM (for configuration storage) +- **Uvicorn**: ASGI server ### Development Phases 1. **Phase 1**: Basic MCP server + single specialized agent diff --git a/config/example-config.yml b/config/example-config.yml new file mode 100644 index 0000000..6dc4b42 --- /dev/null +++ b/config/example-config.yml @@ -0,0 +1,143 @@ +# Beispiel-Konfiguration für Autogen-MCP-Server +# Kopiere diese Datei zu config.yml und passe sie an + +# Moderator Agent Konfiguration +moderator: + name: "AgentModerator" + model: "gpt-4" + system_message: | + Du bist ein intelligenter Moderator-Agent, der Anfragen an spezialisierte Agenten weiterleitet. + Analysiere die Anfrage und bestimme den besten Spezialisten für die Aufgabe. + Koordiniere die Kommunikation zwischen den Agenten und formatiere die finale Antwort. + + # Modell-spezifische Konfiguration + model_config: + temperature: 0.7 + max_tokens: 1000 + timeout: 30 + +# Spezialisierte Agenten +agents: + - name: "AzureDevOpsAgent" + specialization: "azure_devops" + description: "Spezialist für Azure DevOps, Build-Pipelines und Deployment" + model: "gpt-4" + system_message: | + Du bist ein Azure DevOps Spezialist. Du hilfst bei: + - Work Items und Backlogs + - Build und Release Pipelines + - Git Repositories und Pull Requests + - Deployment Strategien + + # MCP Server Verbindung + mcp_server: + url: "mcp://localhost:8001/azure-devops" + timeout: 60 + tools: + - "get_work_items" + - "create_pull_request" + - "get_build_status" + - "trigger_pipeline" + + model_config: + temperature: 0.3 + max_tokens: 1500 + + - name: "DatabaseAgent" + specialization: "database" + description: "Spezialist für Datenbank-Operationen und SQL" + model: "gpt-3.5-turbo" + system_message: | + Du bist ein Datenbank-Spezialist. Du hilfst bei: + - SQL Queries und Optimierung + - Datenbank Design und Schema + - Performance-Analyse + - Backup und Recovery + + mcp_server: + url: "mcp://localhost:8002/database" + timeout: 45 + tools: + - "query_database" + - "get_schema" + - "analyze_performance" + - "backup_database" + + model_config: + temperature: 0.2 + max_tokens: 1200 + +# Routing-Regeln für automatische Agent-Auswahl +routing_rules: + - keywords: ["azure", "devops", "pipeline", "build", "deployment", "pull request", "work item"] + agent: "AzureDevOpsAgent" + confidence: 0.8 + + - keywords: ["database", "sql", "query", "schema", "table", "performance", "backup"] + agent: "DatabaseAgent" + confidence: 0.8 + + - keywords: ["datenbank", "abfrage", "tabelle", "schema"] + agent: "DatabaseAgent" + confidence: 0.7 + +# Fallback-Strategien +fallback: + default_agent: "moderator" # Wenn kein spezieller Agent gefunden wird + timeout_seconds: 120 + retry_attempts: 3 + + # Wenn ein Agent nicht verfügbar ist + unavailable_strategy: "fallback_to_moderator" + + # Fehlerbehandlung + error_responses: + agent_timeout: "Entschuldigung, der angefragte Service ist momentan nicht verfügbar." + mcp_server_error: "Es gab einen Fehler beim Zugriff auf die Backend-Services." + general_error: "Ein unerwarteter Fehler ist aufgetreten. Bitte versuchen Sie es später erneut." + +# Logging-Konfiguration +logging: + level: "INFO" + format: "%(asctime)s - %(name)s - %(levelname)s - %(message)s" + file: "logs/autogen-mcp-server.log" + max_file_size: "10MB" + backup_count: 5 + + # Spezielle Logger + loggers: + agents: "DEBUG" + mcp_server: "INFO" + config: "WARNING" + +# Web UI Konfiguration (optional) +web_ui: + enabled: true + host: "localhost" + port: 8000 + debug: false + + # Sicherheit + secret_key: "your-secret-key-here" # Ändern Sie dies in Produktion! + + # Authentifizierung (optional) + auth: + enabled: false + username: "admin" + password: "password" # Ändern Sie dies in Produktion! + +# Performance-Einstellungen +performance: + # Maximale gleichzeitige Anfragen + max_concurrent_requests: 10 + + # Caching + cache: + enabled: true + ttl_seconds: 300 + max_size: 1000 + + # Connection Pooling für MCP Server + mcp_connection_pool: + max_connections: 5 + timeout: 30 diff --git a/logs/README.md b/logs/README.md new file mode 100644 index 0000000..b1727a1 --- /dev/null +++ b/logs/README.md @@ -0,0 +1,27 @@ +# Logs Directory + +This directory contains log files for the Autogen-MCP-Server. + +## Log Files + +- `autogen-mcp-server.log` - Main application log +- `agents.log` - Agent-specific logs +- `mcp-server.log` - MCP server communication logs +- `web-ui.log` - Web UI access and error logs + +## Log Rotation + +Log files are automatically rotated when they reach 10MB in size. +Up to 5 backup files are kept. + +## Log Levels + +- `DEBUG` - Detailed diagnostic information +- `INFO` - General information about system operation +- `WARNING` - Warning messages about potential issues +- `ERROR` - Error messages about failures +- `CRITICAL` - Critical error messages + +## Configuration + +Log configuration can be adjusted in `config/config.yml` under the `logging` section. diff --git a/requirements-dev.txt b/requirements-dev.txt new file mode 100644 index 0000000..16a1670 --- /dev/null +++ b/requirements-dev.txt @@ -0,0 +1,21 @@ +# Development Requirements - zusätzlich zu requirements.txt + +# Code Quality +pre-commit>=3.5.0 +bandit>=1.7.5 + +# Testing +pytest-xdist>=3.3.0 # Parallel testing +pytest-mock>=3.12.0 +httpx>=0.25.0 # For testing FastAPI endpoints + +# Development Tools +ipython>=8.16.0 +jupyter>=1.0.0 + +# Documentation +mkdocs-mermaid2-plugin>=1.1.0 + +# Type Checking +types-PyYAML>=6.0.0 +types-requests>=2.31.0 diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..24cad5b --- /dev/null +++ b/requirements.txt @@ -0,0 +1,47 @@ +# Requirements for Autogen-MCP-Server + +# Core MCP and AutoGen +mcp>=1.0.0 +autogen-agentchat>=0.2.0 + +# Configuration and Validation +pydantic>=2.5.0 +pydantic-settings>=2.1.0 +PyYAML>=6.0.1 + +# Async and Networking +aiohttp>=3.9.0 +asyncio-mqtt>=0.16.0 + +# Web UI Framework (FastAPI chosen for modern async support) +fastapi>=0.104.0 +uvicorn[standard]>=0.24.0 +jinja2>=3.1.0 + +# Database (for configuration storage if needed) +sqlalchemy>=2.0.0 +alembic>=1.12.0 + +# Logging and Monitoring +structlog>=23.2.0 +prometheus-client>=0.19.0 + +# Security +python-jose[cryptography]>=3.3.0 +passlib[bcrypt]>=1.7.4 + +# Development and Testing +pytest>=7.4.0 +pytest-asyncio>=0.21.0 +pytest-cov>=4.1.0 +black>=23.9.0 +ruff>=0.1.0 +mypy>=1.7.0 + +# Documentation +mkdocs>=1.5.0 +mkdocs-material>=9.4.0 + +# Optional: For advanced features +redis>=5.0.0 # For caching and session management +celery>=5.3.0 # For background tasks diff --git a/src/__init__.py b/src/__init__.py new file mode 100644 index 0000000..0455428 --- /dev/null +++ b/src/__init__.py @@ -0,0 +1,3 @@ +""" +Autogen-MCP-Server: A hierarchical MCP system with AutoGen multi-agent architecture. +""" diff --git a/src/agents/__init__.py b/src/agents/__init__.py new file mode 100644 index 0000000..9369317 --- /dev/null +++ b/src/agents/__init__.py @@ -0,0 +1,3 @@ +""" +AutoGen agents implementation - Moderator and specialized agents. +""" diff --git a/src/agents/specialized/__init__.py b/src/agents/specialized/__init__.py new file mode 100644 index 0000000..0a93a83 --- /dev/null +++ b/src/agents/specialized/__init__.py @@ -0,0 +1,3 @@ +""" +Specialized agents for different domains (Azure DevOps, Database, etc.). +""" diff --git a/src/config/__init__.py b/src/config/__init__.py new file mode 100644 index 0000000..b23dc83 --- /dev/null +++ b/src/config/__init__.py @@ -0,0 +1,3 @@ +""" +Configuration management - YAML/JSON parsing and validation. +""" diff --git a/src/mcp_server/__init__.py b/src/mcp_server/__init__.py new file mode 100644 index 0000000..f3ea6dd --- /dev/null +++ b/src/mcp_server/__init__.py @@ -0,0 +1,3 @@ +""" +MCP Server implementation - Entry point for MCP-capable clients. +""" diff --git a/src/utils/__init__.py b/src/utils/__init__.py new file mode 100644 index 0000000..c545b13 --- /dev/null +++ b/src/utils/__init__.py @@ -0,0 +1,3 @@ +""" +Utility functions - Logging, helpers, and shared functionality. +""" diff --git a/src/web_ui/__init__.py b/src/web_ui/__init__.py new file mode 100644 index 0000000..52b1b1f --- /dev/null +++ b/src/web_ui/__init__.py @@ -0,0 +1,3 @@ +""" +Web UI for configuration management - Flask/FastAPI based interface. +""" diff --git a/src/web_ui/api/__init__.py b/src/web_ui/api/__init__.py new file mode 100644 index 0000000..cae9bf3 --- /dev/null +++ b/src/web_ui/api/__init__.py @@ -0,0 +1,3 @@ +""" +Web UI API endpoints - REST API for configuration management. +""" diff --git a/src/web_ui/templates/index.html b/src/web_ui/templates/index.html new file mode 100644 index 0000000..e8d9d8f --- /dev/null +++ b/src/web_ui/templates/index.html @@ -0,0 +1,53 @@ + + + + + + Autogen-MCP-Server - Konfiguration + + + +
+

🚀 Autogen-MCP-Server Web UI

+
+

🔧 Konfiguration Interface

+

Die Web-basierte Konfigurationsoberfläche befindet sich in Entwicklung.

+

Features in Planung:

+ +
+
+ + diff --git a/tests/integration/__init__.py b/tests/integration/__init__.py new file mode 100644 index 0000000..88e1915 --- /dev/null +++ b/tests/integration/__init__.py @@ -0,0 +1,3 @@ +""" +Integration tests for component interactions. +""" diff --git a/tests/unit/__init__.py b/tests/unit/__init__.py new file mode 100644 index 0000000..94aeec0 --- /dev/null +++ b/tests/unit/__init__.py @@ -0,0 +1,3 @@ +""" +Unit tests for individual components. +"""