Gemini Enterprise Custom MCP: "Reload custom actions" always fails with 401 - UI uses API key instead of OAuth token

Project: (PII Removed by Staff)
Collection: (PII Removed by Staff)
Region: global

ISSUE:
“Reload custom actions” always fails. Network inspection shows the
Console UI calls refreshDataConnectorTools with an API key instead
of an OAuth Bearer token:

POST discoveryengine.clients6.google.com/v1alpha/.../dataConnector:refreshDataConnectorTools?key=AIzaSyCI-zsRP85UVOi0DjtiCwWBwQ1djDy741g

Audit log shows auth:{} empty on every attempt despite:

User has Discovery Engine Admin role (granted:true in audit log)
OAuth flow completes successfully every time
Token issued successfully by MCP server
Connector state: ACTIVE, Action state: ACTIVE
MCP SERVER IS FULLY WORKING:

GET server.php → 200 server info
POST initialize → 200 valid response
POST tools/list → 200 returns 30+ tools
Bearer token auth → working
StreamableHTTP transport → supported
.well-known/oauth-authorization-server → valid JSON
The MCP server never receives a tools/list call from Google after
the OAuth token is issued. Google gets the token then stops.

EXPECTED: Tools load in Actions tab
ACTUAL: 401 UNAUTHENTICATED every time, no tools/list call made

This appears to be a bug in the Console UI JavaScript which uses
an API key (key=AIzaSy…) for refreshDataConnectorTools instead
of the authenticated user’s OAuth token.

I used different methods, custom python file and moodle mcp server but the actions keeps on failing to reload. OAuth flows is created and accepted in Gemini enterprise - Datastore connector but only the actions fails.

Anyone a idea of what the issue might be?

@kesimpson I’m getting the exact same problem now, ive configured mcp servers as data stores and i get the same error when reloading custom actions - any solutions ?

Following as I have the exact same issue with two separate MCP servers.

Following this too as we’re facing the exact same problem.

Previously setup Custom MCP server is still working, but trying to setup a new Custom MCP with the exact same configuration, underlying code, auth, … ends up failing to load the actions.

Can attest that I see the same pattern with the Console UI using an API key (key=…) for refreshDataConnectorTools instead of the authenticated user’s OAuth token (the oauth login popup shows up initially).

This is indeed a UI regression in the Google Cloud Console where refreshDataConnectorTools incorrectly passes an API key instead of the authenticated user’s OAuth Bearer token.
Fastest & Safest Workaround:
Bypass the Console UI and create/refresh the Custom MCP server via gcloud CLI or the REST API directly using your OAuth token:
Authorization: Bearer $(gcloud auth print-access-token)
Alternatively, you can copy the failed request from your browser’s DevTools (Network tab) as a cURL command, replace the key= query parameter with the OAuth Bearer header, and run it directly in your terminal.

Silly question from someone who has been hands off for way to long, how would I intercept that OAuth Bearer header if I wanted to try your second work around via cURL?

We’re hitting the same error. @Kion_Son Could you give us a little more details on the workaround? I copied the failed request as as a cURL command and replaced the Authorization header with Authorization: Bearer $(gcloud auth print-access-token), but I got a 400. I tried various permutations of the request (removing the key param, changing the value of the key param to be $(gcloud auth print-access-token)) but all resulted in some 4xx error.

The HTTP 400 (Bad Request) error usually happens when you copy a command directly from browser DevTools because it includes browser-specific headers (like Cookie, sec-fetch-*, origin, referer, or x-goog-authuser) that conflict with OAuth Bearer tokens, or because the request is targeting an internal console proxy endpoint rather than the public Google Cloud REST API.
Here is how to clean up the request so it works properly:

  1. Strip Out Unnecessary Browser Headers
    When executing the cURL request, strip out all browser headers and keep only Authorization and Content-Type:
    curl -X POST “https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/...”
    -H “Authorization: Bearer $(gcloud auth print-access-token)”
    -H “Content-Type: application/json”
    -d ‘{
    “your”: “payload_data”
    }’
    Completely remove the ?key=… parameter from the URL.
    Remove browser headers (Cookie, sec-fetch-*, x-goog-authuser, origin, referer, etc.).
    Windows (PowerShell) Note: Subshell commands like $(gcloud …) behave differently in PowerShell. Save the token to a variable first:
    $TOKEN = gcloud auth print-access-token
    curl.exe -X POST … -H “Authorization: Bearer $TOKEN”
  2. Verify Your Active Session
    Ensure gcloud is authenticated to the correct account and target project before running the command:
  3. Alternative: Use gcloud curl
    You can also let gcloud automatically append the correct OAuth headers and manage the token for you:
    gcloud curl --request POST
    –header “Content-Type: application/json”
    –data ‘{“your”: “payload”}’
    “https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/...”
    Give this a try by stripping the extra headers and let us know if you get a 200 OK or if the 400 error body provides a specific error code/message!

We hit this with our own custom MCP server (Onplana) in October 2026 and got it working, so here is what fixed it for us, in case it helps.

What we saw

  • “Reload custom actions” failed every time with “Internal error encountered” or “The service is currently unavailable”.
  • Our server logs showed Google completing the OAuth token exchange (POST to our token endpoint, 200), but never a single request to the MCP endpoint: no initialize, no tools/list.
  • Recreating the data connector did not help.
  • Google Cloud Support found this in the project logs for the connector: “Could not acquire the stored credentials for this data connector (upstream status: UNAUTHENTICATED). Re-authorize the connector, then retry.”

Fix 1: re-authenticate the connector, then reload

  1. Open the data store (Gemini Enterprise > your app > Connected data stores > your custom MCP connector).
  2. Click Re-authenticate at the top right and complete the OAuth sign-in for your MCP server.
  3. Wait for “Authentication credentials have been updated successfully” and give it a couple of minutes.
  4. Go to the Actions tab and click Reload custom actions.

It took us more than one re-authentication: an earlier one also completed a successful token exchange and the reload still failed. After a fresh one it loaded the tools straight away. So if the first try fails, re-authenticate again before anything else.

Fix 2: actions are enabled but the assistant says it has no connector

Once the actions loaded and we enabled them, the assistant still answered that no such connector or tool was configured, and our server again saw no calls. The missing step is per user. The admin’s Verify Auth and Re-authenticate do not carry over to chat users:

  1. Open the Gemini Enterprise web app.
  2. In the chat box, click the connector icon (next to Tools).
  3. Find your connector, click Authorize, and approve the sign-in pop-up for your MCP server.
  4. Switch the connector on in the same menu.

After that, the assistant called our tools (tools/list, then the tool calls) on the first prompt.

Things worth double-checking along the way

  • Org policy constraints/discoveryengine.managed.disableCustomMcpServerConnector must be set to not enforced on the project, or creating the data store fails.
  • The OAuth redirect URI registered with your MCP server must be exactly https://vertexaisearch.cloud.google.com/oauth-redirect.
  • Match “Use HTTP Basic Authentication” to your token endpoint. If your server expects the client secret in the request body (client_secret_post), turn it off. Turn PKCE on if your server supports it.
  • The connector only supports Streamable HTTP, not SSE.
  • Our server lists about 330 tools and the console imported 300. You can enable up to 100.

We wrote up the full setup for our server here, in case the steps are useful for yours:

(URL Removed by Staff)