Skip to main content
Glama

Ultra Analyze

ultra-analyze

Analyze code for architecture, performance, security, quality, or scalability issues using AI models. Provides step-by-step workflow with accumulated findings and confidence levels.

Instructions

Comprehensive code analysis with step-by-step workflow

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskYesWhat to analyze in the code
filesNoFile paths to analyze (optional)
focusNoAnalysis focus areaall
providerNoAI provider to use
modelNoSpecific model to use
stepNumberNoCurrent step in the analysis workflow
totalStepsNoEstimated total steps needed
findingsNoAccumulated findings from the analysis
nextStepRequiredNoWhether another step is needed
confidenceNoConfidence level in findings

Implementation Reference

  • Core implementation of the ultra-analyze tool: performs step-by-step code analysis using configured AI providers, workflow management, and formatted responses.
      async handleCodeAnalysis(args: unknown): Promise<HandlerResponse> {
        const params = CodeAnalysisSchema.parse(args);
        const { provider: requestedProvider, model: requestedModel, stepNumber, totalSteps, nextStepRequired, confidence, findings, files, focus, task } = params;
        
        const config = await this.configManager.getConfig();
        const providerName = requestedProvider || await this.providerManager.getPreferredProvider();
        const provider = await this.providerManager.getProvider(providerName);
        
        if (!provider) {
          throw new Error('No AI provider configured. Please run: bunx ultra-mcp config');
        }
    
        try {
          let context = '';
          let requiredActions: string[] = [];
          
          if (stepNumber === 1) {
            context = `You are performing a comprehensive code analysis focused on ${focus}.
            
    Task: ${task}
    ${files ? `Files to analyze: ${files.join(', ')}` : 'Analyze the relevant parts of the codebase'}
    
    Begin your analysis by understanding:
    1. The overall architecture and design patterns
    2. ${focus === 'performance' ? 'Performance characteristics and bottlenecks' : ''}
    3. ${focus === 'security' ? 'Security posture and potential vulnerabilities' : ''}
    4. ${focus === 'architecture' ? 'Architectural decisions and their implications' : ''}
    5. ${focus === 'quality' ? 'Code quality, maintainability, and technical debt' : ''}
    6. ${focus === 'scalability' ? 'Scalability considerations and limitations' : ''}`;
    
            requiredActions = [
              'Map out the codebase structure and architecture',
              'Identify key components and their relationships',
              'Understand data flow and dependencies',
              'Note design patterns and architectural decisions',
              'Document initial observations',
            ];
          } else {
            context = `Continue your analysis based on previous findings:
    
    ${findings}
    
    Deepen your investigation into:
    - Specific areas of concern identified
    - Hidden complexities or technical debt
    - Opportunities for improvement
    - Best practices and patterns that could be applied`;
    
            requiredActions = [
              'Investigate specific concerns in detail',
              'Analyze impact of identified issues',
              'Research best practices for similar systems',
              'Evaluate alternative approaches',
              'Document detailed findings with evidence',
            ];
          }
    
          const prompt = `${context}\n\nProvide your analysis for step ${stepNumber} of ${totalSteps}.`;
          
          const fullResponse = await provider.generateText({
            prompt,
            model: requestedModel,
            temperature: 0.4,
            useSearchGrounding: false,
          });
    
          // TODO: Implement tracking
          // await trackUsage({
          //   tool: 'ultra-analyze',
          //   model: provider.getActiveModel(),
          //   provider: provider.getName(),
          //   input_tokens: 0,
          //   output_tokens: 0,
          //   cache_tokens: 0,
          //   total_tokens: 0,
          //   has_credentials: true,
          // });
    
          const formattedResponse = formatWorkflowResponse(
            stepNumber,
            totalSteps,
            nextStepRequired && confidence !== 'certain',
            fullResponse.text,
            requiredActions
          );
    
          return {
            content: [{ type: 'text', text: formattedResponse }],
          };
        } catch (error) {
          logger.error('Code analysis failed:', error);
          throw error;
        }
      }
  • Zod schema defining input parameters for the ultra-analyze tool, including task, focus areas, workflow steps, and AI provider configuration.
    export const CodeAnalysisSchema = z.object({
      task: z.string().describe('What to analyze in the code'),
      files: z.array(z.string()).optional().describe('File paths to analyze (optional)'),
      focus: z.enum(['architecture', 'performance', 'security', 'quality', 'scalability', 'all']).default('all')
        .describe('Analysis focus area'),
      provider: z.enum(['openai', 'gemini', 'azure', 'grok']).optional()
        .describe('AI provider to use'),
      model: z.string().optional().describe('Specific model to use'),
      
      // Workflow fields
      stepNumber: z.number().min(1).default(1).describe('Current step in the analysis workflow'),
      totalSteps: z.number().min(1).default(3).describe('Estimated total steps needed'),
      findings: z.string().default('').describe('Accumulated findings from the analysis'),
      nextStepRequired: z.boolean().default(true).describe('Whether another step is needed'),
      confidence: z.enum(['exploring', 'low', 'medium', 'high', 'very_high', 'almost_certain', 'certain'])
        .optional().describe('Confidence level in findings'),
    });
  • src/server.ts:405-413 (registration)
    MCP server registration of the ultra-analyze tool, linking schema and handler implementation.
    server.registerTool("ultra-analyze", {
      title: "Ultra Analyze",
      description: "Comprehensive code analysis with step-by-step workflow",
      inputSchema: CodeAnalysisSchema.shape,
    }, async (args) => {
      const { AdvancedToolsHandler } = await import("./handlers/advanced-tools");
      const handler = new AdvancedToolsHandler();
      return await handler.handleCodeAnalysis(args);
    });
  • Dispatch handler that routes 'ultra-analyze' calls to the specific handleCodeAnalysis method.
    async handle(request: { method: string; params: { arguments: unknown } }): Promise<CallToolResult> {
      const { method, params } = request;
    
      switch (method) {
        case 'ultra-review':
          return await this.handleCodeReview(params.arguments);
        case 'ultra-analyze':
          return await this.handleCodeAnalysis(params.arguments);
        case 'ultra-debug':
          return await this.handleDebug(params.arguments);
        case 'ultra-plan':
          return await this.handlePlan(params.arguments);
        case 'ultra-docs':
          return await this.handleDocs(params.arguments);
        default:
          throw new Error(`Unknown method: ${method}`);
      }
    }
  • src/server.ts:832-850 (registration)
    MCP prompt registration for ultra-analyze, providing a natural language interface.
    server.registerPrompt("ultra-analyze", {
      title: "Ultra Code Analysis",
      description: "Deep step-by-step code analysis with architectural insights",
      argsSchema: {
        task: z.string(),
        files: z.string().optional(),
        focus: z.string().optional(),
        stepNumber: z.string(),
        totalSteps: z.string(),
      },
    }, (args) => ({
      messages: [{
        role: "user",
        content: {
          type: "text",
          text: `Perform deep code analysis: ${args.task}${args.files ? `\n\nFiles to analyze: ${args.files}` : ''}${args.focus ? ` (focus: ${args.focus})` : ''} (Step ${args.stepNumber} of ${args.totalSteps})`
        }
      }]
    }));
Behavior2/5

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

With no annotations provided, the description carries full burden but offers minimal behavioral disclosure. It mentions 'step-by-step workflow' suggesting iterative execution, but doesn't describe what 'comprehensive code analysis' entails operationally—such as whether it modifies code, requires specific permissions, has rate limits, or what the output format looks like. For a complex 10-parameter tool with no annotations, this leaves significant gaps in understanding how the tool behaves.

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

Conciseness4/5

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

The description is a single, efficient phrase that's front-loaded with the core purpose. It wastes no words, though it could be more specific. For a tool with this complexity, it might be too brief, but it's structurally sound and not verbose.

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

Completeness2/5

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

Given the high complexity (10 parameters, no annotations, no output schema) and the description's vagueness, it's incomplete. The description doesn't adequately explain what 'comprehensive code analysis' means, how the step-by-step workflow operates, or what results to expect. For a tool with many parameters and no structured behavioral hints, more descriptive context is needed to guide effective use.

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 description coverage is 100%, so the schema already documents all 10 parameters thoroughly. The description adds no specific parameter information beyond what's in the schema—it doesn't explain relationships between parameters like 'stepNumber' and 'totalSteps', or how 'findings' accumulates. Baseline 3 is appropriate as the schema does the heavy lifting, but the description doesn't compensate with additional semantic context.

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

Purpose3/5

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

The description 'Comprehensive code analysis with step-by-step workflow' states a general purpose but lacks specificity about what distinguishes it from siblings like 'analyze-code', 'review-code', or 'ultra-review'. It mentions 'step-by-step workflow' which hints at iterative analysis, but doesn't clearly differentiate the tool's unique function or scope compared to similar tools in the server.

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?

No explicit guidance on when to use this tool versus alternatives like 'analyze-code', 'review-code', or 'ultra-review' is provided. The description implies a comprehensive, multi-step approach but doesn't specify scenarios where this is preferred over simpler one-shot analysis tools or other siblings. Usage context is only vaguely implied by 'step-by-step workflow'.

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/RealMikeChong/ultra-mcp'

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