emma_s
Databricks Employee
Databricks Employee

H

Hi,

I'm not an expert in what Google Gemini Enterprise agent supports, but there are a couple of options with Genie.

The easiest one is if Google Gemini Enterprise agent supports it, using the Databricks Genie MCP to add your MCP. However, I'm not sure whether the Gemini Enterprise agent has this capability of adding MCPs. Docs for this are here. https://docs.databricks.com/aws/en/generative-ai/mcp/managed-mcp

If not, then you can use the Genie API, docs here https://docs.databricks.com/aws/en/genie/conversation-api?language=Use+an+existing+space

You would register this as a google cloud function and then import this into your Gemini Enterpise Agent.

 

Here is some sample code of what the cloud function would look like.

import os
import json
import functions_framework
from databricks.sdk import WorkspaceClient


@functions_framework.http
def query_genie(request):
    try:
        body = request.get_json(silent=True)
        if not body or "user_question" not in body:
            return (
                json.dumps({"error": "Missing 'user_question' in request body"}),
                400,
                {"Content-Type": "application/json"},
            )

        user_question = body["user_question"]

        w = WorkspaceClient(
            host=os.environ["DATABRICKS_HOST"],
            token=os.environ["DATABRICKS_TOKEN"],
        )
        space_id = os.environ["GENIE_SPACE_ID"]

        response = w.genie.start_conversation_and_wait(
            space_id=space_id,
            content=user_question,
        )

        # Genie returns attachments in order: [query, suggested_questions, text]
        # Prefer the text attachment (human-readable answer); fall back to query description.
        answer = ""
        query_fallback = ""
        for attachment in response.attachments or []:
            if hasattr(attachment, "text") and attachment.text:
                answer = attachment.text.content
                break
            if hasattr(attachment, "query") and attachment.query and not query_fallback:
                query_fallback = attachment.query.description or attachment.query.query
        if not answer:
            answer = query_fallback

        return (
            json.dumps(
                {
                    "answer": answer,
                    "conversation_id": response.conversation_id,
                }
            ),
            200,
            {"Content-Type": "application/json"},
        )

    except Exception as e:
        return (
            json.dumps({"error": str(e)}),
            500,
            {"Content-Type": "application/json"},
        )


For full disclosure the api currently only serves standard genie space responses not agent mode ones. You may also want to look at instead giving your business users access to Genie One. There is the ability in beta to connect this to google drive or office. Your users would then get Genie Agent mode properly.

I hope this helps.


Thanks,

Emma

View solution in original post