Skip to main content
Glama

review-code

Analyze code for bugs, security vulnerabilities, performance bottlenecks, and style inconsistencies to improve code quality and reliability.

Instructions

Review code for bugs, security issues, performance, or style problems

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
taskYesWhat to review (e.g., 'review pull request changes', 'check for security issues')
filesNoFile paths to review (optional)
focusNoReview focus areaall
providerNoAI provider to usegemini

Implementation Reference

  • src/server.ts:295-302 (registration)
    Registration of the 'review-code' tool in the MCP server, specifying title, description, input schema (ReviewCodeSchema), and handler function that delegates to AIToolHandlers.handleReviewCode
    server.registerTool("review-code", { title: "Review Code", description: "Review code for bugs, security issues, performance, or style problems", inputSchema: ReviewCodeSchema.shape, }, async (args) => { const aiHandlers = await getHandlers(); return await aiHandlers.handleReviewCode(args); });
  • Zod schema definition for 'review-code' tool input validation: task, optional files, focus (bugs/security/performance/style/all), provider
    const ReviewCodeSchema = z.object({ task: z.string().describe("What to review (e.g., 'review pull request changes', 'check for security issues')"), files: z.array(z.string()).optional().describe("File paths to review (optional)"), focus: z.enum(["bugs", "security", "performance", "style", "all"]).default("all").describe("Review focus area"), provider: z.enum(["openai", "gemini", "azure", "grok"]).optional().default("gemini").describe("AI provider to use"), });
  • Core handler implementation in AIToolHandlers class: selects provider, builds focus-specific system prompt for code review, generates AI response with low temperature, returns structured content and metadata
    async handleReviewCode(params: z.infer<typeof ReviewCodeSchema>) { // Use provided provider or get the preferred one (Azure if configured) const providerName = params.provider || (await this.providerManager.getPreferredProvider(['openai', 'gemini', 'azure', 'grok'])); const provider = await this.providerManager.getProvider(providerName); const focusPrompts = { bugs: "Focus on identifying potential bugs, logic errors, and runtime issues", security: "Focus on security vulnerabilities, input validation, and secure coding practices", performance: "Focus on performance bottlenecks, inefficient algorithms, and optimization opportunities", style: "Focus on code style, formatting, naming conventions, and readability", all: "Provide comprehensive code review covering bugs, security, performance, and style" }; const systemPrompt = `You are an expert code reviewer. Review the provided code thoroughly. ${focusPrompts[params.focus]} Provide detailed feedback on: - Issues found and their severity - Specific recommendations for improvement - Code quality assessment - Best practices and standards compliance Be constructive and specific in your review comments.`; const prompt = `Review the following: ${params.task}${params.files ? `\n\nFiles to review: ${params.files.join(", ")}` : ""}`; const response = await provider.generateText({ prompt, systemPrompt, temperature: 0.2, // Very low temperature for code review accuracy reasoningEffort: (providerName === "openai" || providerName === "azure" || providerName === "grok") ? "high" : undefined, useSearchGrounding: false, // No search needed for code review }); return { content: [ { type: "text", text: response.text, }, ], metadata: { provider: providerName, model: response.model, focus: params.focus, usage: response.usage, ...response.metadata, }, };

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/RealMikeChong/ultra-mcp'

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