{"id":29403568,"url":"https://github.com/lazauk/hackster-aiagenticprotocols--mcp-a2a-acp","last_synced_at":"2026-04-09T07:03:06.093Z","repository":{"id":303428060,"uuid":"1010799473","full_name":"LazaUK/Hackster-AIAgenticProtocols--MCP-A2A-ACP","owner":"LazaUK","description":"Hackster Learning Series about AI Agentic protocols (MCP, A2A, ACP) with practical code examples.","archived":false,"fork":false,"pushed_at":"2025-07-07T14:50:12.000Z","size":46,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-07T15:50:00.477Z","etag":null,"topics":["a2a","acp","agents","ai","azure","hackster","mcp","openai","protocols"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/LazaUK.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-06-29T20:31:12.000Z","updated_at":"2025-07-07T14:50:15.000Z","dependencies_parsed_at":"2025-07-07T15:50:04.358Z","dependency_job_id":"ee922c95-5319-494a-b9af-2dacc85c8252","html_url":"https://github.com/LazaUK/Hackster-AIAgenticProtocols--MCP-A2A-ACP","commit_stats":null,"previous_names":["lazauk/hackster-aiagenticprotocols--mcp-a2a-acp"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/LazaUK/Hackster-AIAgenticProtocols--MCP-A2A-ACP","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LazaUK%2FHackster-AIAgenticProtocols--MCP-A2A-ACP","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LazaUK%2FHackster-AIAgenticProtocols--MCP-A2A-ACP/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LazaUK%2FHackster-AIAgenticProtocols--MCP-A2A-ACP/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LazaUK%2FHackster-AIAgenticProtocols--MCP-A2A-ACP/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/LazaUK","download_url":"https://codeload.github.com/LazaUK/Hackster-AIAgenticProtocols--MCP-A2A-ACP/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/LazaUK%2FHackster-AIAgenticProtocols--MCP-A2A-ACP/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264637858,"owners_count":23642062,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["a2a","acp","agents","ai","azure","hackster","mcp","openai","protocols"],"created_at":"2025-07-10T19:00:43.855Z","updated_at":"2025-12-30T22:12:40.010Z","avatar_url":"https://github.com/LazaUK.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Hackster Learning Series: AI Agentic Protocols\n\nThis GitHub repo complements The Learning Series articles on [Hackster.io](https://www.hackster.io/) about **AI Agentic Protocols**. It covers:\n- the **Model Context Protocol (MCP)** for dynamic tool and data access,\n- the **Agent2Agent Protocol (A2A)** for direct agent collaboration,\n- and the **Agent Communication Protocol (ACP)** for robust, interoperable communication.\n\nThe repo includes Python code to jump-start practical implementation of these protocols, offering immediate application opportunities.\n\n## 📑 Table of contents:\n- [Environment Setup](#environment-setup)\n- [Part 1: Model Context Protocol (MCP)](#part-1-model-context-protocol-mcp)\n- [Part 2: Agent2Agent Protocol (A2A)](#part-2-agent2agent-protocol-a2a)\n- [Part 3: Agent Communication Protocol (ACP)](#part-3-agent-communication-protocol-acp)\n- [Demo videos on YouTube](#demo-videos-on-youtube)\n\n## Environment Setup\n1. Install the required Python packages, listed in the provided *requirements.txt*:\n``` PowerShell\npip install -r requirements.txt\n```\n2. If using Azure OpenAI as your AI backend, set the following environment variables:\n\n| Variable                | Description                                      |\n| ----------------------- | ------------------------------------------------ |\n| `AOAI_API_BASE`         | Base URL of the Azure OpenAI endpoint            |\n| `AOAI_API_VERSION`      | API version of the Azure OpenAI endpoint         |\n| `AOAI_DEPLOYMENT`       | Deployment name of the Azure OpenAI model        |\n\n## Part 1: Model Context Protocol (MCP)\nThis section demonstrates how an AI agent can dynamically discover and use external tools. The implementation uses an **MCP Server** (`MCPServer_HomeAutomation.py`) to expose home automation functionalities (tools) and an **MCP Client** (`MCPClient_GradioUI.py`) as a Gradio UI for user interaction.\n\n1.  **Defining MCP Tools and Resources (MCP Server):** functions decorated with `@mcp.tool()` or `@mcp.resource()` in the `MCPServer_HomeAutomation.py` file define callable actions (Tools) or retrievable data (Resources) for the AI.\n\n    ``` Python\n    from mcp.server.fastmcp import FastMCP\n    mcp = FastMCP(\"Home Automation\")\n\n    @mcp.tool()\n    def control_light(action: str) -\u003e str: # Generalized snippet\n        # ...\n        return \"Light controlled.\"\n\n    @mcp.resource(\"home://device_status\")\n    def get_device_status() -\u003e str: # Generalized snippet\n        # ...\n        return \"{}\"\n\n    if __name__ == \"__main__\":\n        mcp.run() # Starts the MCP server\n    ```\n\n2.  **Establishing MCP Server Connection (MCP Client):** the `MCPClient_GradioUI.py` starts the server as a subprocess and connects using `MCPServerStdio` to enable tool discovery.\n\n    ``` Python\n    import subprocess\n    from agents.mcp import MCPServerStdio\n    \n    server_process = subprocess.Popen([...]) # Start server\n\n    mcp_server = MCPServerStdio(...)\n    await mcp_server.__aenter__() # Initialize connection\n    ```\n\n3.  **Initialising AI Agent with MCP Servers (MCP Client):**\n    An `Agent` is initialised with the connected `mcp_servers`. The agent's instructions are dynamically updated based on MCP tool availability.\n\n    ``` Python\n    from agents import Agent, OpenAIChatCompletionsModel\n    \n    agent = Agent(\n        name=\"Home Assistant\",\n        instructions=\"Use tools...\",\n        model=OpenAIChatCompletionsModel(...),\n        mcp_servers=[mcp_server], # Link MCP server\n    )\n    ```\n\n4.  **Processing User Input and Running Agent (MCP Client):** when a user inputs a query, `Runner.run()` is invoked. The AI model, aware of the MCP tools, decides whether to call a relevant tool or access a resource via the MCP layer to fulfill the request.\n\n    ```Python\n    from agents import Runner\n    \n    async def process_user_input(user_input, agent):\n        result = await Runner.run(starting_agent=agent, input=user_input)\n        return result.final_output\n    ```\n\n\u003e [!NOTE]\n\u003e Hackster article about MCP can be found [here](https://www.hackster.io/news/ai-agentic-protocols-part-1-model-context-protocol-mcp-f9c7d198fe4c).\n\n## Part 2: Agent2Agent Protocol (A2A)\n\n\u003e [!Caution]\n\u003e Work in progress. To be updated soon!\n\n## Part 3: Agent Communication Protocol (ACP)\n\n\u003e [!Caution]\n\u003e Work in progress. To be updated soon!\n\n## Demo videos on YouTube\n\n- [AI Agentic protocols: Part 1 - MCP (Home Automation UI demo)](https://youtu.be/HG9CIeBkco4)\n- [Home Automation with MCP: Behind the Code](https://youtu.be/EtJR4DkAXgs)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flazauk%2Fhackster-aiagenticprotocols--mcp-a2a-acp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flazauk%2Fhackster-aiagenticprotocols--mcp-a2a-acp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flazauk%2Fhackster-aiagenticprotocols--mcp-a2a-acp/lists"}