Skip to main content
Glama
evalops

Deep Code Reasoning MCP Server

by evalops

escalate_analysis

Transfer complex code analysis tasks to Gemini when Claude Code encounters reasoning limits, enabling advanced semantic analysis beyond syntactic patterns for deeper insights.

Instructions

Hand off complex analysis to Gemini when Claude Code hits reasoning limits. Gemini will perform deep semantic analysis beyond syntactic patterns.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
analysis_typeYesType of deep analysis to perform
claude_contextYes
depth_levelNoHow deep to analyze (1=shallow, 5=very deep)
time_budget_secondsNoMaximum time for analysis

Implementation Reference

  • MCP CallToolRequest handler case for 'escalate_analysis': parses args using EscalateAnalysisSchema, validates context, constructs ClaudeCodeContext, calls deepReasoner.escalateFromClaudeCode and returns result as text content.
    case 'escalate_analysis': {
      const parsed = EscalateAnalysisSchema.parse(args);
    
      // Validate and sanitize the Claude context
      const validatedContext = InputValidator.validateClaudeContext(parsed.claude_context);
    
      // Override with specific values from the parsed input
      const context: ClaudeCodeContext = {
        ...validatedContext,
        analysisBudgetRemaining: parsed.time_budget_seconds,
      };
    
      const result = await deepReasoner.escalateFromClaudeCode(
        context,
        parsed.analysis_type,
        parsed.depth_level || 3,
      );
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • Core logic execution for escalate_analysis: reads code files from context.focusArea, optionally enriches with related files based on depthLevel, performs analysis via GeminiService.analyzeWithGemini, handles timeout and errors.
    async escalateFromClaudeCode(
      context: ClaudeCodeContext,
      analysisType: string,
      depthLevel: number,
    ): Promise<DeepAnalysisResult> {
      const startTime = Date.now();
      const timeoutMs = context.analysisBudgetRemaining * 1000;
    
      try {
        // Read all relevant code files
        const codeFiles = await this.codeReader.readCodeFiles(context.focusArea);
    
        // Enrich with related files if depth > 3
        if (depthLevel > 3) {
          await this.enrichWithRelatedFiles(context, codeFiles);
        }
    
        // Send to Gemini for deep analysis
        const result = await this.geminiService.analyzeWithGemini(
          context,
          analysisType,
          codeFiles,
        );
    
        // Check timeout
        const elapsedTime = Date.now() - startTime;
        if (elapsedTime > timeoutMs) {
          result.status = 'partial';
        }
    
        return result;
      } catch (error) {
        console.error('Deep reasoning failed:', error);
        return this.createErrorResult(error as Error, context);
      }
    }
  • Zod schema for validating input parameters to the escalate_analysis tool.
    const EscalateAnalysisSchema = z.object({
      claude_context: z.object({
        attempted_approaches: z.array(z.string()),
        partial_findings: z.array(z.any()),
        stuck_description: z.string(),
        code_scope: z.object({
          files: z.array(z.string()),
          entry_points: z.array(z.any()).optional(),
          service_names: z.array(z.string()).optional(),
        }),
      }),
      analysis_type: z.enum(['execution_trace', 'cross_system', 'performance', 'hypothesis_test']),
      depth_level: z.number().min(1).max(5),
      time_budget_seconds: z.number().default(60),
    });
  • src/index.ts:150-212 (registration)
    Registration of escalate_analysis tool in the ListToolsRequestSchema response, defining name, description, and JSON inputSchema mirroring the Zod schema.
    name: 'escalate_analysis',
    description: 'Hand off complex analysis to Gemini when Claude Code hits reasoning limits. Gemini will perform deep semantic analysis beyond syntactic patterns.',
    inputSchema: {
      type: 'object',
      properties: {
        claude_context: {
          type: 'object',
          properties: {
            attempted_approaches: {
              type: 'array',
              items: { type: 'string' },
              description: 'What Claude Code already tried',
            },
            partial_findings: {
              type: 'array',
              description: 'Any findings Claude Code discovered',
            },
            stuck_description: {
              type: 'string',
              description: 'Description of where Claude Code got stuck',
            },
            code_scope: {
              type: 'object',
              properties: {
                files: {
                  type: 'array',
                  items: { type: 'string' },
                  description: 'Files to analyze',
                },
                entry_points: {
                  type: 'array',
                  description: 'Specific functions/methods to start from',
                },
                service_names: {
                  type: 'array',
                  items: { type: 'string' },
                  description: 'Services involved in cross-system analysis',
                },
              },
              required: ['files'],
            },
          },
          required: ['attempted_approaches', 'partial_findings', 'stuck_description', 'code_scope'],
        },
        analysis_type: {
          type: 'string',
          enum: ['execution_trace', 'cross_system', 'performance', 'hypothesis_test'],
          description: 'Type of deep analysis to perform',
        },
        depth_level: {
          type: 'number',
          minimum: 1,
          maximum: 5,
          description: 'How deep to analyze (1=shallow, 5=very deep)',
        },
        time_budget_seconds: {
          type: 'number',
          default: 60,
          description: 'Maximum time for analysis',
        },
      },
      required: ['claude_context', 'analysis_type'],
    },
Behavior3/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It clearly indicates this is a hand-off operation to a different AI system (Gemini) for deeper analysis, which is useful context. However, it doesn't describe what happens during the hand-off, whether there are rate limits, authentication requirements, or what the expected output format might be.

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 perfectly concise with two sentences that each earn their place. The first sentence establishes the core purpose and trigger condition, while the second explains the value proposition. There's zero wasted language and it's front-loaded with the most important information.

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 complex tool with 4 parameters (including nested objects), no annotations, and no output schema, the description provides good high-level context but lacks details about behavioral characteristics, expected outputs, or error conditions. It adequately explains the 'why' but leaves gaps in operational details that would help an agent use it effectively.

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?

With 75% schema description coverage, the schema already documents most parameters well. The description doesn't add specific parameter semantics beyond implying 'complex analysis' context. It mentions 'deep semantic analysis' which aligns with the analysis_type parameter, but provides no additional details about parameter usage beyond what's in the schema descriptions.

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 clearly states the tool's purpose with specific verbs ('hand off complex analysis to Gemini') and resources ('when Claude Code hits reasoning limits'), and explicitly distinguishes it from sibling tools by mentioning Gemini's unique capability for 'deep semantic analysis beyond syntactic patterns' compared to Claude's limitations.

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

Usage Guidelines5/5

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

The description provides explicit guidance on when to use this tool ('when Claude Code hits reasoning limits') and what it does differently ('Gemini will perform deep semantic analysis beyond syntactic patterns'), clearly positioning it as an escalation path for complex analysis tasks that exceed Claude's capabilities.

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

Related 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/evalops/deep-code-reasoning-mcp'

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