CertSafari
    Databricks Certified Generative AI Engineer Associate· Lessons

    Domain 3 · Lesson 15/56

    Giving LangChain Agents Tools: Local Functions, Unity Catalog, Retrievers and MCP

    Select Langchain/similar tools for use in a Generative AI application.

    11 min read
    1.79% of exam
    5 sources
    Published 3 Oct 2026
    Docs as of 30 Sep 2026

    What you will be able to do

    • Choose between a local function tool, a Unity Catalog function tool, a retriever tool and an MCP server for a given capability
    • Wrap a Unity Catalog function with UCFunctionToolkit and attach it to a LangChain agent
    • Explain why Databricks recommends MCP for adding Unity Catalog functions to agents
    • Route structured-data questions to Genie agents and unstructured ones to an AI Search retriever

    1.Local function tools: the lightest option

    In an agent built with LangChain or a similar library, every capability the LLM can call is a tool. The simplest kind lives in your own code. "For operations that don't require external data sources or APIs, define tools directly in your agent code." Typical uses are data transformations, calculations and utility functions. Each library has its own decorator: LangChain uses @tool and the OpenAI Agents SDK uses @function_tool. The function's docstring tells the model what the tool does.

    Checkpoint 1 of 6· Fill the gap

    Which decorator turns this function into a LangChain tool?

    from langchain_core.tools import tool
    from langgraph.prebuilt import create_react_agent
    from databricks_langchain import ChatDatabricks
    
    @ ? 
    def get_current_time() -> str:
        """Get the current date and time."""
        from datetime import datetime
        return datetime.now().isoformat()
    
    agent = create_react_agent(
        ChatDatabricks(endpoint="databricks-claude-sonnet-4-5"),
        tools=[get_current_time],
    )

    Local tools also cost the least to deploy. "Local function tools don't require resource grants in databricks.yml because they run within the agent process." They become the wrong choice once a tool needs governed data, sharing across teams, or reuse from more than one library. That is when you move to Unity Catalog.

    Sources1

    2.Unity Catalog function tools: governed and portable

    A Unity Catalog function is a SQL or Python function registered under catalog.schema. It is governed like any other securable, and many libraries can call it. Before wiring a function into an agent, test it directly.

    Testing a Unity Catalog function before giving it to an agentpython
    result = client.execute_function(
      function_name=f"{CATALOG}.{SCHEMA}.add_numbers",
      parameters={"number_1": 36939.0, "number_2": 8922.4}
    )
    
    result.value # OUTPUT: '45861.4'

    There are two ways to expose the function to a LangChain agent. The first is UCFunctionToolkit from databricks_langchain, which wraps one or more functions as LangChain tools. "The toolkit ensures consistency across different AI libraries and adds helpful features like auto-tracing for retrievers."

    Wrapping a UC function with UCFunctionToolkitpython
    from databricks_langchain import UCFunctionToolkit
    
    # Create a toolkit with the Unity Catalog function
    func_name = f"{CATALOG}.{SCHEMA}.add_numbers"
    toolkit = UCFunctionToolkit(function_names=[func_name])
    
    tools = toolkit.tools

    The documentation then builds an agent with LangChain's create_tool_calling_agent. The tools are exposed to the model through a prompt template that has an agent_scratchpad placeholder. That sample uses AgentExecutor only "for simplicity". For production workloads, Databricks points you to the agent authoring workflow on Databricks Apps.

    A tool-calling prompt template and agent built from the toolkit's toolspython
    # Define the prompt
    prompt = ChatPromptTemplate.from_messages(
      [
        (
          "system",
          "You are a helpful assistant. Make sure to use tools for additional functionality.",
        ),
        ("placeholder", "{chat_history}"),
        ("human", "{input}"),
        ("placeholder", "{agent_scratchpad}"),
      ]
    )
    
    # Enable automatic tracing
    mlflow.langchain.autolog()
    
    # Define the agent, specifying the tools from the toolkit above
    agent = create_tool_calling_agent(llm, tools, prompt)

    Checkpoint 2 of 6· Put it in order

    Put the steps for giving a LangChain agent a Unity Catalog tool in order

    1. 1.Create the Unity Catalog function under a catalog and schema
    2. 2.Pass toolkit.tools to create_tool_calling_agent with the LLM and prompt
    3. 3.Wrap it with UCFunctionToolkit(function_names=[...])
    4. 4.Test it with client.execute_function using its fully qualified name

    The second way is the one Databricks prefers: "Databricks recommends using MCP servers to add Unity Catalog functions to your agent." The managed MCP URL /api/2.0/mcp/functions/{catalog}/{schema} gives automatic tool discovery and built-in authentication. In LangGraph you connect to it with DatabricksMultiServerMCPClient. Unlike local tools, an app needs an EXECUTE grant on the function in databricks.yml.

    Connecting a LangGraph agent to UC functions through the managed MCP serverpython
    mcp_client = DatabricksMultiServerMCPClient([
        DatabricksMCPServer(
            name="uc-functions",
            url=f"{host}/api/2.0/mcp/functions/<catalog>/<schema>",
            workspace_client=workspace_client,
        ),
    ])
    The same UC function reaches different libraries through different helpers
    LibraryHelper for UC function toolsAgent construct shown
    LangChain / LangGraphdatabricks_langchain UCFunctionToolkit, or DatabricksMultiServerMCPClient (MCP)create_tool_calling_agent / create_react_agent
    OpenAI Agents SDKMcpServer.from_uc_function, or unitycatalog.ai.openai.toolkit UCFunctionToolkitAgent with mcp_servers
    LlamaIndexunitycatalog.ai.llama_index.toolkit UCFunctionToolkitReActAgent.from_tools

    Checkpoint 3 of 6· Exam question

    A team has already registered a Python function in Unity Catalog that looks up current inventory levels by SKU, and access to it is controlled through Unity Catalog grants. They want a LangChain agent to call this exact governed function as a tool, without re-implementing the lookup logic or bypassing UC access control. Which approach should they use?

    Sources2

    3.Custom retriever tools for unstructured data

    For document Q&A, the agent needs a tool that searches an index. The Databricks AI Bridge packages (databricks-langchain, databricks-openai) include "helper functions like from_vector_search and from_uc_function to create retrievers from existing Databricks resources." In LangChain, VectorSearchRetrieverTool wraps an AI Search index as a tool you can bind to any chat model.

    Prototyping a retriever tool and binding it to an LLMpython
    from databricks_langchain import VectorSearchRetrieverTool, ChatDatabricks
    
    # Initialize the retriever tool.
    vs_tool = VectorSearchRetrieverTool(
      index_name="catalog.schema.my_databricks_docs_index",
      tool_name="databricks_docs_retriever",
      tool_description="Retrieves information about Databricks products from official Databricks documentation."
    )
    
    # Run a query against the vector search index locally for testing
    vs_tool.invoke("Databricks Agent Framework?")
    
    # Bind the retriever tool to your Langchain LLM of choice
    llm = ChatDatabricks(endpoint="databricks-claude-sonnet-4-5")
    llm_with_tools = llm.bind_tools([vs_tool])

    Checkpoint 4 of 6· Check yourself

    An agent with a VectorSearchRetrieverTool rarely calls it, even for questions the index can answer. Which change does the documentation point to?

    Sources3

    4.Structured data, Genie agents and orchestration

    The type of data decides which tool you need. For unstructured text, "AI Search automatically indexes your knowledge base at scale for semantic or hybrid search," which is what a retriever tool queries. For tables, the options are serverless SQL, online feature stores, and Genie: "Genie agents can be used in multi-agent systems to answer natural language queries about your structured data." (These sources do not describe the Genie conversation API itself; this lesson covers only where Genie fits among the tool choices.)

    When one application needs several of these, you can use a Supervisor Agent, which "orchestrates Genie Agents, agent endpoints, Unity Catalog functions, MCP servers, and custom agents." A code-first alternative is a DSPy multi-agent system over Genie Agents and Model Serving agents. Both MCP servers and Unity Catalog functions "provide Unity Catalog-based governance", so access control stays the same whichever library calls them.

    Checkpoint 5 of 6· Exam question

    An engineering team already has a Mosaic AI Vector Search (AI Search) index over chunked support documents and wants to give a LangChain agent read-only access to that index as a callable retrieval tool, with minimal custom code and while keeping MLflow tracing on retrieval calls. Which option best satisfies this?

    Checkpoint 6 of 6· Check yourself

    A multi-agent app must answer "What were Q3 sales by region?" from Delta tables and "What does our refund policy say?" from PDFs. Which pairing of tools fits?

    Sources45

    Exam traps

    Each one states something that sounds right. Open it to see what is actually true.

    1. 1.UCFunctionToolkit is the recommended way to add Unity Catalog functions to an agent.Why is that wrong?

      UCFunctionToolkit works, but Databricks recommends MCP servers, which provide automatic tool discovery and built-in authentication.

      Covered in Unity Catalog function tools: governed and portable

    2. 2.Every agent tool, including a local @tool function, needs a resource grant in databricks.yml.Why is that wrong?

      Local function tools run inside the agent process and need no grants. Unity Catalog functions reached through MCP do need an EXECUTE grant.

      Covered in Local function tools: the lightest option

    3. 3.The LangChain AgentExecutor sample in the docs is the production pattern for Databricks agents.Why is that wrong?

      The AgentExecutor example is there for simplicity. Production workloads should follow the agent authoring workflow on Databricks Apps.

      Covered in Unity Catalog function tools: governed and portable

    Practise it for real

    Give a LangChain tool-calling agent a governed Unity Catalog function and confirm it calls the function.

    1. 1.Run client.execute_function on your {CATALOG}.{SCHEMA}.add_numbers function with number_1=36939.0 and number_2=8922.4.

      Why: Testing the function on its own first separates function bugs from agent bugs.

      You should see: result.value returns '45861.4'.

    2. 2.Create UCFunctionToolkit(function_names=[func_name]) and read toolkit.tools.

      Why: The toolkit turns the UC function into LangChain-compatible tools.

      You should see: A list of tools containing the add_numbers function.

    3. 3.Call mlflow.langchain.autolog(), then build the agent with create_tool_calling_agent(llm, tools, prompt) using a ChatDatabricks LLM and the tool-calling prompt template.

      Why: Autologging records each tool call as a trace, which matters most on serverless compute, where it is not on by default.

      You should see: An agent object, with no errors.

    4. 4.Wrap it in AgentExecutor(agent=agent, tools=tools, verbose=True) and invoke it with {"input": "What is 36939.0 + 8922.4?"}.

      Why: This checks that the model chooses the tool instead of doing the arithmetic itself.

      You should see: Verbose output shows the add_numbers tool being called, and a trace appears in the active MLflow experiment.

    Stuck? Get a nudge

    If the agent answers without calling the tool, check that tools were passed to both create_tool_calling_agent and AgentExecutor.

    Sources

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

    1. 1.
      “For operations that don't require external data sources or APIs, define tools directly in your agent code.”
      ↩︎ Local function tools: the lightest option
      “Local function tools don't require resource grants in databricks.yml because they run within the agent process.”
      ↩︎ Local function tools: the lightest option
      “Local function tools don't require resource grants in databricks.yml because they run within the agent process.”
      ↩︎ Exam trap 2
    2. 2.
      “The toolkit ensures consistency across different AI libraries and adds helpful features like auto-tracing for retrievers.”
      ↩︎ Unity Catalog function tools: governed and portable
      “Databricks recommends using MCP servers to add Unity Catalog functions to your agent.”
      ↩︎ Unity Catalog function tools: governed and portable
      “The MCP approach provides a simpler integration with automatic tool discovery and built-in authentication support.”
      ↩︎ Unity Catalog function tools: governed and portable
      “Databricks recommends using MCP servers to add Unity Catalog functions to your agent.”
      ↩︎ Exam trap 1
      “This example authors a simple agent using LangChain AgentExecutor API for simplicity. For production workloads, use the agent authoring workflow”
      ↩︎ Exam trap 3
      “Once you have created and tested your Unity Catalog function, choose one of the following approaches to add it to your agent.”
      ↩︎ Checkpoint
    3. 3.
      “helper functions like from_vector_search and from_uc_function to create retrievers from existing Databricks resources”
      ↩︎ Custom retriever tools for unstructured data
      “Provide a descriptive tool_description to help the agent understand the tool and determine when to invoke it.”
      ↩︎ Checkpoint
    4. 4.
      “AI Search automatically indexes your knowledge base at scale for semantic or hybrid search.”
      ↩︎ Structured data, Genie agents and orchestration
      “Tool support includes MCP servers and Unity Catalog Functions, both of which provide Unity Catalog-based governance.”
      ↩︎ Structured data, Genie agents and orchestration
      “Genie agents can be used in multi-agent systems to answer natural language queries about your structured data.”
      ↩︎ Checkpoint
    5. 5.
      “Build a supervisor agent that orchestrates Genie Agents, agent endpoints, Unity Catalog functions, MCP servers, and custom agents.”
      ↩︎ Structured data, Genie agents and orchestration

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