Skip to main content
Glama
dhippley

Azure Topology Graph MCP Server

by dhippley

export_topology

Export complete Azure infrastructure topology maps to analyze resource relationships and connectivity paths in JSON or summary format.

Instructions

Export the complete topology graph

Input Schema

NameRequiredDescriptionDefault
formatNoExport formatsummary

Input Schema (JSON Schema)

{ "properties": { "format": { "default": "summary", "description": "Export format", "enum": [ "json", "summary" ], "type": "string" } }, "type": "object" }

Implementation Reference

  • The handler function implementing the core logic of the 'export_topology' tool. It retrieves the topology graph and exports it in either JSON format or a human-readable summary.
    case 'export_topology': { const { format = 'summary' } = args as { format?: 'json' | 'summary' }; const topology = await buildTopology(); if (format === 'json') { return { content: [ { type: 'text', text: JSON.stringify(topology, null, 2), }, ], }; } else { const resourceTypes = Array.from(new Set(topology.nodes.map(n => n.type))).sort(); const subscriptions = Array.from(new Set(topology.nodes.map(n => n.subscriptionId))).sort(); const resourceGroups = Array.from(new Set(topology.nodes.map(n => n.resourceGroup))).sort(); return { content: [ { type: 'text', text: `Azure Topology Summary:\n\n` + `Total Resources: ${topology.nodes.length}\n` + `Total Connections: ${topology.edges.length}\n\n` + `Subscriptions (${subscriptions.length}):\n${subscriptions.map(s => `• ${s}`).join('\n')}\n\n` + `Resource Groups (${resourceGroups.length}):\n${resourceGroups.map(rg => `• ${rg}`).join('\n')}\n\n` + `Resource Types (${resourceTypes.length}):\n${resourceTypes.map(rt => `• ${rt}`).join('\n')}`, }, ], }; } }
  • src/server.ts:403-417 (registration)
    Registration of the 'export_topology' tool in the list of available tools, including its name, description, and input schema.
    { name: 'export_topology', description: 'Export the complete topology graph', inputSchema: { type: 'object', properties: { format: { type: 'string', enum: ['json', 'summary'], description: 'Export format', default: 'summary', }, }, }, },
  • Key helper function called by the export_topology handler to build and cache the topology graph from Azure resources using Resource Graph queries.
    async function buildTopology(): Promise<TopologyGraph> { const now = Date.now(); if (topologyCache && (now - cacheTimestamp) < CACHE_TTL) { return topologyCache; } console.error('Building topology from Azure resources...'); try { // Query all resources const resourcesResult = await resourceGraphClient.resources({ query: RESOURCE_QUERY, subscriptions: subscriptionIds, }); const nodes: GraphNode[] = []; const edges: GraphEdge[] = []; // Process resources into nodes if (resourcesResult.data) { for (const resource of resourcesResult.data as any[]) { const node: GraphNode = { id: resource.id, type: resource.type, name: resource.name, subscriptionId: resource.subscriptionId, resourceGroup: resource.resourceGroup, location: resource.location, tags: resource.tags, properties: resource.properties, }; nodes.push(node); } } // Build relationships/edges await buildResourceRelationships(nodes, edges); const topology: TopologyGraph = { nodes, edges }; topologyCache = topology; cacheTimestamp = now; console.error(`Topology built: ${nodes.length} nodes, ${edges.length} edges`); return topology; } catch (error) { console.error('Error building topology:', error); throw error; } }

Latest Blog Posts

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/dhippley/azure_mcp_graph'

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