Skip to main content
Glama

Analyze file

analyze_file

Analyze code to identify legacy imports, components, props, hooks, and Tailwind patterns for migration to HeroUI v3.

Instructions

Analyze code and return detailed findings about legacy imports, components, props, hooks and Tailwind patterns.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYes
filenameNo

Implementation Reference

  • The main handler function for the `analyze_file` MCP tool. It orchestrates compatibility checks, Tailwind analysis, and AST traversal.
    export async function analyzeFile(code: string, filename?: string): Promise<AnalyzeFileResult> {
      const findings: any[] = [];
      const manualSteps: string[] = [];
    
      // run compatibility helpers first (imports/hooks/props that weren't captured by AST)
      const issues = checkV3Compatibility(code);
      for (const msg of issues) {
        findings.push({ type: "doc", severity: "warning", message: msg, autoFixable: false, confidence: 0.5 });
      }
    
      // tailwind plugin check
      const tw = analyzeTailwindConfig(code);
      for (const iss of tw.issues) {
        findings.push({ type: "tailwind", severity: "warning", message: iss, autoFixable: false, confidence: 0.6 });
      }
    
      // AST-based scanning for more precise locations and types
      try {
        const ast = parse(code, { sourceType: "module", plugins: ["jsx", "typescript"], locations: true });
        traverse(ast, {
          ImportDeclaration(path: any) {
            const src = path.node.source.value;
            if (src.includes("@nextui-org/react")) {
              const loc = path.node.loc?.start;
              findings.push({
                type: "import",
                severity: "warning",
                message: `Legacy import source ${src}`,
                autoFixable: true,
                confidence: 0.8,
                location: loc ? { line: loc.line, column: loc.column } : undefined,
              });
            }
            path.node.specifiers.forEach((spec: any) => {
              if (t.isImportSpecifier(spec)) {
                const name = spec.imported.name;
                if (KNOWN_V2_IMPORTS[name]) {
                  const loc = spec.loc?.start;
                  findings.push({
                    type: "import",
                    severity: "info",
                    message: `Legacy component import ${name}`,
                    component: name,
                    autoFixable: true,
                    confidence: 0.7,
                    location: loc ? { line: loc.line, column: loc.column } : undefined,
                  });
                }
              }
            });
          },
          JSXOpeningElement(path: any) {
            const nameNode = path.node.name;
            if (t.isJSXIdentifier(nameNode)) {
              const name = nameNode.name;
              if (KNOWN_V2_IMPORTS[name]) {
                const loc = nameNode.loc?.start;
  • src/server.ts:419-432 (registration)
    Tool registration for `analyze_file` in the MCP server setup. It handles input parsing and invokes the core migration logic.
    server.registerTool(
      "analyze_file",
      {
        title: "Analyze file",
        description: "Analyze code and return detailed findings about legacy imports, components, props, hooks and Tailwind patterns.",
        inputSchema: { code: z.string(), filename: z.string().optional() }
      },
      async ({ code, filename }) => {
        const { analyzeFile } = await import("./core/migration.js");
        const result = await analyzeFile(code, filename);
        AnalyzeFileResultSchema.parse(result);
        return { content: [], structuredContent: result as any };
      }
    );
Behavior2/5

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

No annotations provided, so description carries full disclosure burden. While 'return detailed findings' implies read-only behavior, it fails to explicitly confirm safety, side effects, output format, or what constitutes 'legacy' patterns.

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?

Single efficient sentence (12 words) that front-loads the action and target. No redundant or wasteful text.

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

Completeness3/5

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

For a 2-parameter analysis tool with no output schema, the description adequately covers the analysis scope but leaves critical gaps regarding the optional filename parameter and return value structure. Minimum viable but incomplete.

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

Parameters2/5

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

Schema coverage is 0% with no parameter descriptions. Description mentions analyzing 'code' which maps to the required parameter, but offers no explanation for the optional 'filename' parameter (its purpose, format, or when to include it). Inadequate compensation for schema gaps.

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

Purpose4/5

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

States specific verb ('Analyze') and target resource ('code'), listing concrete analysis targets (legacy imports, components, props, hooks, Tailwind patterns). Implicitly distinguishes from sibling 'audit_tailwind' by breadth of analysis, though explicit comparison is absent.

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

Usage Guidelines2/5

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

Provides no explicit guidance on when to use this tool versus siblings like 'scan_project' (multi-file) or 'audit_tailwind' (narrow scope). No prerequisites or exclusions mentioned.

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/sctg-development/heroui-migration-mcp'

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