Skip to content

Local CLI MCP endpoint (http://localhost:54321/mcp) fails OAuth: Kong has no routes for .well-known/oauth-* — 'no Route matched with those values' #257

@tristanbes

Description

@tristanbes

Bug report

Describe the bug

Following the official "Local Development" install docs (Platform: CLI → Server URL: http://localhost:54321/mcp), the Claude Code MCP client can never authenticate against the locally-bundled Supabase MCP server. The failure happens during OAuth discovery: Kong (the local stack's gateway on port 54321) has no routes for the .well-known/oauth-* metadata endpoints that the MCP server's auth flow depends on, so the client receives Kong's generic "no Route matched" 404 in place of an OAuth error response, and the SDK's Zod schema rejects the payload.

The MCP endpoint itself (/mcp) is reachable and responds, but the OAuth companion endpoints required to complete the authorization handshake are not proxied through Kong in the CLI's local stack. This makes the advertised http://localhost:54321/mcp URL effectively unusable from any MCP client that follows the standard OAuth 2.0 Protected Resource Metadata flow (RFC 9728).

Note: I'm filing here because this repo is where /docs/guides/getting-started/mcp + the "Platform: CLI" install instructions point users. The root cause likely lives in the Supabase CLI's Kong template (supabase/cli) — please feel free to transfer if appropriate.

To Reproduce

  1. Install Supabase CLI 2.90.0 and run supabase start in any project.
  2. Confirm the MCP URL is advertised by the CLI:
    $ supabase status
    ...
    │ MCP     │ http://127.0.0.1:54321/mcp │
    ...
    
  3. Follow the official local install instructions for Claude Code — add to .mcp.json:
    {
      "mcpServers": {
        "supabase_local": {
          "type": "http",
          "url": "http://127.0.0.1:54321/mcp"
        }
      }
    }
  4. In a terminal, run claude /mcp, select supabase_local, choose Authenticate.
  5. Observe the failure dialog:
    Supabase_local MCP Server
    Status: failed
    Auth:   not authenticated
    URL:    http://127.0.0.1:54321/mcp
    
    Error: SDK auth failed: HTTP 404: Invalid OAuth error response: ZodError: [
      {
        "expected": "string",
        "code": "invalid_type",
        "path": ["error"],
        "message": "Invalid input: expected string, received undefined"
      }
    ]. Raw body: {"message":"no Route matched with those values"}
    

Reproducible via curl

The /mcp endpoint itself answers (POST, with the required Accept: application/json, text/event-stream), proving the MCP service is reachable through Kong:

$ curl -s -o /dev/null -w "%{http_code}\n" \
    -X POST http://127.0.0.1:54321/mcp \
    -H "Content-Type: application/json" \
    -H "Accept: application/json, text/event-stream" \
    -d '{"jsonrpc":"2.0","id":1,"method":"initialize","params":{"protocolVersion":"2025-06-18","capabilities":{},"clientInfo":{"name":"curl","version":"0"}}}'
400

But the OAuth discovery endpoints the client must fetch next are not routed:

$ curl -s http://127.0.0.1:54321/.well-known/oauth-protected-resource
{"message":"no Route matched with those values"}

$ curl -s http://127.0.0.1:54321/.well-known/oauth-authorization-server
404 page not found

The {"message":"no Route matched with those values"} payload is Kong's default no-route response, which is exactly what shows up in the Raw body: of the Claude Code error above — confirming the OAuth metadata fetch is the step that fails.

Running Docker containers in the local stack (no dedicated MCP container — the service is embedded in Studio, and hitting /mcp/.well-known/oauth-protected-resource actually falls through to Studio's Next.js 404 page, X-Powered-By: Next.js):

supabase_db_*        postgres:17.6.1.025
supabase_studio_*    studio:2026.01.27-sha-2a37755
supabase_pg_meta_*   postgres-meta:v0.95.2
supabase_rest_*      postgrest:v13.0.5
supabase_realtime_*  realtime:v2.73.2
supabase_inbucket_*  mailpit:v1.22.3
supabase_auth_*      gotrue:v2.182.1
supabase_kong_*      kong:2.8.1

Expected behavior

Following the documented Platform: CLI install path should yield a working, authenticated MCP connection. Concretely, the OAuth discovery endpoints advertised by the local MCP server (Protected Resource Metadata, Authorization Server Metadata, and the token/registration URLs they in turn point to) must all be reachable through Kong on port 54321, so that an MCP client can complete the standard RFC 9728 + OAuth 2.0 Dynamic Client Registration flow.

Either of the following would resolve this:

  • Update the local Kong template shipped by the CLI to proxy the .well-known/oauth-* paths (and any downstream authorization/token/registration endpoints) to the MCP/Studio upstream.
  • Have the local MCP server advertise OAuth URLs that resolve to endpoints Kong already routes (or a port/host that doesn't require going through Kong).
  • Alternatively, ship a no-auth mode for the local CLI MCP (see related Local-only mode with no access token #22), since OAuth on a loopback-only dev stack is mostly ceremony anyway.

Screenshots

  • Official install doc page (Platform: CLI, Client: Claude Code) showing http://localhost:54321/mcp as the recommended URL.
  • Claude Code auth dialog showing the ZodError / Raw body: {"message":"no Route matched with those values"} failure.

(I'll add them via the web UI after the issue is created.)

System information

  • OS: macOS 26.4.1 (Darwin 25.4.0)
  • Supabase CLI: 2.90.0
  • Kong image: public.ecr.aws/supabase/kong:2.8.1
  • Studio image: public.ecr.aws/supabase/studio:2026.01.27-sha-2a37755
  • Node.js: v24.14.0
  • MCP client: Claude Code (HTTP transport)

Additional context

  • The hosted MCP at https://mcp.supabase.com/mcp?project_ref=... works fine from the same machine / same client — the break is specific to the local CLI stack.
  • Working workaround for anyone hitting this in the meantime: swap the HTTP transport for a stdio server pointed straight at the local Postgres, e.g.
    "supabase_local": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-postgres",
        "postgresql://postgres:postgres@127.0.0.1:54322/postgres"
      ]
    }
    This bypasses Kong and OAuth entirely and restores read-only SQL access against the local DB.
  • Related existing issues: Local-only mode with no access token #22 (local-only mode with no access token), Functionality with Self Hosted Supabase Instances (non-local[?]). #69 (self-hosted functionality), Claude Desktop MCP Supabase - not working #5 (Claude Desktop MCP Supabase not working) — this one is narrower and specifically about the CLI-advertised local HTTP MCP + OAuth discovery gap.

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