Skip to main content
Glama

get_project_structure

Retrieve all code entities—modules, classes, functions, variables—from a project with their type, name, file path, and line number. Filter by entity type and limit results for targeted analysis.

Instructions

Get all modules, classes, functions, and variables in the analyzed project. Returns entity type, name, file path, and line number.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
projectNoProject name or path (auto-detects if omitted)
typeNoFilter by entity type
limitNoMax results to return (default: 100)

Implementation Reference

  • index.ts:157-199 (registration)
    Tool registration for 'get_project_structure' using server.tool() with name, description, Zod schema for input, and handler function.
    server.tool(
      "get_project_structure",
      "Get all modules, classes, functions, and variables in the analyzed project. Returns entity type, name, file path, and line number.",
      {
        project: z.string().optional().describe("Project name or path (auto-detects if omitted)"),
        type: z.enum(["all", "module", "class", "function", "variable"]).optional().describe("Filter by entity type"),
        limit: z.number().optional().describe("Max results to return (default: 100)"),
      },
      async ({ project, type, limit }) => {
        const loaded = loadAnalysis(project);
        if (!loaded) {
          return { content: [{ type: "text" as const, text: "No analysis data found. Run 'CodeAtlas: Analyze Project' in VS Code first." }] };
        }
    
        let nodes = loaded.analysis.graph.nodes;
        if (type && type !== "all") {
          nodes = nodes.filter((n) => n.type === type);
        }
    
        const maxResults = limit || 100;
        const truncated = nodes.length > maxResults;
        nodes = nodes.slice(0, maxResults);
    
        const stats = getStats(loaded.analysis);
    
        const result = {
          project: loaded.projectName,
          projectDir: loaded.projectDir,
          total: loaded.analysis.graph.nodes.length,
          showing: nodes.length,
          truncated,
          stats,
          entities: nodes.map((n) => ({
            name: n.label,
            type: n.type,
            filePath: n.filePath || null,
            line: n.line || null,
          })),
        };
    
        return { content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }] };
      }
    );
  • Handler function that loads analysis data, optionally filters nodes by type, limits results, and returns entities with name, type, filePath, and line number.
    async ({ project, type, limit }) => {
      const loaded = loadAnalysis(project);
      if (!loaded) {
        return { content: [{ type: "text" as const, text: "No analysis data found. Run 'CodeAtlas: Analyze Project' in VS Code first." }] };
      }
    
      let nodes = loaded.analysis.graph.nodes;
      if (type && type !== "all") {
        nodes = nodes.filter((n) => n.type === type);
      }
    
      const maxResults = limit || 100;
      const truncated = nodes.length > maxResults;
      nodes = nodes.slice(0, maxResults);
    
      const stats = getStats(loaded.analysis);
    
      const result = {
        project: loaded.projectName,
        projectDir: loaded.projectDir,
        total: loaded.analysis.graph.nodes.length,
        showing: nodes.length,
        truncated,
        stats,
        entities: nodes.map((n) => ({
          name: n.label,
          type: n.type,
          filePath: n.filePath || null,
          line: n.line || null,
        })),
      };
    
      return { content: [{ type: "text" as const, text: JSON.stringify(result, null, 2) }] };
    }
  • Input schema using Zod: optional project (string), optional type (enum: all/module/class/function/variable), optional limit (number, default 100).
    {
      project: z.string().optional().describe("Project name or path (auto-detects if omitted)"),
      type: z.enum(["all", "module", "class", "function", "variable"]).optional().describe("Filter by entity type"),
      limit: z.number().optional().describe("Max results to return (default: 100)"),
    },
  • Helper function getStats() used by the handler to unify stats from different analysis format versions (entityCounts vs stats).
    function getStats(analysis: AnalysisResult) {
      const ec = analysis.entityCounts;
      const st = analysis.stats;
      return {
        files: st?.files ?? ec?.modules ?? analysis.totalFilesAnalyzed ?? 0,
        modules: ec?.modules ?? st?.files ?? analysis.totalFilesAnalyzed ?? 0,
        functions: ec?.functions ?? st?.functions ?? 0,
        classes: ec?.classes ?? st?.classes ?? 0,
        dependencies: ec?.dependencies ?? st?.dependencies ?? 0,
        circularDeps: ec?.circularDeps ?? st?.circularDeps ?? 0,
      };
    }
  • Helper function loadAnalysis() that discovers projects, finds the matching project, and reads/parses the analysis.json file.
    function loadAnalysis(projectDir?: string): { analysis: AnalysisResult; projectName: string; projectDir: string } | null {
      const projects = discoverProjects();
      if (projects.length === 0) return null;
    
      let target = projects[0]; // default: most recently modified
    
      if (projectDir) {
        const match = projects.find(
          (p) => p.dir === projectDir || p.name.toLowerCase() === projectDir.toLowerCase()
        );
        if (match) target = match;
      }
    
      try {
        const data = fs.readFileSync(target.analysisPath, "utf-8");
        return { analysis: JSON.parse(data), projectName: target.name, projectDir: target.dir };
      } catch (e) {
        console.error(`[CodeAtlas] ERROR: Failed to parse analysis file at ${target.analysisPath}: ${e}`);
        return null;
      }
    }
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description must carry the behavioral transparency burden. It only mentions what is returned, omitting behavioral traits such as performance, pagination behavior, or any side effects. This is minimal disclosure.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence (18 words) that front-loads the main purpose without any fluff or redundant information.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness4/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a query tool with 3 optional parameters and no output schema, the description covers the core purpose and returned fields, but omits details like the default behavior of the 'limit' parameter or how auto-detection works for 'project'. Still sufficiently complete.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so the schema already documents all parameters. The description does not add additional meaning beyond the schema, meeting the baseline of 3.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description explicitly states the verb 'Get' and the resource 'modules, classes, functions, and variables in the analyzed project', specifying the returned fields (entity type, name, file path, line number), making it clear and distinct from sibling tools.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description does not provide guidance on when to use this tool versus alternatives, nor does it mention prerequisites or exclusions. Usage is implied by the description but not explicitly stated.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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