Skip to main content

Prerequisites

Before you can configure and use Gemini Enterprise with Connect AI, you must first do the following:
  • Connect a data source to your Connect AI account. See Sources for more information.
  • Have a Gemini Enterprise account (trial available).
  • Have a Google Cloud project with billing enabled.
  • Install and configure the Google Cloud CLI.
  • Install Python 3.12+ and the UV package manager.
  • Install google-adk>=1.31.1.
  • Have a Google Cloud Storage bucket available for ADK deployment staging.
Use google-adk>=1.31.1. Versions prior to 1.31.1 have a known bug where a bound token mechanism interferes with McpToolset’s outbound HTTP requests, preventing the header_provider auth token from being passed correctly to the MCP server.
ADK deployment has a known issue on Windows. Use Ubuntu via WSL (Windows Subsystem for Linux) on Windows machines. Mac and Linux environments work directly.

Create an OAuth App in CData Connect AI

Gemini Enterprise uses OAuth 2.0 Authorization Code with PKCE to authenticate users against the CData Connect AI MCP Server. This requires a user-based OAuth App in your CData Connect AI account.
1
Click the gear icon in the top-right corner of Connect AI to open Settings.
2
Navigate to OAuth Apps and click + Create App. The Create OAuth App dialog appears.
3
Enter the following settings:
Creating an OAuth App in CData Connect AI
4
Click Confirm. CData Connect AI generates a Client ID and Client Secret.
5
Copy both the Client ID and Client Secret. You will need them when adding the agent to Gemini Enterprise.
Client ID and Client Secret

Set Up the Google CLI and ADK Environment

1
Install the Google Cloud CLI and authenticate:
gcloud auth login
gcloud config set project YOUR_PROJECT_ID
gcloud auth application-default login
2
Enable the Vertex AI API and Cloud Resource Manager API:
gcloud services enable aiplatform.googleapis.com
gcloud services enable cloudresourcemanager.googleapis.com
3
Create a Google Cloud Storage bucket for ADK staging (if you don’t already have one):
gcloud storage buckets create gs://YOUR_BUCKET_NAME --location=us-central1
4
Create a project folder, initialize a Python environment with UV, and install the ADK:
mkdir agents
cd agents
uv init
uv sync
source .venv/bin/activate
uv add google-adk>=1.31.1 python-dotenv
5
Verify the ADK installation:
adk --version

Develop the ADK Agent

The agent uses McpToolset with StreamableHTTPConnectionParams and a header_provider to connect to the CData Connect AI MCP endpoint. The header_provider retrieves the per-session Bearer token from the ReadonlyContext, injected by Gemini Enterprise after the OAuth flow, so no credentials are stored in the agent code.

Folder Structure

agents/
+-- connect_ai_oauth/
    +-- __init__.py
    +-- .env
    +-- agent.py
From the agents/ directory, create the agent subdirectory and navigate into it:
mkdir connect_ai_oauth
cd connect_ai_oauth

agent.py

import os
from google.adk.agents import Agent
from google.adk.tools.mcp_tool.mcp_toolset import McpToolset
from google.adk.tools.mcp_tool.mcp_session_manager import StreamableHTTPConnectionParams
from google.adk.agents.readonly_context import ReadonlyContext
from dotenv import load_dotenv

load_dotenv()

AUTH_ID = os.getenv("CONNECT_AI_AUTHID", "")
MCP_SERVER_URL = os.getenv('MCP_SERVER_URL', 'https://mcp.cloud.cdata.com/mcp')

def get_auth_header(context: ReadonlyContext) -> dict:
    access_token = context.state.get(AUTH_ID, "")
    return {"Authorization": f"Bearer {access_token}"}

root_agent = Agent(
    name="connect_ai_oauth",
    model="gemini-2.5-flash",
    description="An agent that can access data via CData Connect AI Remote MCP.",
    instruction="You are a data assistant with access to live enterprise data via CData Connect AI. Use your available tools directly to answer user questions. Do not write or execute code. When a user asks about data, call the appropriate tool to retrieve it and present the results.",
    tools=[
        McpToolset(
            connection_params=StreamableHTTPConnectionParams(url=MCP_SERVER_URL),
            header_provider=get_auth_header
        )
    ]
)

.env

MCP_SERVER_URL=https://mcp.cloud.cdata.com/mcp
CONNECT_AI_AUTHID=<your-oauth-app-id-from-connect-ai>
The CONNECT_AI_AUTHID value is the OAuth App ID generated above. It can be found on the OAuth Apps page in Connect AI Settings (format: cdata-connect-ai-oauth_XXXXXXXXXXXXXXXXX).

__init__.py

from . import agent

Deploy to Vertex AI Agent Engine

Deployment typically takes about 5 minutes.
1
From the agents/ directory, run the deployment command:
adk deploy agent_engine \
  --project=YOUR_PROJECT_ID \
  --region=us-central1 \
  connect_ai_oauth
2
When deployment completes, the Vertex AI Agent Engine resource name is displayed:
Created agent engine: projects/YOUR_PROJECT_ID/locations/us-central1/reasoningEngines/XXXXXXXXXX
Copy this resource name. You will need it in the next section.
3
The resource name can also be found later in the Google Cloud console under Vertex AI > Agent Engine.

Add the Agent to Gemini Enterprise

1
Open Gemini Enterprise and navigate to the Agents screen.
2
Click + Add Agent.
3
From the agent type selection, click Add under Custom agent by Agent Engine.
4
On the authorization screen, configure OAuth with the following settings:Click Next.
Configuring OAuth authorization in Gemini Enterprise
5
On the configuration screen, fill in the following:
  • Agent name–enter an appropriate display name (for example, CData Connect AI Agent).
  • Agent description–enter a description that helps Gemini understand when to invoke this agent.
  • Agent Engine inference engine–enter the resource name copied from the previous section in the following format: projects/{project}/locations/{location}/reasoningEngines/{id}.
Configuring the agent in Gemini Enterprise
6
Click Create. The agent is now available in Gemini Enterprise.

Query Live Data with Natural Language

With the agent registered, you can query live data using natural language from the Gemini Enterprise web application. Each user authenticates with their own Connect AI credentials via the OAuth flow on first use.
1
Open Gemini Enterprise and select the CData Connect AI agent from the Agents panel.
Selecting the CData Connect AI agent in Gemini Enterprise
2
Ask natural language questions about your data, such as:
  • “Show me all records from the last 30 days”
  • “What are the top accounts by revenue?”
  • “List all active opportunities and their current status”
  • “Summarize activity for this quarter”
3
The agent automatically discovers available connections in Connect AI, generates SQL, and returns results—all without requiring you to write queries or understand the underlying data structure.