find_path
Discover connection paths between Azure resources to analyze network connectivity and troubleshoot infrastructure relationships.
Instructions
Find connection path between two Azure resources
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sourceId | Yes | Source resource ID | |
| targetId | Yes | Target resource ID |
Implementation Reference
- src/server.ts:497-523 (handler)MCP tool dispatcher case for 'find_path' tool. Parses arguments, calls the path-finding function, handles no-path case, and formats the response content.case 'find_path': { const { sourceId, targetId } = args as { sourceId: string; targetId: string }; const path = await findResourcePath(sourceId, targetId); if (path.length === 0) { return { content: [ { type: 'text', text: `No connection path found between the specified resources.`, }, ], }; } return { content: [ { type: 'text', text: `Connection Path (${path.length} hops):\n\n` + path.map((node, index) => `${index + 1}. ${node.name} (${node.type})\n ${node.id}` ).join('\n\n'), }, ], }; }
- src/server.ts:279-320 (handler)Core implementation of the find_path tool using BFS to find the shortest path between two resources in the topology graph.async function findResourcePath(sourceId: string, targetId: string): Promise<GraphNode[]> { const topology = await buildTopology(); if (!topology.nodes.find(n => n.id === sourceId)) { throw new McpError(ErrorCode.InvalidRequest, `Source resource not found: ${sourceId}`); } if (!topology.nodes.find(n => n.id === targetId)) { throw new McpError(ErrorCode.InvalidRequest, `Target resource not found: ${targetId}`); } // Simple BFS to find shortest path const queue: string[][] = [[sourceId]]; const visited = new Set<string>([sourceId]); while (queue.length > 0) { const path = queue.shift()!; const current = path[path.length - 1]; if (current === targetId) { return path.map(id => topology.nodes.find(n => n.id === id)!); } // Find neighbors for (const edge of topology.edges) { let next: string | null = null; if (edge.source === current && !visited.has(edge.target)) { next = edge.target; } else if (edge.target === current && !visited.has(edge.source)) { next = edge.source; } if (next) { visited.add(next); queue.push([...path, next]); } } } return []; // No path found }
- src/server.ts:385-402 (registration)Registration of the 'find_path' tool in the listTools response, including name, description, and input schema definition.{ name: 'find_path', description: 'Find connection path between two Azure resources', inputSchema: { type: 'object', properties: { sourceId: { type: 'string', description: 'Source resource ID', }, targetId: { type: 'string', description: 'Target resource ID', }, }, required: ['sourceId', 'targetId'], }, },
- src/server.ts:388-401 (schema)Input schema definition for the 'find_path' tool specifying sourceId and targetId parameters.inputSchema: { type: 'object', properties: { sourceId: { type: 'string', description: 'Source resource ID', }, targetId: { type: 'string', description: 'Target resource ID', }, }, required: ['sourceId', 'targetId'], },