get_dependencies
Analyze import, call, and containment relationships between modules, classes, and functions to understand codebase dependencies and connections.
Instructions
Get import/call/containment relationships between entities. Shows how modules, classes, and functions are connected.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| project | No | Project name or path | |
| source | No | Filter by source entity name | |
| target | No | Filter by target entity name | |
| relationship | No | Filter by relationship type | |
| limit | No | Max results (default: 100) |
Implementation Reference
- index.ts:180-233 (handler)The handler implementation for the "get_dependencies" tool, which filters and returns dependencies based on project, source, target, and relationship type.
// Tool 2: Get dependencies server.tool( "get_dependencies", "Get import/call/containment relationships between entities. Shows how modules, classes, and functions are connected.", { project: z.string().optional().describe("Project name or path"), source: z.string().optional().describe("Filter by source entity name"), target: z.string().optional().describe("Filter by target entity name"), relationship: z.enum(["all", "import", "call", "contains"]).optional().describe("Filter by relationship type"), limit: z.number().optional().describe("Max results (default: 100)"), }, async ({ project, source, target, relationship, limit }) => { const loaded = loadAnalysis(project); if (!loaded) { return { content: [{ type: "text" as const, text: "No analysis data found. Run 'CodeAtlas: Analyze Project' first." }] }; } const nodeMap = new Map(loaded.analysis.graph.nodes.map((n) => [n.id, n.label])); let links = loaded.analysis.graph.links; if (relationship && relationship !== "all") { links = links.filter((l) => l.type === relationship); } if (source) { links = links.filter((l) => { const label = nodeMap.get(l.source) || l.source; return label.toLowerCase().includes(source.toLowerCase()); }); } if (target) { links = links.filter((l) => { const label = nodeMap.get(l.target) || l.target; return label.toLowerCase().includes(target.toLowerCase()); }); } const maxResults = limit || 100; const truncated = links.length > maxResults; links = links.slice(0, maxResults); const result = { total: loaded.analysis.graph.links.length, showing: links.length, truncated, dependencies: links.map((l) => ({ source: nodeMap.get(l.source) || l.source, target: nodeMap.get(l.target) || l.target, type: l.type, })), }; return { content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }] }; } );