Skip to main content
Glama

openai_review

Review code changes using OpenAI Codex to get a non-interactive analysis of uncommitted modifications or changes against a base branch.

Instructions

Code review via Codex review (non-interactive). Reviews uncommitted changes or changes against a base branch.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
instructionsNoCustom review instructions (e.g., 'Focus on error handling and race conditions')
uncommittedNoReview uncommitted changes (default true)
baseNoReview against this base branch
commitNoReview a specific commit SHA
timeoutNoTimeout in seconds (default 120)
cwdNoWorking directory (git repo root)

Implementation Reference

  • Registration of the 'openai_review' tool with the MCP server, including its input schema (instructions, uncommitted, base, commit, timeout, cwd).
    mcpServer.registerTool(
      "openai_review",
      {
        description:
          "Code review via Codex review (non-interactive). Reviews uncommitted changes or changes against a base branch.",
        inputSchema: {
          instructions: z
            .string()
            .optional()
            .describe("Custom review instructions (e.g., 'Focus on error handling and race conditions')"),
          uncommitted: z
            .boolean()
            .default(true)
            .describe("Review uncommitted changes (default true)"),
          base: z
            .string()
            .optional()
            .describe("Review against this base branch"),
          commit: z
            .string()
            .optional()
            .describe("Review a specific commit SHA"),
          timeout: z
            .number()
            .default(120)
            .describe("Timeout in seconds (default 120)"),
          cwd: z
            .string()
            .optional()
            .describe("Working directory (git repo root)"),
        },
      },
      async ({ instructions, uncommitted = true, base, commit, timeout = 120, cwd }) => {
        const timeoutMs = timeout * 1000;
    
        try {
          log(`Review: uncommitted=${uncommitted}, base=${base || "none"}, timeout=${timeout}s`);
          const startTime = Date.now();
    
          const args = ["review", "--ephemeral"];
    
          if (uncommitted) {
            args.push("--uncommitted");
          }
          if (base) {
            args.push("--base", base);
          }
          if (commit) {
            args.push("--commit", commit);
          }
    
          if (instructions) {
            args.push("-");
          }
    
          const { stdout, stderr, exitCode } = await runCodex(args, {
            timeoutMs,
            stdin: instructions || undefined,
            cwd,
          });
    
          const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
          const combined = stdout + stderr;
    
          const error = detectError(combined);
          if (error) {
            log(`${error.errorType}: ${error.message}`);
            return {
              content: [{ type: "text", text: error.message }],
              isError: true,
            };
          }
    
          const response = combined.trim() || "No review output";
          log(`Review OK in ${elapsed}s (${response.length} chars)`);
    
          return {
            content: [{ type: "text", text: response }],
          };
        } catch (error) {
          const knownError = detectError(error.message);
          if (knownError) {
            log(`${knownError.errorType}: ${knownError.message}`);
            return {
              content: [{ type: "text", text: knownError.message }],
              isError: true,
            };
          }
    
          log(`Error: ${error.message}`);
          return {
            content: [{ type: "text", text: `Codex review error: ${error.message}` }],
            isError: true,
          };
        }
      }
    );
  • Input schema/validation for openai_review, defining parameters: instructions (optional string), uncommitted (boolean, default true), base (optional string), commit (optional string), timeout (number, default 120), cwd (optional string).
    inputSchema: {
      instructions: z
        .string()
        .optional()
        .describe("Custom review instructions (e.g., 'Focus on error handling and race conditions')"),
      uncommitted: z
        .boolean()
        .default(true)
        .describe("Review uncommitted changes (default true)"),
      base: z
        .string()
        .optional()
        .describe("Review against this base branch"),
      commit: z
        .string()
        .optional()
        .describe("Review a specific commit SHA"),
      timeout: z
        .number()
        .default(120)
        .describe("Timeout in seconds (default 120)"),
      cwd: z
        .string()
        .optional()
        .describe("Working directory (git repo root)"),
    },
  • Handler function for openai_review. Calls 'codex review --ephemeral' with optional flags (--uncommitted, --base, --commit). Passes custom instructions as stdin. Detects known errors (quota, auth, model) via detectError(). Returns review output or error message.
    async ({ instructions, uncommitted = true, base, commit, timeout = 120, cwd }) => {
      const timeoutMs = timeout * 1000;
    
      try {
        log(`Review: uncommitted=${uncommitted}, base=${base || "none"}, timeout=${timeout}s`);
        const startTime = Date.now();
    
        const args = ["review", "--ephemeral"];
    
        if (uncommitted) {
          args.push("--uncommitted");
        }
        if (base) {
          args.push("--base", base);
        }
        if (commit) {
          args.push("--commit", commit);
        }
    
        if (instructions) {
          args.push("-");
        }
    
        const { stdout, stderr, exitCode } = await runCodex(args, {
          timeoutMs,
          stdin: instructions || undefined,
          cwd,
        });
    
        const elapsed = ((Date.now() - startTime) / 1000).toFixed(1);
        const combined = stdout + stderr;
    
        const error = detectError(combined);
        if (error) {
          log(`${error.errorType}: ${error.message}`);
          return {
            content: [{ type: "text", text: error.message }],
            isError: true,
          };
        }
    
        const response = combined.trim() || "No review output";
        log(`Review OK in ${elapsed}s (${response.length} chars)`);
    
        return {
          content: [{ type: "text", text: response }],
        };
      } catch (error) {
        const knownError = detectError(error.message);
        if (knownError) {
          log(`${knownError.errorType}: ${knownError.message}`);
          return {
            content: [{ type: "text", text: knownError.message }],
            isError: true,
          };
        }
    
        log(`Error: ${error.message}`);
        return {
          content: [{ type: "text", text: `Codex review error: ${error.message}` }],
          isError: true,
        };
      }
    }
  • Helper function detectError() used by the openai_review handler to detect known error patterns (quota exceeded, model not supported, auth expired) in the output of the codex CLI.
    function detectError(output) {
      const combined = output.toLowerCase();
    
      if (combined.includes("usage limit") || combined.includes("hit your usage limit")) {
        const match = output.match(/try again at (.+?)[\.\n]/);
        const resetDate = match ? match[1] : "unknown";
        return {
          isError: true,
          errorType: "QUOTA_EXCEEDED",
          message: `Codex usage limit reached. Credits reset at: ${resetDate}. Use a fallback provider.`,
        };
      }
    
      if (combined.includes("not supported when using codex with a chatgpt account")) {
        return {
          isError: true,
          errorType: "MODEL_NOT_SUPPORTED",
          message: "This model is not available with ChatGPT Plus. Use the default model.",
        };
      }
    
      if (combined.includes("auth") && (combined.includes("expired") || combined.includes("login"))) {
        return {
          isError: true,
          errorType: "AUTH_EXPIRED",
          message: "Codex auth token expired. Run 'codex login' to re-authenticate.",
        };
      }
    
      return null;
    }
  • Helper function runCodex() that spawns the 'codex' CLI process with timeout and buffer limits, used by the openai_review handler to execute 'codex review' commands.
    function runCodex(args, options = {}) {
      const { timeoutMs = 90000, stdin: stdinData, cwd } = options;
    
      return new Promise((resolve, reject) => {
        const proc = spawn("codex", args, {
          cwd: cwd || process.cwd(),
          stdio: ["pipe", "pipe", "pipe"],
          env: {
            ...process.env,
            CODEX_HOME,
          },
        });
    
        let stdout = "";
        let stderr = "";
        let killed = false;
        let killTimer;
    
        const timer = setTimeout(() => {
          killed = true;
          proc.kill("SIGTERM");
          killTimer = setTimeout(() => {
            try { if (!proc.killed) proc.kill("SIGKILL"); } catch {}
          }, 5000);
        }, timeoutMs);
    
        proc.stdout.on("data", (data) => {
          stdout += data.toString();
          if (stdout.length > MAX_BUFFER) {
            killed = true;
            proc.kill("SIGTERM");
          }
        });
    
        proc.stderr.on("data", (data) => {
          stderr += data.toString();
          if (stderr.length > MAX_BUFFER) {
            killed = true;
            proc.kill("SIGTERM");
          }
        });
    
        if (stdinData) {
          proc.stdin.write(stdinData);
          proc.stdin.end();
        } else {
          proc.stdin.end();
        }
    
        proc.on("close", (exitCode) => {
          clearTimeout(timer);
          clearTimeout(killTimer);
          if (killed) {
            reject(new Error(`Process killed after ${timeoutMs / 1000}s timeout. Partial output: ${(stdout + stderr).slice(-200)}`));
          } else {
            resolve({ stdout, stderr, exitCode });
          }
        });
    
        proc.on("error", (err) => {
          clearTimeout(timer);
          clearTimeout(killTimer);
          reject(err);
        });
      });
    }
Behavior3/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 correctly notes that the tool is 'non-interactive' and reviews code changes, but does not disclose whether it is read-only, what side effects exist, or any authorization requirements. Some behavioral context is given but insufficient for full transparency.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single concise sentence that conveys the core functionality. It is front-loaded and efficient, though it could be slightly expanded to include output or usage guidance without losing brevity.

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?

The description adequately explains the tool's basic use but lacks details about return values (no output schema), how parameters interact (e.g., combining 'uncommitted' with 'base'), and any prerequisites. Given the complexity of 6 parameters and missing annotations, the description is somewhat incomplete.

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?

With 100% schema description coverage, the schema already documents each parameter. The description only adds the context of reviewing uncommitted changes or against a base branch, which partially maps to the 'uncommitted' and 'base' parameters. No additional parameter details are provided beyond the schema.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states it is a code review tool using Codex, non-interactive, and specifies the scope (uncommitted changes or against a base branch). This effectively distinguishes it from the sibling 'openai_chat' which is presumably for interactive chat.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines3/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description implies usage for automated code review, but does not explicitly state when not to use it or provide alternatives. The sibling name 'openai_chat' suggests an alternative for interactive tasks, but this is not stated.

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/spyrae/claude-concilium'

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