CertSafari
    Databricks Certified Generative AI Engineer Associate· Lessons

    Domain 4 · Lesson 40/56

    Managed, external and custom MCP servers for Databricks agents

    Integrate managed, external, and custom MCP servers based on a given application requirements

    19 min read
    1.47% of exam
    8 sources
    Published 22 Oct 2026
    Docs as of 17 Oct 2026

    What you will be able to do

    • Pick a managed, external or custom MCP server to meet a given application requirement
    • Name the URL pattern, permission and OAuth scope each server type needs
    • Connect agent code to any MCP server with DatabricksMCPClient, then list and call its tools

    Key concept

    One MCP interface, three kinds of server — Databricks agents reach tools through the Model Context Protocol. A server can be hosted by Databricks (managed), registered from a third party (external), or built and run by you on Databricks Apps (custom). All three expose the same interface, so the agent code stays the same. What you choose is who runs the server, which URL the agent calls, and which permission controls access.

    1.Why an agent connects to MCP servers

    Model Context Protocol (MCP) is how a Databricks agent gets its tools: querying data, searching documents and calling outside services. You don't write a separate integration for each tool. The agent connects to a server and uses the tools that server publishes. In the workspace, Unity Gateway > MCPs lists the servers available to you, and it is also where you register or build new ones.

    There are three kinds of server, and the difference is who runs it. Managed servers are hosted by Databricks and give access to your own Unity Catalog data and functions. External servers are third-party or self-hosted servers that you register so Unity Gateway can govern them. Custom servers are your own code, running as a Databricks app. To the agent they all look the same. Only three things change: the URL, the authentication, and the permission that decides who may call it.

    When you choose a server, you also choose the tool descriptions the model will read. An MCP server publishes each tool's name and description, and the LLM uses that text to decide which tool to call and in what order. For why this matters, see Tool names and descriptions as the LLM's ordering signal. Before you connect a server, read its tool descriptions: unclear descriptions from a server lead to unclear tool choices by the agent.

    Checkpoint 1 of 9· Match them up

    Match each kind of MCP server to who runs it and what it provides.

    Tap a term, then the definition that fits it.

    Sources12

    2.Managed MCP servers: governed access to data you already have

    A managed server is the right choice when the data or logic already lives in Databricks. That covers Unity Catalog functions, AI Search (Vector Search) indexes, Genie and SQL. Databricks hosts the server and handles authentication, so there is nothing to deploy. Unity Catalog enforces permissions, so an agent can reach only the functions, indexes and tables its caller has been granted.

    Managed MCP servers, their URL patterns and the OAuth scope each needs for on-behalf-of-user access
    ServerUse caseURL patternOAuth scope
    Genie OneNatural-language analytics across your workspacehttps://<workspace-hostname>/ai-gateway/mcp-services/system.ai.genie_one_mcpai-gateway
    Genie AgentNatural-language analytics scoped to one Genie Agenthttps://<workspace-hostname>/api/2.0/mcp/genie/{genie_space_id}genie
    AI SearchRetrieval over unstructured documentshttps://<workspace-hostname>/api/2.0/mcp/ai-search/{catalog}/{schema}/{index_name}ai-search
    Databricks SQLDeveloper queries and data engineeringhttps://<workspace-hostname>/api/2.0/mcp/sqlsql
    Unity Catalog functionsPredefined SQL logic as toolshttps://<workspace-hostname>/api/2.0/mcp/functions/{catalog}/{schema}/{function_name}unity-catalog

    The Unity Catalog functions server turns functions you have already registered into tools. If you point the URL at a catalog and schema, every function in that schema becomes available as a tool. If you add a function name, only that one function is exposed. Who can run each function is still decided by Unity Catalog grants. You don't build an app or create a connection. The system.ai schema adds ready-made functions such as the code interpreter system.ai.python_exec, which the agent calls through this same server.

    The Genie servers are one more example of the managed pattern. For analytics questions, Databricks recommends starting with Genie One rather than having the agent write SQL. Genie resolves business terms through its governed semantic layer, which gives more accurate answers than SQL written against raw tables. Use the Databricks SQL server when you already have the query you want to run. For how multi-agent systems use Genie, see Genie MCP server.

    With on-behalf-of-user authentication, the scope does real work. The application must request the OAuth scope that belongs to each managed server it calls: ai-search for AI Search, unity-catalog for functions, genie for a Genie Agent, sql for Databricks SQL. The token then carries the user's identity to the server, and Unity Catalog permissions still apply. That is how each user ends up seeing only their own documents. You don't need an admin token, and you don't switch off Unity Catalog enforcement.

    Managed servers accept two kinds of parameters. Tool call arguments are generated by the LLM from the user's request. **_meta parameters** are set in your agent code, so that part of the behaviour is fixed instead of left to the model. Billing follows the feature behind the server. Unity Catalog functions use serverless general compute pricing, Genie Agents use serverless SQL pricing, Databricks SQL uses Databricks SQL pricing, and AI Search uses AI Search pricing.

    Checkpoint 2 of 9· Check yourself

    A team has registered several governed SQL functions in the Unity Catalog schema main.tools. Their agent should call only main.tools.lookup_customer, and existing Unity Catalog grants should decide who may run it. Which setup fits?

    Checkpoint 3 of 9· Exam question

    A team is building an agent that must run governed Unity Catalog SQL functions as predefined tools, without standing up any new infrastructure. The workspace already has the functions registered in a catalog and schema, and the team wants Unity Catalog permissions to govern which users can invoke each function. Which approach best satisfies this requirement?

    Checkpoint 4 of 9· Exam question

    An engineer is configuring an agent to call a Databricks-managed AI Search MCP server using on-behalf-of-user authentication, so that each end user's own permissions determine which documents are retrievable. Which configuration detail is required for this authentication mode to work correctly?

    Sources34

    3.External MCP servers: governing third-party tools through Unity Gateway

    Use an external server when the tool lives outside Databricks, such as Slack, GitHub, Jira or an MCP server your platform team runs. Databricks already provides several of these as built-in system.ai services, including system.ai.slack, system.ai.github, system.ai.atlassian, system.ai.google_drive, system.ai.gmail and system.ai.microsoft_365. You don't host or register anything for these. If a tool asks you to sign in, you authorize your provider account through the login link it returns and then retry the call.

    If no built-in service exists, you register the server yourself. In Unity Gateway > MCPs, choose + MCP, then Connect an existing MCP server. Pick a catalog and schema, enter a name, and attach a Unity Catalog HTTP connection that holds the server URL and credentials, using managed OAuth where the provider supports it. The server must support Streamable HTTP. Registering it requires CREATE SERVICE on the schema, plus either CREATE CONNECTION on the schema or USE CONNECTION on an existing connection.

    After registration, the server is a Unity Catalog securable like any other. Calling it requires EXECUTE on the service, and Unity Gateway checks that permission on every call. Policies can also restrict individual tools. This governance is the reason to register a third-party server rather than call it directly from the agent. One team registers it once, and everyone else gets audited, permissioned access at /ai-gateway/mcp-services/<catalog>.<schema>.<service>.

    Networking is the usual cause of a failure after registration. Calls to external MCP providers go out from the workspace's serverless compute plane. If the serverless network policy uses Restricted access, you must add the server's fully qualified domain name to Allowed domains. Creating the connection doesn't open that route. Built-in services have their own requirements too. By default, system.ai.github can reach only public repositories until a GitHub organization admin installs the Databricks connector app.

    Checkpoint 5 of 9· Check yourself

    Your platform team registered its self-hosted MCP server in Unity Gateway. They attached a Unity Catalog HTTP connection, and callers have EXECUTE on the service. The workspace's serverless network policy uses Restricted access, and agent calls to the server still fail. What fixes this?

    Sources562

    4.Custom MCP servers: hosting your own tools on Databricks Apps

    A custom server is the answer when the tool logic is your own and no managed service matches it. One example is proprietary Python that scores leads. Another is an internal HTTP API. Databricks Apps runs the server and gives it an HTTPS URL, so the code stays on Databricks-managed infrastructure without you running a server yourself.

    There are three ways to start, depending on what you have:

    • MCP Server (Starter) template: write new Python tools. It comes with a working health tool, and you add more as decorated functions in server/tools.py.
    • MCP Server (OpenAPI) template: expose an existing REST API. You upload an OpenAPI 3.x spec.json to a volume and set UC_CONNECTION_NAME in app.yaml to an HTTP connection that holds the API's credentials.
    • Custom app: deploy MCP server code you already have. It must use Streamable HTTP, listen on 0.0.0.0 and the port in DATABRICKS_APP_PORT (default 8000), and include an app.yaml start command.

    Give the app a name that starts with mcp-, such as mcp-my-server. The prefix lets AI Playground recognize the app as an MCP server. The agent connects to the app URL with the MCP path added: /mcp for both templates, or the path your own server is configured with. When you add or change a tool, sync the code and redeploy. The agent then has to reconnect to load the updated tool list.

    Access is controlled by Apps permissions, not Unity Catalog grants on a service. A caller needs CAN USE on the app. With the OpenAPI template, a caller also needs USE CONNECTION on the HTTP connection behind it. Authentication is OAuth only. You can use a personal access token for local tests against managed and registered servers, but an app-hosted server rejects it.

    Checkpoint 6 of 9· Check yourself

    While testing locally, a developer sends a personal access token to their lead-scoring MCP server, which is hosted as a Databricks app. The same token works against managed servers, but the app rejects the request. What must change?

    Checkpoint 7 of 9· Exam question

    A team has built proprietary tool logic in Python that doesn't correspond to any Databricks-managed service, and they want to expose it to their agent as an MCP server while keeping it inside Databricks-managed infrastructure with access controlled through existing permission mechanisms. Which deployment approach fits this requirement?

    Sources7

    5.Choosing between managed, external and custom

    Choose based on where the capability already exists. If Databricks already provides it, use the managed server: you get governance with no infrastructure. If a third party provides it, use a built-in or registered MCP Service. Build a custom app only for logic that exists nowhere else. Building a custom app to wrap something a managed server already covers adds a deployment you have to run and loses the Unity Catalog governance you would otherwise get for free.

    What changes between the three server types when an agent connects
    Server typeURL patternWho may call it
    Managedhttps://<workspace-hostname>/api/2.0/mcp/<service>/<path>Unity Catalog permissions on the underlying function, index, space or warehouse
    External (MCP Service)https://<workspace-hostname>/ai-gateway/mcp-services/<catalog>.<schema>.<mcp-service>EXECUTE on the service, enforced on every call
    Customhttps://<app-url>/mcpCAN USE on the Databricks app

    Checkpoint 8 of 9· Match them up

    A support agent needs three tools. For each one, pick the server and the permission that decides who may call it.

    Tap a term, then the definition that fits it.

    Sources1

    6.Wiring an MCP server into agent code

    The databricks-mcp library handles authentication to Databricks MCP servers, so one client works for all three server types. You create a DatabricksMCPClient with a server URL and an authenticated WorkspaceClient. Then you call list_tools() to see what the server publishes and call_tool() to run one.

    Connecting to a server and listing its tools. Only the URL changes between managed, MCP Service and custom servers.python
    from databricks_mcp import DatabricksMCPClient
    from databricks.sdk import WorkspaceClient
    
    workspace_client = WorkspaceClient(profile="DEFAULT")
    host = workspace_client.config.host
    
    # Use a managed, MCP Service, or custom server URL:
    mcp_server_url = f"{host}/api/2.0/mcp/functions/system/ai"
    
    mcp_client = DatabricksMCPClient(server_url=mcp_server_url, workspace_client=workspace_client)
    tools = mcp_client.list_tools()
    print(f"Available tools: {[t.name for t in tools]}")

    Find tool names by asking the server, not by memory. list_tools() returns each tool's name, description and input schema at runtime. That is the dependable way to learn the exact arguments, and it is also where you read the descriptions the model will see. In the example, the tool comes back as system__ai__python_exec, and it runs with mcp_client.call_tool("system__ai__python_exec", {"code": "print('Hello, world!')"}). Managed system.ai tools only run if serverless compute is enabled in the workspace.

    Pick the authentication that matches where the agent runs:

    • Local environment: use a Databricks CLI OAuth profile, as in the example above.
    • Service principal: give the WorkspaceClient the service principal's client ID and secret, ideally read from Databricks secrets. Use this for unattended agents, and declare the server's resource when you log the agent.
    • On-behalf-of-user: use ModelServingUserCredentials. Log the agent with the apps scope plus each managed server's scope, or with ai-gateway for an MCP Service, where the user also needs EXECUTE.
    On-behalf-of-user authentication: the agent calls the server with the calling user's permissionspython
    from databricks.sdk.credentials_provider import ModelServingUserCredentials
    
    workspace_client = WorkspaceClient(credentials_strategy=ModelServingUserCredentials())
    mcp_client = DatabricksMCPClient(server_url=mcp_server_url, workspace_client=workspace_client)

    Agent frameworks wrap the same connection. With LangGraph, DatabricksMultiServerMCPClient takes a list of DatabricksMCPServer entries, each with its own name and URL. get_tools() then collects tools from all of those servers, and you pass them to create_react_agent. The OpenAI Agents SDK does the same with McpServer from databricks_openai.agents. Either way, a single agent can combine a managed Genie server, a registered GitHub service and your custom app.

    Checkpoint 9 of 9· Fill the gap

    This agent code connects to a Databricks MCP server and should find out at runtime which tools the server publishes, with their names, descriptions and input schemas. Which method completes it?

    from databricks_mcp import DatabricksMCPClient
    from databricks.sdk import WorkspaceClient
    
    workspace_client = WorkspaceClient(profile="DEFAULT")
    host = workspace_client.config.host
    
    # Use a managed, MCP Service, or custom server URL:
    mcp_server_url = f"{host}/api/2.0/mcp/functions/system/ai"
    
    mcp_client = DatabricksMCPClient(server_url=mcp_server_url, workspace_client=workspace_client)
    tools = mcp_client. ? ()
    print(f"Available tools: {[t.name for t in tools]}")

    Sources2

    Practise it for real

    Connect a Python agent environment to a managed MCP server, discover its tools and call one

    1. 1.Run databricks auth login --host https://<workspace-hostname> and keep the DEFAULT profile name.

      Why: DatabricksMCPClient authenticates through a WorkspaceClient built from this profile.

      You should see: A saved OAuth profile you can pass to WorkspaceClient(profile="DEFAULT").

    2. 2.Install the client libraries with pip install -U "mcp>=1.9" "databricks-sdk[openai]" "mlflow>=3.1.0" "databricks-agents>=1.0.0" "databricks-mcp" on Python 3.12 or above.

      Why: The databricks-mcp library provides the client that handles authentication to every server type.

      You should see: The packages install without errors.

    3. 3.Run the listing snippet against {host}/api/2.0/mcp/functions/system/ai.

      Why: list_tools() is the reliable way to learn a server's exact tool names and input schemas.

      You should see: The output includes system__ai__python_exec.

    4. 4.Call mcp_client.call_tool("system__ai__python_exec", {"code": "print('Hello, world!')"}) and print result.content.

      Why: This confirms authentication and tool invocation from start to finish.

      You should see: The content contains Hello, world! If it fails, check that serverless compute is enabled in the workspace.

    Stuck? Get a nudge

    To try a custom or MCP Service server next, change only mcp_server_url. The rest of the code stays the same.

    Sources

    (8)

    Every claim above is drawn from one of these pages, quoted as it was written on the date shown.

    1. 1.
      “Model Context Protocol (MCP) lets your agent query data, search documents, and call external services.”
      ↩︎ Why an agent connects to MCP servers
      “Use a Databricks-provided MCP, register an existing server, or build your own.”
      ↩︎ Choosing between managed, external and custom
    2. 2.
      “What differs is the server URL and how you authenticate.”
      ↩︎ Why an agent connects to MCP servers
      “For an external MCP Service, the caller must also have EXECUTE on the service.”
      ↩︎ External MCP servers: governing third-party tools through Unity Gateway
      “Do not hardcode server names, tool names, or argument shapes from memory; confirm them from the workspace.”
      ↩︎ Wiring an MCP server into agent code
      “Use ModelServingUserCredentials so the agent acts with the calling user's permissions.”
      ↩︎ Wiring an MCP server into agent code
      “All of them expose the same MCP interface, so the agent code is the same.”
      ↩︎ Key concept
      “Databricks-managed servers, external MCP servers registered as MCP Services, and custom servers hosted as Databricks apps.”
      ↩︎ Checkpoint
      “For an external MCP Service, the caller must also have EXECUTE on the service. AI Gateway enforces this permission on every call.”
      ↩︎ Checkpoint
    3. 3.
      “No setup: Databricks hosts the servers and manages authentication.”
      ↩︎ Managed MCP servers: governed access to data you already have
      “_meta parameters: Configuration parameters that you can preset in your agent code to set behavior deterministically”
      ↩︎ Managed MCP servers: governed access to data you already have
      “Governed: Unity Catalog enforces permissions, so agents and users access only the tools and data you grant them.”
      ↩︎ Exam trap 1
      “include the corresponding OAuth scope for each server your application needs to access”
      ↩︎ Exam trap 2
      “include the corresponding OAuth scope for each server your application needs to access”
      ↩︎ Prediction
      “Governed: Unity Catalog enforces permissions, so agents and users access only the tools and data you grant them.”
      ↩︎ Checkpoint
    4. 5.
      “Use a built-in system.ai MCP Service (Slack, GitHub, Google Drive, Google Calendar, Gmail) or register your own external MCP server.”
      ↩︎ External MCP servers: governing third-party tools through Unity Gateway
    5. 6.
      “Register a self-hosted or third-party MCP server so your team can use it through Unity Gateway. Create its connection as part of registration.”
      ↩︎ External MCP servers: governing third-party tools through Unity Gateway
    6. 7.
      “Databricks Apps provides the compute to run the server and an HTTPS URL for agents to connect to it.”
      ↩︎ Custom MCP servers: hosting your own tools on Databricks Apps
      “Listen on 0.0.0.0 and the port in DATABRICKS_APP_PORT (default 8000).”
      ↩︎ Custom MCP servers: hosting your own tools on Databricks Apps

    Also cited

    Spotted a mistake, or was something unclear? Tell us.