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) );

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