Skip to main content
Glama

analyze_current_file

Analyze SAPUI5 file structure to identify imports, classes, and controller methods for development insights.

Instructions

Analyze the current file for imports, class structure, and controller methods.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes

Implementation Reference

  • The main handler function that executes the analyze_current_file tool logic. It parses input arguments, reads the file using readTextFile, analyzes the file structure using analyzeFileStructure, detects the controller pattern, and returns validated output.
    async handler(args, { context }) {
      const { path } = inputSchema.parse(args);
      const code = await readTextFile(path, context.rootDir);
      // AST-backed parser utilities expose metadata for IDE automation and audits.
      const analysis = analyzeFileStructure(code);
    
      return outputSchema.parse({
        path,
        imports: analysis.imports,
        classNames: analysis.classNames,
        controllerPattern: detectControllerPattern(code),
        controllerMethods: analysis.controllerMethods
      });
    }
  • Input and output schema definitions using Zod. The input schema validates a 'path' string parameter, while the output schema defines the structure for analysis results including imports, class names, controller pattern, and controller methods.
    const inputSchema = z.object({
      path: z.string().min(1)
    }).strict();
    
    const outputSchema = z.object({
      path: z.string(),
      imports: z.object({
        esmImports: z.array(z.string()),
        sapUiDefineDependencies: z.array(z.string())
      }),
      classNames: z.array(z.string()),
      controllerPattern: z.string(),
      controllerMethods: z.array(z.string())
    });
  • src/tools/index.js:4-4 (registration)
    Import statement for the analyzeCurrentFileTool from the project-specific module.
    import { analyzeCurrentFileTool } from "./project/analyzeCurrentFile.js";
  • Registration of the analyzeCurrentFileTool in the allTools array, making it available as an MCP tool.
    analyzeCurrentFileTool,
  • Helper function readTextFile that resolves a workspace path, validates it exists as a file, and reads its contents as UTF-8 text. Used by the handler to read the file to be analyzed.
    export async function readTextFile(inputPath, root = workspaceRoot()) {
      const resolved = resolveWorkspacePath(inputPath, root);
      await assertPathExists(resolved);
      const stats = await fs.stat(resolved);
      if (!stats.isFile()) {
        throw new ToolError(`Path is not a file: ${inputPath}`, { code: "NOT_A_FILE" });
      }
      return fs.readFile(resolved, "utf8");
    }

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/santiagosanmartinn/mcpui5server'

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