Skip to main content
Glama
emmron
by emmron

mcp__gemini__codereview_expert

Analyze code for security, performance, and maintainability issues, providing actionable fixes, risk scoring, and automated suggestions to improve code quality.

Instructions

Multi-perspective code review with actionable fixes, risk scoring, and automated suggestions

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
codeYesCode to review
contextNoCode context or description
generate_fixesNoGenerate automated fix suggestions
languageNoProgramming languagejavascript
review_focusNoFocus areas

Implementation Reference

  • The core handler function for the 'mcp__gemini__codereview_expert' tool. It performs multi-perspective code review (security, performance, etc.) by calling the AI client for each focus area, generates a comprehensive summary, and formats the results.
        handler: async (args) => {
          const { code, language = 'javascript', review_focus = ['security', 'performance', 'maintainability'], context = '', generate_fixes = true } = args;
          validateString(code, 'code', 20000);
          
          const timer = performanceMonitor.startTimer('codereview_expert');
          
          const focusAreas = Array.isArray(review_focus) ? review_focus : [review_focus];
          
          // Multi-perspective review
          const reviewPrompts = {
            security: `Security Review - Focus on vulnerabilities, injection risks, authentication, authorization, data validation:`,
            performance: `Performance Review - Focus on efficiency, optimization opportunities, resource usage, algorithms:`,
            maintainability: `Maintainability Review - Focus on code clarity, structure, documentation, technical debt:`,
            architecture: `Architecture Review - Focus on design patterns, separation of concerns, scalability:`,
            testing: `Testing Review - Focus on testability, coverage opportunities, test quality:`
          };
          
          const reviews = {};
          
          for (const focus of focusAreas) {
            if (reviewPrompts[focus]) {
              const reviewPrompt = `${reviewPrompts[focus]}
    
    ${context ? `Context: ${context}\n\n` : ''}Code to review:
    
    \`\`\`${language}
    ${code}
    \`\`\`
    
    Provide:
    1. Overall ${focus} assessment (1-10 scale)
    2. Specific issues found with line references
    3. Risk level for each issue (Critical/High/Medium/Low)
    4. ${generate_fixes ? 'Suggested fixes with code examples' : 'Improvement recommendations'}
    5. Best practices violations
    6. Positive aspects worth noting
    
    Be thorough and specific.`;
    
              reviews[focus] = await aiClient.call(reviewPrompt, 'review');
            }
          }
          
          // Generate comprehensive summary
          const summaryPrompt = `Create a comprehensive code review summary from these expert reviews:
    
    ${Object.entries(reviews).map(([focus, review]) => `**${focus.toUpperCase()} REVIEW:**\n${review}\n\n---\n`).join('')}
    
    Provide:
    1. **Executive Summary** with overall quality score (1-10)
    2. **Critical Issues** requiring immediate attention
    3. **Risk Assessment** with prioritized action items
    4. **Quality Metrics** breakdown by category
    5. **Improvement Roadmap** with suggested order of fixes
    6. **Compliance Check** against ${language} best practices
    
    ${generate_fixes ? 'Include specific code examples for top 3 fixes.' : ''}`;
    
          const summary = await aiClient.call(summaryPrompt, 'analysis', { maxTokens: 3000 });
          
          timer.end();
          
          return `๐Ÿ” **Expert Code Review** (${language})
    
    **Focus Areas**: ${focusAreas.join(', ')}
    **Auto-fixes**: ${generate_fixes ? 'Enabled' : 'Disabled'}
    
    ${summary}
    
    ---
    
    **Detailed Reviews by Focus Area:**
    
    ${Object.entries(reviews).map(([focus, review]) => `### ${focus.toUpperCase()}
    ${review}`).join('\n\n---\n\n')}`;
        }
  • Input schema defining parameters for the code review tool: code (required), language, review_focus, context, generate_fixes.
    parameters: {
      code: { type: 'string', description: 'Code to review', required: true },
      language: { type: 'string', description: 'Programming language', default: 'javascript' },
      review_focus: { type: 'array', description: 'Focus areas', default: ['security', 'performance', 'maintainability'] },
      context: { type: 'string', description: 'Code context or description' },
      generate_fixes: { type: 'boolean', description: 'Generate automated fix suggestions', default: true }
  • Tool definition object in enhancedTools export, which includes name, description, parameters (schema), and handler. This object is used for registration.
      'mcp__gemini__codereview_expert': {
        description: 'Multi-perspective code review with actionable fixes, risk scoring, and automated suggestions',
        parameters: {
          code: { type: 'string', description: 'Code to review', required: true },
          language: { type: 'string', description: 'Programming language', default: 'javascript' },
          review_focus: { type: 'array', description: 'Focus areas', default: ['security', 'performance', 'maintainability'] },
          context: { type: 'string', description: 'Code context or description' },
          generate_fixes: { type: 'boolean', description: 'Generate automated fix suggestions', default: true }
        },
        handler: async (args) => {
          const { code, language = 'javascript', review_focus = ['security', 'performance', 'maintainability'], context = '', generate_fixes = true } = args;
          validateString(code, 'code', 20000);
          
          const timer = performanceMonitor.startTimer('codereview_expert');
          
          const focusAreas = Array.isArray(review_focus) ? review_focus : [review_focus];
          
          // Multi-perspective review
          const reviewPrompts = {
            security: `Security Review - Focus on vulnerabilities, injection risks, authentication, authorization, data validation:`,
            performance: `Performance Review - Focus on efficiency, optimization opportunities, resource usage, algorithms:`,
            maintainability: `Maintainability Review - Focus on code clarity, structure, documentation, technical debt:`,
            architecture: `Architecture Review - Focus on design patterns, separation of concerns, scalability:`,
            testing: `Testing Review - Focus on testability, coverage opportunities, test quality:`
          };
          
          const reviews = {};
          
          for (const focus of focusAreas) {
            if (reviewPrompts[focus]) {
              const reviewPrompt = `${reviewPrompts[focus]}
    
    ${context ? `Context: ${context}\n\n` : ''}Code to review:
    
    \`\`\`${language}
    ${code}
    \`\`\`
    
    Provide:
    1. Overall ${focus} assessment (1-10 scale)
    2. Specific issues found with line references
    3. Risk level for each issue (Critical/High/Medium/Low)
    4. ${generate_fixes ? 'Suggested fixes with code examples' : 'Improvement recommendations'}
    5. Best practices violations
    6. Positive aspects worth noting
    
    Be thorough and specific.`;
    
              reviews[focus] = await aiClient.call(reviewPrompt, 'review');
            }
          }
          
          // Generate comprehensive summary
          const summaryPrompt = `Create a comprehensive code review summary from these expert reviews:
    
    ${Object.entries(reviews).map(([focus, review]) => `**${focus.toUpperCase()} REVIEW:**\n${review}\n\n---\n`).join('')}
    
    Provide:
    1. **Executive Summary** with overall quality score (1-10)
    2. **Critical Issues** requiring immediate attention
    3. **Risk Assessment** with prioritized action items
    4. **Quality Metrics** breakdown by category
    5. **Improvement Roadmap** with suggested order of fixes
    6. **Compliance Check** against ${language} best practices
    
    ${generate_fixes ? 'Include specific code examples for top 3 fixes.' : ''}`;
    
          const summary = await aiClient.call(summaryPrompt, 'analysis', { maxTokens: 3000 });
          
          timer.end();
          
          return `๐Ÿ” **Expert Code Review** (${language})
    
    **Focus Areas**: ${focusAreas.join(', ')}
    **Auto-fixes**: ${generate_fixes ? 'Enabled' : 'Disabled'}
    
    ${summary}
    
    ---
    
    **Detailed Reviews by Focus Area:**
    
    ${Object.entries(reviews).map(([focus, review]) => `### ${focus.toUpperCase()}
    ${review}`).join('\n\n---\n\n')}`;
        }
      },
  • Registration call that registers all tools from enhancedTools module, including 'mcp__gemini__codereview_expert', by iterating over the object and calling registerTool for each.
    this.registerToolsFromModule(enhancedTools);
Behavior2/5

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

No annotations are provided, so the description carries the full burden. It mentions 'actionable fixes, risk scoring, and automated suggestions,' which gives some behavioral context, but lacks details on permissions, rate limits, output format, or whether it modifies code. For a tool with no annotations, this is insufficient to fully understand its behavior.

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 a single, efficient sentence that front-loads key information: 'Multi-perspective code review with actionable fixes, risk scoring, and automated suggestions.' It's appropriately sized with zero wasted words, making it easy to scan and understand quickly.

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?

Given the complexity of a code review tool with 5 parameters and no output schema, the description is somewhat complete but has gaps. It outlines the tool's purpose and features, but without annotations or output schema, it doesn't fully cover behavioral aspects or return values. It's minimally adequate but could benefit from more context.

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. The description doesn't add any meaning beyond what's in the schemaโ€”it doesn't explain how parameters like 'review_focus' or 'generate_fixes' affect the review process. Baseline 3 is appropriate when the schema handles parameter documentation.

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 tool's purpose as 'Multi-perspective code review with actionable fixes, risk scoring, and automated suggestions.' It specifies the verb ('code review') and key features, though it doesn't explicitly distinguish it from sibling tools like 'mcp__gemini__code_analyze' or 'mcp__gemini__quality_guardian' that might have overlapping functionality.

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. With many sibling tools like 'mcp__gemini__code_analyze' and 'mcp__gemini__quality_guardian' that might handle code analysis, there's no indication of when this specific code review tool is preferred or what distinguishes it from other options.

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/emmron/gemini-mcp'

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