Skip to main content
Glama
evalops

Deep Code Reasoning MCP Server

by evalops

hypothesis_test

Test specific theories about code behavior using Gemini AI. Analyze code scope, define hypotheses, and apply test approaches to validate assumptions in distributed systems and long-trace debugging.

Instructions

Use Gemini to test specific theories about code behavior

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
code_scopeYes
hypothesisYes
test_approachYes

Implementation Reference

  • src/index.ts:235-254 (registration)
    Registers the 'hypothesis_test' MCP tool with name, description, and JSON input schema defining hypothesis, code_scope (files), and test_approach.
    {
      name: 'hypothesis_test',
      description: 'Use Gemini to test specific theories about code behavior',
      inputSchema: {
        type: 'object',
        properties: {
          hypothesis: { type: 'string' },
          code_scope: {
            type: 'object',
            properties: {
              files: { type: 'array', items: { type: 'string' } },
              entry_points: { type: 'array' },
            },
            required: ['files'],
          },
          test_approach: { type: 'string' },
        },
        required: ['hypothesis', 'code_scope', 'test_approach'],
      },
    },
  • Zod schema for validating 'hypothesis_test' tool inputs: hypothesis (string), code_scope with files array, optional entry_points, and test_approach (string). Used in handler parsing.
    const HypothesisTestSchema = z.object({
      hypothesis: z.string(),
      code_scope: z.object({
        files: z.array(z.string()),
        entry_points: z.array(z.any()).optional(),
      }),
      test_approach: z.string(),
    });
  • MCP CallToolRequest handler for 'hypothesis_test': parses args with HypothesisTestSchema, validates/sanitizes inputs and file paths, delegates execution to deepReasoner.testHypothesis, returns JSON-formatted result as text content.
    case 'hypothesis_test': {
      const parsed = HypothesisTestSchema.parse(args);
    
      // Validate file paths
      const validatedFiles = InputValidator.validateFilePaths(parsed.code_scope.files);
      if (validatedFiles.length === 0) {
        throw new McpError(
          ErrorCode.InvalidParams,
          'No valid file paths provided',
        );
      }
    
      const result = await deepReasoner.testHypothesis(
        InputValidator.validateString(parsed.hypothesis, 2000),
        validatedFiles,
        InputValidator.validateString(parsed.test_approach, 1000),
      );
    
      return {
        content: [
          {
            type: 'text',
            text: JSON.stringify(result, null, 2),
          },
        ],
      };
    }
  • DeepCodeReasonerV2.testHypothesis method: reads code files from codeScope using SecureCodeReader, passes sanitized codeFiles/hypothesis/testApproach to GeminiService.testHypothesis for analysis, returns structured result.
    async testHypothesis(
      hypothesis: string,
      codeScope: string[],
      testApproach: string,
    ): Promise<{
      hypothesis: string;
      testApproach: string;
      analysis: string;
      filesAnalyzed: string[];
    }> {
      const codeFiles = new Map<string, string>();
    
      // Read all files in scope
      for (const file of codeScope) {
        try {
          const content = await this.codeReader.readFile(file);
          codeFiles.set(file, content);
        } catch (error) {
          console.error(`Failed to read ${file}:`, error);
        }
      }
    
      // Use Gemini to test hypothesis
      const analysis = await this.geminiService.testHypothesis(
        hypothesis,
        codeFiles,
        testApproach,
      );
    
      return {
        hypothesis,
        testApproach,
        analysis,
        filesAnalyzed: Array.from(codeFiles.keys()),
      };
    }
  • GeminiService.testHypothesis: builds secure, sanitized prompt with hypothesis, testApproach, and formatted code files; sends to Gemini-2.5-pro model; returns raw analysis text response.
      async testHypothesis(
        hypothesis: string,
        codeFiles: Map<string, string>,
        testApproach: string,
      ): Promise<string> {
        const systemInstructions = `Test the provided hypothesis about the code behavior.
    
    Systematically:
    1. Find evidence supporting the hypothesis
    2. Find evidence contradicting the hypothesis
    3. Consider edge cases and boundary conditions
    4. Evaluate the likelihood of the hypothesis being correct
    5. Suggest specific tests or checks to validate
    
    Be rigorous and evidence-based in your analysis.`;
    
        // Prepare sanitized data
        const codeFileData: string[] = [];
        for (const [file, content] of codeFiles) {
          codeFileData.push(PromptSanitizer.formatFileContent(file, content));
        }
    
        const userData = {
          'Hypothesis': PromptSanitizer.sanitizeString(hypothesis),
          'Test Approach': PromptSanitizer.sanitizeString(testApproach),
          'Code Files for Analysis': codeFileData.join('\n\n'),
        };
    
        const prompt = PromptSanitizer.createSafePrompt(systemInstructions, userData);
    
        const result = await this.model.generateContent(prompt);
        return result.response.text();
      }
Behavior2/5

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

No annotations are provided, so the description carries full burden. It mentions using Gemini but doesn't disclose behavioral traits such as whether this is a read-only analysis, if it modifies code, execution time, rate limits, or authentication needs. For a tool with 3 parameters and nested objects, this lack of detail is a significant gap.

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 sentence that gets straight to the point without unnecessary words. It's appropriately sized for a basic overview, though it could be more front-loaded with critical details given the lack of other documentation.

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 complexity (3 parameters with nested objects, 0% schema coverage, no output schema, and no annotations), the description is incomplete. It doesn't explain what the tool returns, how to interpret results, or provide enough context for effective use. This is inadequate for a tool that likely involves code analysis and hypothesis testing.

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 description coverage is 0%, so the description must compensate. It doesn't add any meaning beyond the schema, failing to explain parameters like 'code_scope', 'hypothesis', or 'test_approach'. This leaves agents guessing about what to provide, especially for nested structures like 'entry_points' and 'files'.

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 states the tool uses Gemini to test theories about code behavior, which provides a general purpose. However, it lacks specificity about what kind of testing (e.g., unit, integration, static analysis) and doesn't clearly distinguish from siblings like 'run_hypothesis_tournament' or 'trace_execution_path'. The phrase 'test specific theories' is somewhat vague compared to more precise alternatives.

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 is provided. The description implies it's for testing code theories with Gemini, but it doesn't specify contexts, prerequisites, or exclusions. Without comparison to siblings like 'run_hypothesis_tournament', agents might struggle to choose appropriately.

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