Connect AI agent tools to external services
This feature is in Public Preview.
Learn how to connect AI agent tools to external applications like Slack, Google Calendar, or any service with an API using HTTP requests. Agents can use externally connected tools to automate tasks, send messages, and retrieve data from third-party platforms.
Requirements
- Create a Unity Catalog HTTP connection for your external application. Unity Catalog connections provide secure, governed credential management and support multiple standard authentication methods, including OAuth 2.0 user-to-machine and machine-to-machine authentication.
Use tools from external MCP servers
If the external service you want to connect to has an MCP server available, the easiest way to connect your agent is through external MCP servers. This approach provides:
- Automatic tool discovery: The MCP server exposes all available tools using standard APIs.
- Simplified integration: Connect and execute tools using standard SDKs.
- Reduced maintenance: Tool definitions are managed centrally by the external MCP server.
See Use external MCP servers for detailed instructions.
Create a tool in agent code
To send HTTP requests to external services with Python, use the http_request function from the databricks-sdk library. This function sends an HTTP request to an external service using a Unity Catalog connection to authenticate.
Permissions required: USE CONNECTION on the connection object.
The following example makes an external HTTP request from inside agent code.
from databricks.sdk import WorkspaceClient
from databricks.sdk.service.serving import ExternalFunctionRequestHttpMethod
WorkspaceClient().serving_endpoints.http_request(
conn="connection_name",
method=ExternalFunctionRequestHttpMethod.POST,
path="/api/v1/resource",
json={"key": "value"},
headers={"extra_header_key": "extra_header_value"},
)
conn: The connection object that specifies the host, port, base_path, and access credentials.method: The HTTP request method used to make the call. For example:GET,POST,PUT,DELETEpath: The path to concatenate after thebase_pathto invoke the service resource.json: The JSON body to send with the request.headers: A Map to specify the request headers.
Create a Unity Catalog function tool
SQL access with http_request is blocked for the User-to-Machine Per User connection type. Use the Python Databricks SDK instead.
After creating the HTTP connection and testing that it works properly, create a Unity Catalog function that uses the connection. The following example creates a Unity Catalog function tool that an agent can use to post a message to Slack:
CREATE OR REPLACE FUNCTION main.default.slack_post_message(
text STRING COMMENT 'message content'
)
RETURNS STRING
COMMENT 'Sends a Slack message by passing in the message and returns the response received from the external service.'
RETURN (http_request(
conn => 'test_sql_slack',
method => 'POST',
path => '/api/chat.postMessage',
json => to_json(named_struct(
'channel', "C032G2DAH3",
'text', text
))
)).text
See CREATE FUNCTION (SQL and Python).
Example notebooks
Connect an agent to Slack
See Connect an AI agent to Slack.
External connection tools
The following notebooks demonstrate creating AI agent tools that connect to Slack, OpenAI, and Azure AI search.