Mohammed2311/Azure_Cost_Estimation_Agent
Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference -----
☁️ Azure Cost Estimation Agent
Submission for the MCP 1st Birthday Hackathon
A 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.
💡 The Problem & Solution
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.
The Solution: An Agentic Workflow:
- Reasoning: The agent interprets your description and infers necessary resources (App Service, Cosmos DB, Bandwidth, etc.).
- Tool Use (MCP): It autonomously calls a local MCP server (
azure_pricing_mcp_server.py) to fetch real-time retail prices and discover SKUs. - Visualization: It aggregates the data into a clean report with interactive Plotly charts.
✨ Features
- Natural Language Input: Just describe your infrastructure requirements.
- Real-Time Pricing: No hardcoded values. The agent queries the Azure Retail Prices API via MCP.
- ReAct Pattern: Uses a "Thought → Action → Observation" loop to refine its search and calculations.
- Interactive UI: Built with Gradio for a chat-like experience.
- Visualizations: Generates Pie and Bar charts using Plotly to visualize cost distribution.
- Transparent Logic: Displays the full "Agent Analysis Trace" so you can see exactly what tools were called.
🏗️ Architecture
The system consists of two main components communicating via the Model Context Protocol over stdio:
- Client (`session.py`): The Gradio frontend and Gemini Agent. It sends prompts and tool requests.
- Server (`azure_pricing_mcp_server.py`): A standalone script that implements MCP tools (
azure_price_search,azure_cost_estimate) to fetch data from Azure.
<!-- end list -->
graph LR
User[User] -->|Input| UI[Gradio Interface]
UI -->|Prompt| Gemini[Gemini 2.5 Flash Lite]
subgraph "MCP Connection (Stdio)"
Gemini <-->|ReAct Loop| AgentLogic
AgentLogic <-->|JSON-RPC| MCPServer[Azure Pricing MCP Server]
end
MCPServer <-->|HTTP GET| AzureAPI[Azure Retail Prices API]🛠️ Installation
Prerequisites
- Python 3.10 or higher
- A Google Gemini API Key (Get one here)
1\. Clone the Repository
git clone https://github.com/your-username/azure-cost-agent.git
cd azure-cost-agent2\. Set up Virtual Environment
python -m venv venv
# Windows
.\venv\Scripts\activate
# Mac/Linux
source venv/bin/activate3\. Install Dependencies
Create a requirements.txt file (or run the command below):
pip install mcp google-generativeai gradio plotly python-dotenv requests4\. Configure Environment
Create a .env file in the root directory and add your key:
GEMINI_API_KEY=your_actual_gemini_api_key_here5\. Verify Files
Ensure both Python scripts are in the same folder:
session.py(The main application)azure_pricing_mcp_server.py(The MCP server script)
🚀 Usage
Run the main session file. The MCP server will be started automatically as a subprocess.
python session.pyOnce running, click the local URL provided (usually http://127.0.0.1:7860).
Example Prompts to Try
- "I need a mobile app backend with REST APIs, authentication, and MongoDB. Expected 10,000 active users in Europe."
- "Deploy a data analytics platform: batch processing 8h/day, 2TB data warehouse, ML training twice weekly."
- "Simple WordPress site on a VM with a MySQL database in East US."
🧩 Technical Details
The Tools
The agent has access to the following MCP tools:
azure_discover_skus: Finds available SKUs for a specific service and region.azure_price_search: Searches for specific pricing meters.azure_cost_estimate: Calculates monthly costs based on usage patterns (hours/day, quantity).azure_price_compare: Compares costs across different Azure regions.
Technologies Used
- Model Context Protocol (MCP): For standardized tool definitions and client-server communication.
- Google Gemini 2.5 Flash Lite: For fast, accurate reasoning and JSON parsing.
- Gradio: For the web interface.
- Plotly: For dynamic data visualization.
🤝 Contributing
Contributions are welcome\! Please fork the repository and submit a pull request.
📄 License
Distributed under the MIT License. See LICENSE for more information.
