Skip to content

OAuth not working with Gemini CLI #139

@dylanbr

Description

@dylanbr

Laravel Package Version

0.5.2

Laravel Version

12.47.0

PHP Version

8.4.17

Database Driver & Version

Postgres 17.7 on Linux aarch64 (Docker on Mac)

Description

I have tried using the OAuth flow with my laravel/mcp server using both Claude Code and Codex CLI, and this has worked without a problem. In both cases a browser window is opened and I am able to authorize the application.

When using Gemini CLI, however, I get the following error:

ℹ Starting OAuth authentication for MCP server 'mymcp'...
✕ Failed to authenticate with MCP server 'mymcp': Protected resource http://localhost:8000 does not match expected http://localhost:8000/mcp

The route for my MCP server is /mcp, so the issue is that when Gemini looks up the resource, it is getting the base URL instead.

In case it is relevant, I'm using Passport v13.4.3

Steps To Reproduce

You will need a laravel/mcp server running on /mcp (or similar), and Gemini CLI installed and authenticated.

Register the MCP server with Gemini:

gemini mcp add --transport http mymcp http://localhost:8000/mcp

Run gemini, and it will tell you that the MCP server needs authentication:

ℹ MCP server 'mymcp' requires authentication using: /mcp auth mymcp

Attempt to authenticate, and the error will be thrown:

> /mcp auth mymcp


ℹ Starting OAuth authentication for MCP server 'mymcp'...
✕ Failed to authenticate with MCP server 'mymcp': Protected resource http://localhost:8000 does not match expected http://localhost:8000/mcp

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions