Skip to main content
Glama

Azure MCP Server

by pcsouzafv
GUIA_RAPIDO.md4.53 kB
# Guia Rápido - Azure MCP Server ## Passo 1: Configurar Credenciais Azure ### Criar arquivo .env Copie o arquivo de exemplo: ```bash copy .env.example .env ``` ### Obter Credenciais Azure Você tem duas opções: #### Opção A: Usar Azure CLI (Recomendado) ```bash # Fazer login no Azure az login # Criar Service Principal az ad sp create-for-rbac --name "azure-mcp-server" --role "Reader" --scopes /subscriptions/SUA-SUBSCRIPTION-ID # O comando retornará algo assim: # { # "appId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", # "displayName": "azure-mcp-server", # "password": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", # "tenant": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" # } ``` #### Opção B: Usar Portal Azure 1. Acesse o Portal Azure 2. Vá em "Azure Active Directory" > "App registrations" > "New registration" 3. Após criar, vá em "Certificates & secrets" > "New client secret" 4. Anote o valor do secret (você só verá uma vez!) 5. Vá em "Overview" e copie: - Application (client) ID - Directory (tenant) ID 6. Vá em "Subscriptions" e copie sua Subscription ID 7. Atribua a role "Reader" ao Service Principal na subscription ### Editar o arquivo .env ```env AZURE_SUBSCRIPTION_ID=sua-subscription-id-aqui AZURE_TENANT_ID=seu-tenant-id-aqui AZURE_CLIENT_ID=seu-client-id-aqui (appId) AZURE_CLIENT_SECRET=seu-client-secret-aqui (password) PORT=3000 NODE_ENV=development ``` ## Passo 2: Iniciar o Servidor ```bash # Desenvolvimento (com hot-reload) npm run dev # Produção npm start ``` ## Passo 3: Testar ### Testar Health Check ```bash curl http://localhost:3000/health ``` Resposta esperada: ```json { "status": "healthy", "azureConfigured": true, "timestamp": "2025-11-02T...", "service": "Azure MCP Server" } ``` ### Listar VMs ```bash curl http://localhost:3000/api/vms ``` ### Listar VMSS ```bash curl http://localhost:3000/api/vmss ``` ### Obter Status de VM ```bash curl http://localhost:3000/api/vms/MEU-RESOURCE-GROUP/MINHA-VM/status ``` ## Troubleshooting ### Erro: "Configuração Azure incompleta" - Verifique se o arquivo `.env` existe - Confirme que todas as variáveis estão preenchidas - Reinicie o servidor após editar o `.env` ### Erro: "Unauthorized" ou "Forbidden" - Verifique se o Service Principal tem a role "Reader" - Confirme que a subscription ID está correta - Teste as credenciais com Azure CLI: `az login --service-principal` ### Erro: "Resource Group não encontrado" - Verifique se o nome está correto (case-sensitive) - Confirme que o resource group existe na subscription - Verifique se o Service Principal tem acesso a esse resource group ## Exemplos de Uso ### PowerShell ```powershell # Listar todas VMs Invoke-RestMethod -Uri "http://localhost:3000/api/vms" # Obter status de VM específica Invoke-RestMethod -Uri "http://localhost:3000/api/vms/rg-prod/vm-web-01/status" ``` ### JavaScript/Node.js ```javascript const fetch = require('node-fetch'); async function getVMs() { const response = await fetch('http://localhost:3000/api/vms'); const data = await response.json(); console.log(data); } getVMs(); ``` ### Python ```python import requests response = requests.get('http://localhost:3000/api/vms') vms = response.json() print(vms) ``` ## Endpoints Disponíveis | Método | Endpoint | Descrição | |--------|----------|-----------| | GET | `/health` | Health check | | GET | `/` | Informações e documentação | | GET | `/api/vms` | Listar todas VMs | | GET | `/api/vms/resource-group/:rg` | Listar VMs por RG | | GET | `/api/vms/:rg/:vm` | Detalhes de VM | | GET | `/api/vms/:rg/:vm/status` | Status de VM | | GET | `/api/vmss` | Listar todos VMSS | | GET | `/api/vmss/resource-group/:rg` | Listar VMSS por RG | | GET | `/api/vmss/:rg/:vmss` | Detalhes de VMSS | | GET | `/api/vmss/:rg/:vmss/status` | Status de VMSS | | GET | `/api/vmss/:rg/:vmss/instances` | Listar instâncias | | GET | `/api/vmss/:rg/:vmss/instances/:id` | Detalhes da instância | ## Segurança em Produção 1. Use HTTPS (configure um reverse proxy como nginx) 2. Adicione autenticação (JWT, API Keys, etc) 3. Use Azure Key Vault para secrets 4. Configure rate limiting 5. Use variáveis de ambiente do sistema, não arquivo .env 6. Habilite logs e monitoramento 7. Configure firewall para restringir acesso ## Próximos Passos - Adicionar cache para melhorar performance - Implementar webhooks para notificações - Criar dashboard web - Adicionar mais serviços Azure (App Services, Storage, etc) - Implementar métricas e alertas

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/pcsouzafv/azure-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server