From 4b88aecd0d7ac85e279c8b423fd622f35c9867e5 Mon Sep 17 00:00:00 2001 From: Roy Date: Thu, 10 Apr 2025 21:39:07 +0300 Subject: [PATCH] Add simulation project: manual vs MCP vs A2A setup --- .../a2a_simulation.py | 21 ++ MCP-MANUAL-A2A-nginx-install/gitignore | 45 ++++ MCP-MANUAL-A2A-nginx-install/install_nginx.sh | 17 ++ MCP-MANUAL-A2A-nginx-install/mcp_config.json | 28 ++ .../mcp_nginx_install.py | 20 ++ MCP-MANUAL-A2A-nginx-install/nginx_install.py | 21 ++ README.md | 249 +++++++++--------- requirements.txt | 1 + 8 files changed, 273 insertions(+), 129 deletions(-) create mode 100644 MCP-MANUAL-A2A-nginx-install/a2a_simulation.py create mode 100644 MCP-MANUAL-A2A-nginx-install/gitignore create mode 100644 MCP-MANUAL-A2A-nginx-install/install_nginx.sh create mode 100644 MCP-MANUAL-A2A-nginx-install/mcp_config.json create mode 100644 MCP-MANUAL-A2A-nginx-install/mcp_nginx_install.py create mode 100644 MCP-MANUAL-A2A-nginx-install/nginx_install.py create mode 100644 requirements.txt diff --git a/MCP-MANUAL-A2A-nginx-install/a2a_simulation.py b/MCP-MANUAL-A2A-nginx-install/a2a_simulation.py new file mode 100644 index 0000000..e7bd9a6 --- /dev/null +++ b/MCP-MANUAL-A2A-nginx-install/a2a_simulation.py @@ -0,0 +1,21 @@ +# a2a_simulation.py + +class Agent: + def __init__(self, name, tools): + self.name = name + self.tools = tools + + def describe_capabilities(self): + print(f"{self.name} can work with: {', '.join(self.tools)}") + + def collaborate(self, other_agent): + print(f"{self.name} is collaborating with {other_agent.name}...") + combined = set(self.tools).union(other_agent.tools) + print(f"Together, they cover: {', '.join(combined)}") + +if __name__ == "__main__": + devops_agent = Agent("DevOps Agent", ["Docker", "Kubernetes", "CI/CD", "Terraform"]) + monitoring_agent = Agent("Monitoring Agent", ["Datadog", "Prometheus", "Grafana"]) + devops_agent.describe_capabilities() + monitoring_agent.describe_capabilities() + devops_agent.collaborate(monitoring_agent) diff --git a/MCP-MANUAL-A2A-nginx-install/gitignore b/MCP-MANUAL-A2A-nginx-install/gitignore new file mode 100644 index 0000000..9423ad2 --- /dev/null +++ b/MCP-MANUAL-A2A-nginx-install/gitignore @@ -0,0 +1,45 @@ + +# Byte-compiled / optimized / DLL files +__pycache__/ +*.py[cod] +*$py.class + +# VSCode settings +.vscode/ + +# Environment variables +.env +*.env + +# Logs +*.log + +# Virtual environment +venv/ +env/ +ENV/ + +# Mac system files +.DS_Store + +# Jupyter Notebook checkpoints +.ipynb_checkpoints/ + +# PyInstaller output +dist/ +build/ +*.spec + +# Coverage reports +htmlcov/ +.coverage +coverage.xml +*.cover + +# MyPy +.mypy_cache/ +.dmypy.json +dmypy.json + +# Pytest +.pytest_cache/ diff --git a/MCP-MANUAL-A2A-nginx-install/install_nginx.sh b/MCP-MANUAL-A2A-nginx-install/install_nginx.sh new file mode 100644 index 0000000..d3aca87 --- /dev/null +++ b/MCP-MANUAL-A2A-nginx-install/install_nginx.sh @@ -0,0 +1,17 @@ +#!/bin/bash + +# Just simulating Nginx installation (no real installation happening) + +echo "Simulating Nginx installation..." + +# Print simulated installation steps +echo "Step 1: Downloading Nginx..." +sleep 1 +echo "Step 2: Unpacking the Nginx package..." +sleep 1 +echo "Step 3: Setting up Nginx configuration..." +sleep 1 +echo "Step 4: Starting Nginx server..." +sleep 1 + +echo "Nginx installation simulation complete!" # small fix to trigger Git diff --git a/MCP-MANUAL-A2A-nginx-install/mcp_config.json b/MCP-MANUAL-A2A-nginx-install/mcp_config.json new file mode 100644 index 0000000..6c03abe --- /dev/null +++ b/MCP-MANUAL-A2A-nginx-install/mcp_config.json @@ -0,0 +1,28 @@ +{ + "mcp": { + "inputs": [ + { + "type": "promptString", + "id": "github_token", + "description": "GitHub Personal Access Token", + "password": true + } + ], + "servers": { + "github": { + "command": "docker", + "args": [ + "run", + "-i", + "--rm", + "-e", + "GITHUB_PERSONAL_ACCESS_TOKEN", + "ghcr.io/github/github-mcp-server" + ], + "env": { + "GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}" + } + } + } + } + } \ No newline at end of file diff --git a/MCP-MANUAL-A2A-nginx-install/mcp_nginx_install.py b/MCP-MANUAL-A2A-nginx-install/mcp_nginx_install.py new file mode 100644 index 0000000..1ee0e2f --- /dev/null +++ b/MCP-MANUAL-A2A-nginx-install/mcp_nginx_install.py @@ -0,0 +1,20 @@ +import mcp # The MCP module should be installed and ready to use + +def install_nginx_with_mcp(): + # Connect to the system using MCP + mcp.connect_to_system("nginx_system") # The name of the system you're connecting to + + # Install Nginx using MCP's automatic installation process + mcp.install_package("nginx") # Automatically install nginx + + # Start the Nginx service + mcp.start_service("nginx") # Start the nginx service + + # Enable the Nginx service to start on boot + mcp.enable_service("nginx") # Enable the service to run on system startup + +if __name__ == "__main__": + install_nginx_with_mcp() + # This script will install Nginx on the specified system using MCP's automation features. + + \ No newline at end of file diff --git a/MCP-MANUAL-A2A-nginx-install/nginx_install.py b/MCP-MANUAL-A2A-nginx-install/nginx_install.py new file mode 100644 index 0000000..887a9c9 --- /dev/null +++ b/MCP-MANUAL-A2A-nginx-install/nginx_install.py @@ -0,0 +1,21 @@ +import subprocess + +def simulate_nginx_installation(): + # Simulate system update + print("Simulating system update...") + subprocess.run(["apt", "update"], check=True) + + # Simulate Nginx installation + print("Simulating Nginx installation...") + subprocess.run(["apt", "install", "-y", "nginx"], check=True) + + # Simulate starting the Nginx service + print("Simulating starting Nginx...") + subprocess.run(["systemctl", "start", "nginx"], check=True) + + # Simulate enabling Nginx to start on boot + print("Simulating enabling Nginx to start on boot...") + subprocess.run(["systemctl", "enable", "nginx"], check=True) + +if __name__ == "__main__": + simulate_nginx_installation() \ No newline at end of file diff --git a/README.md b/README.md index 9fe28d4..18b7dac 100644 --- a/README.md +++ b/README.md @@ -1,158 +1,149 @@ - -# DevOps-Zero2Hero +# MCP vs Manual vs A2A Nginx Installation -- The aim of this project is to collect as many resources as possible that users can use to DevOps. -- The project will contain DevOps Learning labs. +## Introduction +This project simulates three different approaches to setting up a server (e.g., Nginx): ---- +1. A traditional manual installation (simulated, not an actual system setup). +2. An automated installation using Anthropic's MCP (Model Context Protocol), which is actually connected and working in this project (connection steps are explained later in the file). +3. A simulated collaborative agent setup using Google's A2A (Agent2Agent Protocol). -
- DevOps-Zero2Hero -
+The goal is to demonstrate how DevOps engineers in the near future could leverage both MCP and especially A2A to simplify their workflows, reduce time and effort, improve efficiency, and automate complex infrastructure tasks across tools and environments. --- - -## Table of Contents - -- [Detailed instructions how to contribute](#detailed-instructions-how-to-contribute) - - [Getting Started](#getting-started) - - [Fork the Repository](#fork-the-repository) - - [Making Changes](#making-changes) - - [Generating ssh key](#generating-ssh-key) - - [Setting up upstream](#setting-up-upstream) - - [Stay Updated](#stay-updated) - - [Commit changes](#commit-changes) -- [Contributing notes](#contributing-notes) -- [Contributing Quality](#contributing-quality) - - [Run GithubAction locally](#run-githubaction-locally) -- [Recommended extensions for improved contribution](#recommended-extensions-for-improved-contribution) +## What is MCP? +Model Context Protocol (MCP) by Anthropic is an open protocol that standardizes how AI applications can connect to tools and data sources. It lets large language models understand available tools, access them securely, and decide how to use them without being hardcoded for each case. MCP simplifies complex operations into high-level intents. + +## What is A2A? +A2A (Agent2Agent Protocol) is a new open protocol introduced by Google just days ago. It enables AI agents to discover each other, communicate, and collaborate across different systems—even if the agents were built by different vendors. A2A empowers developers to build ecosystems of agents that can coordinate tasks together, creating smart, dynamic workflows. --- -### How to contribute to this project? +## Real-Life Example of What MCP Is: +Think of it as a kitchen tool that connects all your equipment. Instead of pulling out different devices and connecting them every time you need to cook, you have one system that connects everything and simplifies the work for you. The MCP agent works in a similar way—it connects data sources, making tasks like setting up servers faster and easier, without having to manually integrate each one separately. + +## Real-Life Example of What A2A Is: +**Personal example: Automating daily errands through agents** + +Imagine you have a few personal AI agents: +- An Email Agent +- A Shopping Agent +- A Calendar Agent + +### Without A2A: +Each agent works alone. You must manually send emails, book appointments, and shop. -- **Contribute** to the project. - - Make changes locally on your local machine (clone). - - Create a new branch with meaningful name (git checkout -b your-branch-name) - - **Add & Commit** the changes. (git add . && git commit -m "Describe your changes") - - **Push** the changes to your forked repository. (git push origin your-branch-name) - - Create a **pull request** to the main repository main branch. - - When the PR is merged you will automatically added to the list of contributors. - - Follow the instructions in the pull request to merge your changes. - - Wait for the project maintainers to review and merge your pull request. +### With A2A: +You say: “I need to buy new headphones by tomorrow, and I’m only free between 5–6pm.” +- The Email Agent checks your inbox. +- The Calendar Agent verifies your availability. +- The Shopping Agent finds matching deals. +- They coordinate with each other and complete the task. You get an update with the delivery info and a calendar entry. --- -## Detailed instructions how to contribute - -### Getting Started - -#### Fork the Repository - -- Start by forking the repository to your own GitHub account: -- Click the "Fork" button in the upper right corner -- Clone your fork locally: - ```bash - # Clone the repository - $ git clone https://github.com/YOUR-USERNAME/DevOps-Zero2Hero.git - - # Navigate into the project directory - $ cd DevOps-Zero2Hero-NAME - ``` - -#### Making Changes - -##### Generating ssh key - - - Make sure you have a setup an SSH key for GitHub. - - If you don't have one, follow these steps to generate and add your SSH key to GitHub. - - Generate an SSH key: - ```bash - # Generate rsa key - ssh-keygen -t rsa - - # Follow the prompt to save the key to a file (e.g., `~/.ssh/id_rsa`) - # You can also specify a different file name by using `-f` option, e.g: - # ssh-keygen -t rsa -f ~/.ssh/mykey - ``` - - This will create a new file named `id_rsa` and `id_rsa.pub` in your home directory unless you gave it a different name - - Copy the contents of `id_rsa.pub` and paste it under "SSH key" field in your GitHub account settings. - -##### Setting up upstream - -- Add the original repository as an upstream remote: - ```bash - # Add the original repository as an upstream remote - git remote add upstream git@github.com:nirgeier/DevOps-Zero2Hero.git - ``` - -##### Stay Updated - -- Keep your fork in sync with the upstream repository: - ```bash - # Keep your fork in sync with the upstream repository - git fetch --all - - # Merge upstream changes into your branch - git merge upstream/main - ``` - -##### Commit changes - - ```sh - # Create branch for your changes. - $ git checkout -b - - # Make changes locally on your local machine (clone). - # Add the changes to your staging area - $ git add . - - # Commit the changes - $ git commit -m "Describe your changes here" - - # Push the changes to your forked repository. - $ git push origin - ``` - -- Create a pull request to the main repository. +## Prerequisites +Before you begin, make sure you have the following: + +1. Python 3.x installed +2. Docker installed (for running MCP agent) +3. Visual Studio Code (VSCode) installed +4. Copilot Plugin installed in VSCode (this is used to interact with the MCP agent) + +## Step-by-Step Instructions + +### Step 2: Automating the Installation with MCP Agent +1. Install the Copilot Plugin in VSCode. +2. Open the JSON file in VSCode. Click "Start" to open the Copilot chat window. +3. Set Mode to "Agent" in the Copilot window. + +**Note:** To use the MCP configuration, you will need a GitHub Personal Access Token. Go to your GitHub account → Settings → Developer settings → Personal access tokens, and generate a token with the appropriate permissions. Once generated, paste the token where prompted in the Copilot input field for `github_token`. + +**Use the Following JSON Code** +```json +{ + "mcp": { + "inputs": [ + { + "type": "promptString", + "id": "github_token", + "description": "GitHub Personal Access Token", + "password": true + } + ], + "servers": { + "github": { + "command": "docker", + "args": [ + "run", + "-i", + "--rm", + "-e", + "GITHUB_PERSONAL_ACCESS_TOKEN", + "ghcr.io/github/github-mcp-server" + ], + "env": { + "GITHUB_PERSONAL_ACCESS_TOKEN": "${input:github_token}" + } + } + } + } +} +``` --- -## Contributing notes +## A2A Protocol Overview +**A2A is Google's open protocol that enables agents to communicate, exchange information, and collaborate on complex tasks—even across vendors.** -1. All folders should be named in lowercase with no spaces. -2. Content should be written in markdown and file name should be `.md` -3. Content should b based upon the Default template with the required placeholders and include TOC -4. GitHub action is collecting all the files and generate auto-content README file with the different topics. -5. Images should be in the resources/images folder -6. If you add new technology you have to edit the main README as well and add the logo + add the technology to the list +### ✅ Advantages +- Agents collaborate with each other +- Enables complex multi-agent workflows +- Can work with different tools simultaneously +- Real-time scaling, monitoring, and customization -## Contributing Quality +### ⚠️ Disadvantages +- Requires advanced initial setup +- Still a very new (evolving) interface -### Run GithubAction locally +--- -1. Install `act` from the official website to run GithubAction locally - Click CTRL to open in hew tab: https://nektosact.com/installation/index.html -2. Execute the following command in your terminal: - ```sh - # Execute the Github Actions locally - act --workflows \ - ".github/workflows/add-contrib.yml" --job "add-contributor" -- TODO: Add detailed page on how to run and text GitHub actions locally -- Verify that your code is passing all the pre-merge checks +## 🧪 Real-World DevOps A2A Example: Deployment & Cloud Maintenance +Imagine you're a DevOps engineer managing apps across AWS, GCP, and internal systems. +- One agent manages Terraform infrastructure. +- Another triggers CI/CD with Jenkins. +- A third monitors performance with Prometheus. +- A fourth sends updates via Slack. -## Recommended extensions for improved contribution +### Without A2A: +You manually integrate each step, deal with mismatches, and handle every connection manually. -- [Markdown All in One](https://marketplace.visualstudio.com/items?itemName=yzhang.markdown-all-in-one) -- [GitHub Actions](https://marketplace.visualstudio.com/items?itemName=GitHub.vscode-github-actions) +### With A2A: +- Jenkins Agent runs a build. +- Sends a "task" to the Terraform Agent to deploy. +- If an error occurs, Monitoring Agent alerts the Slack Agent. ---- +Now all agents communicate and sync—even if built with different tools. -- Use the [discussions](https://github.com/nirgeier/DevOps-Zero2Hero/discussions) tab to discuss the project. +### 🎯 Benefits: +**For you:** Smart automation of your digital tasks. +**For DevOps:** Modular agent-based systems that talk to each other without extra integrations. +More efficiency, less time wasted, scalable and transparent infrastructure. --- -Thank it. AS simple as that! +## 📁 Project Structure +``` +MCP-MANUAL-A2A-nginx-install/ +├── install_nginx.sh +├── mcp_config.json +├── mcp_nginx_install.py +├── nginx_install.py +├── a2a_simulation.py +├── requirements.txt +└── README.md +``` + +--- diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..f229360 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +requests