get_neighbors
Find connected resources in Azure infrastructure to analyze relationships and dependencies for troubleshooting or optimization.
Instructions
Get resources connected to a specific resource
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| resourceId | Yes | Full Azure resource ID |
Implementation Reference
- src/server.ts:254-275 (handler)Core handler function that retrieves the specified resource node and all directly connected neighbor nodes from the cached topology graph by scanning edges.async function getResourceNeighbors(resourceId: string): Promise<{node: GraphNode, neighbors: GraphNode[]}> { const topology = await buildTopology(); const node = topology.nodes.find(n => n.id === resourceId); if (!node) { throw new McpError(ErrorCode.InvalidRequest, `Resource not found: ${resourceId}`); } // Find all connected nodes const connectedIds = new Set<string>(); for (const edge of topology.edges) { if (edge.source === resourceId) { connectedIds.add(edge.target); } else if (edge.target === resourceId) { connectedIds.add(edge.source); } } const neighbors = topology.nodes.filter(n => connectedIds.has(n.id)); return { node, neighbors };
- src/server.ts:371-384 (registration)Tool registration entry in the ListTools response, including name, description, and input schema.{ name: 'get_neighbors', description: 'Get resources connected to a specific resource', inputSchema: { type: 'object', properties: { resourceId: { type: 'string', description: 'Full Azure resource ID', }, }, required: ['resourceId'], }, },
- src/server.ts:479-495 (handler)Dispatch handler in the CallToolRequestHandler switch statement that extracts arguments, calls the core getResourceNeighbors function, and formats the textual response.case 'get_neighbors': { const { resourceId } = args as { resourceId: string }; const { node, neighbors } = await getResourceNeighbors(resourceId); return { content: [ { type: 'text', text: `Resource: ${node.name} (${node.type})\n\n` + `Connected Resources (${neighbors.length}):\n\n` + neighbors.map(n => `• ${n.name} (${n.type})\n Resource Group: ${n.resourceGroup}\n Location: ${n.location}` ).join('\n\n'), }, ], }; }