Skip to main content
Glama

review_code

Analyze code changes to identify issues in security, performance, style, or logic. Provide actionable feedback on Git diffs to improve code quality during development.

Instructions

Review code changes and provide feedback

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
diffYesGit diff or code changes to review
contextNoContext about the changes
reviewTypeNoType of review to performall

Implementation Reference

  • The ReviewCodeTool class extends BaseAITool and implements the core logic for code review, including prompts and focus areas. The reviewCode function is the entry point that executes the tool.
    class ReviewCodeTool extends BaseAITool<CodeReviewOptions> {
      private readonly reviewFocus = {
        security: 'Security vulnerabilities, input validation, authentication/authorization issues, data exposure risks',
        performance: 'Performance bottlenecks, inefficient algorithms, memory leaks, unnecessary computations',
        style: 'Code style consistency, naming conventions, code organization, readability',
        logic: 'Business logic errors, edge cases, error handling, correctness of implementation',
        all: 'All aspects including security, performance, code style, and logic',
      };
    
      protected getActionName(): string {
        return 'reviewing code';
      }
    
      protected getSystemPrompt(args: CodeReviewOptions): string {
        const { reviewType = 'all' } = args;
        return `You are an expert code reviewer. Review the provided code changes critically and provide actionable feedback.
    Focus on: ${this.reviewFocus[reviewType]}
    
    Provide:
    - Specific line-by-line feedback where issues are found
    - Severity level for each issue (critical, major, minor)
    - Concrete suggestions for improvement
    - Recognition of good practices when present
    
    Be constructive but thorough in identifying potential issues.`;
      }
    
      protected getUserPrompt(args: CodeReviewOptions): string {
        const { diff, context } = args;
        return `Review these code changes:\n\n${diff}${context ? `\n\nContext: ${context}` : ''}`;
      }
    }
    
    const tool = new ReviewCodeTool();
    
    export async function reviewCode(args: CodeReviewOptions): Promise<CallToolResult> {
      return tool.execute(args);
    }
  • TypeScript interface defining the input options for the review_code tool, matching the Zod schema in registration.
    export interface CodeReviewOptions {
      diff: string;
      context?: string;
      reviewType?: 'security' | 'performance' | 'style' | 'logic' | 'all';
    }
  • src/index.ts:57-68 (registration)
    Registers the 'review_code' tool with the MCP server, providing description, Zod inputSchema for validation, and the handler function.
    server.registerTool(
      'review_code',
      {
        description: 'Review code changes and provide feedback',
        inputSchema: {
          diff: z.string().describe('Git diff or code changes to review'),
          context: z.string().optional().describe('Context about the changes'),
          reviewType: z.enum(['security', 'performance', 'style', 'logic', 'all']).optional().default('all').describe('Type of review to perform'),
        },
      },
      async (args) => reviewCode(args)
    );
Behavior2/5

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

With no annotations provided, the description carries full burden for behavioral disclosure. It states the tool reviews code and provides feedback, but doesn't describe what the feedback looks like (e.g., format, detail level), whether it's automated or human-like, if it has limitations (e.g., language support), or any side effects. This is inadequate for a tool with 3 parameters and no output schema.

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 extremely concise (6 words) and front-loaded with the core purpose. Every word earns its place with no redundancy or unnecessary elaboration.

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 3 parameters, no annotations, and no output schema, the description is incomplete. It doesn't explain what the tool returns (feedback format), behavioral traits, or usage context. For a code review tool that likely produces complex output, this leaves significant gaps for the agent.

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 parameters thoroughly. The description adds no additional meaning about parameters beyond what's in the schema (e.g., it doesn't explain what 'all' means for reviewType or how diff and context interact). Baseline 3 is appropriate when schema does the heavy lifting.

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?

The description clearly states the action ('review code changes') and outcome ('provide feedback'), which is specific and actionable. However, it doesn't distinguish this tool from potential siblings like 'run_linter' or 'review_spec', which might also involve code review aspects.

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?

The description provides no guidance on when to use this tool versus alternatives like 'run_linter' or 'review_spec'. It doesn't mention prerequisites, context, or exclusions, leaving the agent to guess based on tool names alone.

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/jaggederest/mcp_reviewer'

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