review_code
Analyze code quality by submitting code for automated review from Codex and Gemini CLIs. Get feedback on security, performance, and best practices to improve your implementation.
Instructions
Request a code review from Codex and Gemini CLIs. Provide code directly as a string. Returns feedback from both reviewers for Claude to consider.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| code | Yes | The code to review | |
| context | No | Additional context about the code (optional) | |
| reviewers | No | Which reviewers to use (default: both) |
Implementation Reference
- src/index.ts:271-288 (handler)The main handler function for the "review_code" MCP tool. It validates input arguments, ensures code is provided, invokes the shared review performance logic, and returns formatted review feedback.private async handleReviewCode(args: CodeReviewRequest) { const { code, context, reviewers = ["both"] } = args; if (!code) { throw new Error("Code is required"); } const reviews = await this.performReview(code, context, reviewers); return { content: [ { type: "text", text: this.formatReviews(reviews), }, ], }; }
- src/index.ts:191-212 (schema)JSON Schema defining the input parameters for the "review_code" tool, including required 'code' field and optional 'context' and 'reviewers'.inputSchema: { type: "object", properties: { code: { type: "string", description: "The code to review", }, context: { type: "string", description: "Additional context about the code (optional)", }, reviewers: { type: "array", items: { type: "string", enum: ["codex", "gemini", "both"], }, description: "Which reviewers to use (default: both)", }, }, required: ["code"], },
- src/index.ts:187-213 (registration)Tool registration in the getTools() method, defining name, description, and inputSchema for the MCP tools list.{ name: "review_code", description: "Request a code review from Codex and Gemini CLIs. Provide code directly as a string. Returns feedback from both reviewers for Claude to consider.", inputSchema: { type: "object", properties: { code: { type: "string", description: "The code to review", }, context: { type: "string", description: "Additional context about the code (optional)", }, reviewers: { type: "array", items: { type: "string", enum: ["codex", "gemini", "both"], }, description: "Which reviewers to use (default: both)", }, }, required: ["code"], }, },
- src/index.ts:107-108 (registration)Dispatch case in the CallToolRequestSchema handler that routes "review_code" calls to the specific handleReviewCode method.case "review_code": return await this.handleReviewCode(args as CodeReviewRequest);
- src/index.ts:383-426 (helper)Core helper method that performs the actual code review by calling available CLI tools (Codex/OpenAI and/or Gemini), validates responses, and collects feedback from selected reviewers.private async performReview( code: string, context: string | undefined, reviewers: string[] ): Promise<Record<string, string>> { const reviews: Record<string, string> = {}; const useCodex = (reviewers.includes("codex") || reviewers.includes("both")) && this.cliAvailability.codex; const useGemini = (reviewers.includes("gemini") || reviewers.includes("both")) && this.cliAvailability.gemini; // If no CLIs are available, provide a helpful message if (!this.cliAvailability.codex && !this.cliAvailability.gemini) { reviews.info = "⚠️ No review CLIs are currently available. Please install OpenAI CLI and/or Gemini CLI to enable code reviews.\n\n" + "Check status with the check_cli_status tool."; return reviews; } const reviewPrompt = this.buildReviewPrompt(code, context); const reviewPromises: Promise<void>[] = []; if (useCodex) { reviewPromises.push( this.getCodexReview(reviewPrompt).then((review) => { reviews.codex = review; }) ); } else if (reviewers.includes("codex")) { reviews.codex = "⚠️ Codex review requested but OpenAI CLI is not available."; } if (useGemini) { reviewPromises.push( this.getGeminiReview(reviewPrompt).then((review) => { reviews.gemini = review; }) ); } else if (reviewers.includes("gemini")) { reviews.gemini = "⚠️ Gemini review requested but Gemini CLI is not available."; } await Promise.all(reviewPromises); return reviews; }