Skip to main content
Glama

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
NameRequiredDescriptionDefault
projectNoProject name or path
sourceNoFilter by source entity name
targetNoFilter by target entity name
relationshipNoFilter by relationship type
limitNoMax results (default: 100)

Implementation Reference

  • 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) }] };
      }
    );

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/giauphan/codeatlas-mcp'

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