Mohammed2311/Azure_Cost_Estimation_Agent
0
1---2title: Azure Cost Estimation Agent3emoji: ๐ข4colorFrom: gray5colorTo: pink6sdk: gradio7sdk_version: 6.0.18app_file: azure_cost_agent.py9pinned: false10license: mit11short_description: Azure Cost Estimation Agent powered by (MCP)12---13 14Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference15-----16 17# โ๏ธ Azure Cost Estimation Agent18 19> **Submission for the MCP 1st Birthday Hackathon**20 21A production-ready agentic system that transforms natural language architecture descriptions into accurate, real-time Azure cost estimates. By leveraging the **Model Context Protocol (MCP)**, this agent connects a Gemini reasoning engine directly to a local Azure Pricing tool server, replacing manual spreadsheet work with intelligent conversation.22 23-----24 25## ๐ก The Problem & Solution26 27**The Problem:** Turning an architectural idea (e.g., *"I need a mobile backend for 10k users"*) into a cost estimate is tedious. It requires hunting through pricing pages, finding specific SKUs, and manually calculating monthly rates.28 29**The Solution:** An **Agentic Workflow**:30 311. **Reasoning:** The agent interprets your description and infers necessary resources (App Service, Cosmos DB, Bandwidth, etc.).322. **Tool Use (MCP):** It autonomously calls a local MCP server (`azure_pricing_mcp_server.py`) to fetch **real-time** retail prices and discover SKUs.333. **Visualization:** It aggregates the data into a clean report with interactive Plotly charts.34 35-----36 37## โจ Features38 39 * **Natural Language Input:** Just describe your infrastructure requirements.40 * **Real-Time Pricing:** No hardcoded values. The agent queries the Azure Retail Prices API via MCP.41 * **ReAct Pattern:** Uses a "Thought โ Action โ Observation" loop to refine its search and calculations.42 * **Interactive UI:** Built with **Gradio** for a chat-like experience.43 * **Visualizations:** Generates Pie and Bar charts using **Plotly** to visualize cost distribution.44 * **Transparent Logic:** Displays the full "Agent Analysis Trace" so you can see exactly what tools were called.45 46-----47 48## ๐๏ธ Architecture49 50The system consists of two main components communicating via the Model Context Protocol over `stdio`:51 521. **Client (`session.py`):** The Gradio frontend and Gemini Agent. It sends prompts and tool requests.532. **Server (`azure_pricing_mcp_server.py`):** A standalone script that implements MCP tools (`azure_price_search`, `azure_cost_estimate`) to fetch data from Azure.54 55<!-- end list -->56 57```mermaid58graph LR59 User[User] -->|Input| UI[Gradio Interface]60 UI -->|Prompt| Gemini[Gemini 2.5 Flash Lite]61 62 subgraph "MCP Connection (Stdio)"63 Gemini <-->|ReAct Loop| AgentLogic64 AgentLogic <-->|JSON-RPC| MCPServer[Azure Pricing MCP Server]65 end66 67 MCPServer <-->|HTTP GET| AzureAPI[Azure Retail Prices API]68```69 70-----71 72## ๐ ๏ธ Installation73 74### Prerequisites75 76 * Python 3.10 or higher77 * A Google Gemini API Key ([Get one here](https://aistudio.google.com/))78 79### 1\. Clone the Repository80 81```bash82git clone https://github.com/your-username/azure-cost-agent.git83cd azure-cost-agent84```85 86### 2\. Set up Virtual Environment87 88```bash89python -m venv venv90# Windows91.\venv\Scripts\activate92# Mac/Linux93source venv/bin/activate94```95 96### 3\. Install Dependencies97 98Create a `requirements.txt` file (or run the command below):99 100```bash101pip install mcp google-generativeai gradio plotly python-dotenv requests102```103 104### 4\. Configure Environment105 106Create a `.env` file in the root directory and add your key:107 108```env109GEMINI_API_KEY=your_actual_gemini_api_key_here110```111 112### 5\. Verify Files113 114Ensure both Python scripts are in the same folder:115 116 * `session.py` (The main application)117 * `azure_pricing_mcp_server.py` (The MCP server script)118 119-----120 121## ๐ Usage122 123Run the main session file. The MCP server will be started automatically as a subprocess.124 125```bash126python session.py127```128 129Once running, click the local URL provided (usually `http://127.0.0.1:7860`).130 131### Example Prompts to Try132 133 * *"I need a mobile app backend with REST APIs, authentication, and MongoDB. Expected 10,000 active users in Europe."*134 * *"Deploy a data analytics platform: batch processing 8h/day, 2TB data warehouse, ML training twice weekly."*135 * *"Simple WordPress site on a VM with a MySQL database in East US."*136 137-----138 139## ๐งฉ Technical Details140 141### The Tools142 143The agent has access to the following MCP tools:144 145 * `azure_discover_skus`: Finds available SKUs for a specific service and region.146 * `azure_price_search`: Searches for specific pricing meters.147 * `azure_cost_estimate`: Calculates monthly costs based on usage patterns (hours/day, quantity).148 * `azure_price_compare`: Compares costs across different Azure regions.149 150### Technologies Used151 152 * **Model Context Protocol (MCP):** For standardized tool definitions and client-server communication.153 * **Google Gemini 2.5 Flash Lite:** For fast, accurate reasoning and JSON parsing.154 * **Gradio:** For the web interface.155 * **Plotly:** For dynamic data visualization.156 157-----158 159## ๐ค Contributing160 161Contributions are welcome\! Please fork the repository and submit a pull request.162 163## ๐ License164 165Distributed under the MIT License. See `LICENSE` for more information.166 