Skip to content

Command prompts reference incorrect MCP tool names, causing FatalTurnLimitedError #510

@kweinmeister

Description

@kweinmeister

TL;DR

The bundled command prompts (gemini-review.toml, gemini-invoke.toml, gemini-plan-execute.toml) reference GitHub MCP tools using a naming convention (e.g., pull_request_read.get, issue_read.get_comments) that doesn't match the mcp_{server}_{tool} naming convention used by the Gemini CLI's tool registry. This causes the model to exhaust its turn budget searching for non-existent tools, resulting in FatalTurnLimitedError (exit code 53).

Expected behavior

When using the bundled /gemini-review command with a GitHub MCP server configured, the model should successfully invoke the MCP tools referenced in the prompt (read PR diff, create pending review, add review comments, submit review) and complete the code review within the turn budget.

Observed behavior

The model reads the prompt instructions, attempts to call tools like pull_request_read.get — which doesn't exist in the tool registry — then tries various naming variations (github:pull_request_read, github_pull_request_read, etc.), all of which fail with "tool not found." This loop repeats until the turn budget is exhausted:

FatalTurnLimitedError: Agent exceeded the maximum number of turns (50)

The gemini_response output is empty. No review is ever posted.

Root cause

The Gemini CLI registers MCP tools using the format mcp_{serverName}_{toolName} (see mcp-tool.ts formatMcpToolName()). For a server named github, the tool pull_request_read becomes mcp_github_pull_request_read.

The bundled prompts (shipped in the action's .github/commands/ and copied to the workspace at action.yml line 213) reference tool names that don't match this format:

Prompt reference (doesn't exist) Actual registered name Source file
pull_request_read.get mcp_github_pull_request_read (with method: "get" param) gemini-review.toml:37
pull_request_read.get_files mcp_github_pull_request_read (with method: "get_files" param) gemini-review.toml:38
pull_request_read.get_diff mcp_github_pull_request_read (with method: "get_diff" param) gemini-review.toml:39, :53; gemini-invoke.toml:53; gemini-plan-execute.toml:51
issue_read (bare) mcp_github_issue_read gemini-invoke.toml:53; gemini-plan-execute.toml:51, :59
issue_read.get_comments mcp_github_issue_read (with method: "get_comments" param) gemini-plan-execute.toml:51, :59
get_file_contents (bare) mcp_github_get_file_contents gemini-invoke.toml:53; gemini-plan-execute.toml:51
create_pending_pull_request_review mcp_github_pull_request_review_write (with method: "create" param) gemini-review.toml:134
add_comment_to_pending_review (bare) mcp_github_add_comment_to_pending_review gemini-review.toml:136
submit_pending_pull_request_review mcp_github_pull_request_review_write (with method: "submit_pending" param) gemini-review.toml:154

Additionally, create_pending_pull_request_review and submit_pending_pull_request_review don't exist as standalone tools in github-mcp-server. They are methods on the consolidated pull_request_review_write tool (see pullrequests.go:1525). The MCP server's own toolset_instructions.go documents the correct workflow:

Always use pull_request_review_write with method create to create a pending review, then add_comment_to_pending_review to add comments, and finally pull_request_review_write with method submit_pending to submit the review.

Action YAML

name: 'Gemini Review'

on:
  pull_request:
    types: [opened, synchronize]

jobs:
  review:
    runs-on: 'ubuntu-latest'
    permissions:
      contents: 'read'
      pull-requests: 'write'
    steps:
      - uses: 'actions/checkout@v4'

      - uses: 'google-github-actions/run-gemini-cli@v0'
        env:
          GITHUB_TOKEN: '${{ github.token }}'
          PULL_REQUEST_NUMBER: '${{ github.event.pull_request.number }}'
          REPOSITORY: '${{ github.repository }}'
        with:
          gemini_api_key: '${{ secrets.GEMINI_API_KEY }}'
          settings: |-
            {
              "mcpServers": {
                "github": {
                  "command": "docker",
                  "args": [
                    "run", "-i", "--rm",
                    "-e", "GITHUB_PERSONAL_ACCESS_TOKEN",
                    "ghcr.io/github/github-mcp-server"
                  ],
                  "env": {
                    "GITHUB_PERSONAL_ACCESS_TOKEN": "${{ github.token }}"
                  }
                }
              }
            }
          prompt: '/gemini-review'

Log output

Key log excerpts:


YOLO mode is enabled. All tool calls will be automatically approved.
Prompt with name "AssignCodingAgent" is already registered. Renaming to "github_AssignCodingAgent".


(MCP tool discovery completes, tools are registered with `mcp_github_*` names, but the model then attempts to call `pull_request_read.get` which doesn't exist)

Final error:

Error: Gemini CLI execution failed: FatalTurnLimitedError: Agent exceeded the maximum number of turns (50)


`gemini_response` output is empty (`''`).

Additional information

Additional information

  • Gemini CLI version: 0.39.1
  • GitHub MCP Server version: v1.0.3

Affected files in the action (.github/commands/):

  1. gemini-review.toml — Lines 37-39, 53, 134, 136, 154
  2. gemini-invoke.toml — Line 53
  3. gemini-plan-execute.toml — Lines 51, 59

Suggested fix

Update the bundled command files to use the fully-qualified tool names that match the Gemini CLI's tool registry. For example in gemini-review.toml:

-- Use `pull_request_read.get` to get the title, body, and metadata about the pull request.
-- Use `pull_request_read.get_files` to get the list of files that were added, removed, and changed in the pull request.
-- Use `pull_request_read.get_diff` to get the diff from the pull request.
+- Use `mcp_github_pull_request_read` with method "get" to get the title, body, and metadata about the pull request.
+- Use `mcp_github_pull_request_read` with method "get_files" to get the list of files that were added, removed, and changed in the pull request.
+- Use `mcp_github_pull_request_read` with method "get_diff" to get the diff from the pull request.

And for the review submission flow:

-1. **Create Pending Review:** Call `create_pending_pull_request_review`.
-2. **Add Comments and Suggestions:** For each formulated review comment, call `add_comment_to_pending_review`.
-3. **Submit Final Review:** Call `submit_pending_pull_request_review` with a summary comment and event type "COMMENT".
+1. **Create Pending Review:** Call `mcp_github_pull_request_review_write` with method "create".
+2. **Add Comments and Suggestions:** For each formulated review comment, call `mcp_github_add_comment_to_pending_review`.
+3. **Submit Final Review:** Call `mcp_github_pull_request_review_write` with method "submit_pending", a summary comment, and event type "COMMENT".

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions