Azure Architecture Diagram Generator MCP Server
A Model Context Protocol (MCP) server that generates Azure architecture diagrams from natural language descriptions using Python's diagrams library.
Features
- 🏗️ Natural Language Processing: Convert text descriptions into structured Azure architecture diagrams
- 🎨 Visual Diagrams: Generate both PNG and SVG format diagrams with official Azure icons
- 🐳 Docker Support: Fully containerized for easy deployment
- 🔧 MCP Protocol: Compatible with MCP clients for seamless integration
- ☁️ Comprehensive Azure Support: Covers 15+ Azure service categories including:
- Compute (VMs, App Service, Functions, AKS)
- Storage (Blob, Files, Queues, Tables)
- Databases (SQL Database, Cosmos DB, Redis Cache)
- Networking (VNet, Load Balancer, Application Gateway)
- Security & Monitoring services
Quick Start
Using Docker (Recommended)
-
Clone the repository:
git clone <your-repo-url> cd genaidiagramsasmcp -
Build the Docker image:
docker build -t azure-diagram-mcp . -
Run the container:
docker run -it azure-diagram-mcp
Local Development
-
Install dependencies:
pip install -r requirements.txt -
Install Graphviz (required for diagram generation):
- Windows: Download from graphviz.org or use
choco install graphviz - macOS:
brew install graphviz - Ubuntu/Debian:
sudo apt-get install graphviz
- Windows: Download from graphviz.org or use
-
Configure environment (optional):
cp .env.example .env # Edit .env with your Azure OpenAI credentials -
Run the server:
python azure_diagram_server.py
Usage Examples
Basic Diagram Generation
from azure_diagram_server import AzureDiagramGenerator
generator = AzureDiagramGenerator()
# Generate from text description
description = "A web application with Azure App Service, SQL Database, and Redis Cache"
result = generator.generate_diagram_from_text(description, "web_app_diagram")
# Generate from structured JSON
services = [
{"type": "appservice", "name": "WebApp"},
{"type": "sqldatabase", "name": "Database"},
{"type": "redis", "name": "Cache"}
]
result = generator.generate_diagram_from_json(services, "structured_diagram")
Supported Azure Services
The server supports a comprehensive range of Azure services:
| Category | Services |
|---|---|
| Compute | Virtual Machines, App Service, Functions, AKS, Container Instances |
| Storage | Blob Storage, File Storage, Queue Storage, Table Storage |
| Database | SQL Database, Cosmos DB, Redis Cache, MySQL, PostgreSQL |
| Networking | Virtual Network, Load Balancer, Application Gateway, CDN, DNS |
| Security | Key Vault, Active Directory, Security Center |
| Monitoring | Monitor, Log Analytics, Application Insights |
API Reference
MCP Tools
The server exposes the following MCP tools:
generate_azure_diagram
Generate an Azure architecture diagram from a text description.
Parameters:
description(string): Natural language description of the architecturediagram_name(string): Name for the generated diagram fileformat(string, optional): Output format - "png" or "svg" (default: "png")
Returns:
success(boolean): Whether the operation succeededmessage(string): Status messagefile_path(string): Path to the generated diagram fileservices_identified(array): List of Azure services identified in the description
generate_azure_diagram_from_json
Generate an Azure architecture diagram from structured service data.
Parameters:
services(array): List of service objects withtypeandnamepropertiesdiagram_name(string): Name for the generated diagram fileformat(string, optional): Output format - "png" or "svg" (default: "png")
Returns:
- Same as
generate_azure_diagram
Configuration
Environment Variables
Create a .env file with the following variables (optional):
AZURE_OPENAI_ENDPOINT=your_azure_openai_endpoint
AZURE_OPENAI_KEY=your_azure_openai_key
AZURE_OPENAI_DEPLOYMENT=your_deployment_name
AZURE_OPENAI_API_VERSION=2024-02-15-preview
Note: Azure OpenAI is optional. The server will fall back to basic NLP processing if not configured.
Architecture
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ MCP Client │────│ MCP Server │────│ Diagrams │
│ │ │ (FastMCP) │ │ Library │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│
┌──────────────────┐
│ Azure OpenAI │
│ (Optional) │
└──────────────────┘
Development
Project Structure
genaidiagramsasmcp/
├── azure_diagram_server.py # Main MCP server implementation
├── requirements.txt # Python dependencies
├── Dockerfile # Container configuration
├── .env # Environment variables (create from .env.example)
├── README.md # This file
├── tests/ # Test files
│ ├── test_server_fixed.py # Fixed test script
│ ├── validate_mcp.py # Comprehensive validation
│ └── test_mcp_simple.py # Simple diagram test
└── DEPLOYMENT_SUMMARY.md # Deployment documentation
Running Tests
# Test basic functionality
python test_server_fixed.py
# Comprehensive validation
python validate_mcp.py
# Simple diagram generation test
python test_mcp_simple.py
Docker Development
# Build with no cache to ensure latest code
docker build --no-cache -t azure-diagram-mcp .
# Run with volume mount for development
docker run -v $(pwd):/app -it azure-diagram-mcp
Contributing
- Fork the repository
- Create a feature branch:
git checkout -b feature-name - Make your changes and add tests
- Commit your changes:
git commit -am 'Add feature' - Push to the branch:
git push origin feature-name - Submit a pull request
License
This project is licensed under the MIT License - see the LICENSE file for details.
Troubleshooting
Common Issues
- Graphviz not found: Install Graphviz system package
- Import errors: Ensure all Python dependencies are installed
- Azure OpenAI errors: Check your API credentials or use without Azure OpenAI
- Docker build fails: Ensure Docker has sufficient resources allocated
Support
For issues and questions:
- Create an issue on GitHub
- Check the DEPLOYMENT_SUMMARY.md for detailed deployment information
Acknowledgments
- Built with FastMCP for MCP protocol support
- Uses Diagrams library for diagram generation
- Azure icons provided by the diagrams library
- Follows Model Context Protocol specification
