How to integrate Databricks MCP with LlamaIndex

Framework Integration Gradient
Databricks Logo
LlamaIndex Logo
divider

Introduction

This guide walks you through connecting Databricks to LlamaIndex using the Composio tool router. By the end, you'll have a working Databricks agent that can run a sql query on sales data, list all clusters running right now, start a databricks job for data import through natural language commands.

This guide will help you understand how to give your LlamaIndex agent real control over a Databricks account through Composio's Databricks MCP server.

Before we dive in, let's take a quick look at the key ideas and tools involved.

TL;DR

Here's what you'll learn:
  • Set your OpenAI and Composio API keys
  • Install LlamaIndex and Composio packages
  • Create a Composio Tool Router session for Databricks
  • Connect LlamaIndex to the Databricks MCP server
  • Build a Databricks-powered agent using LlamaIndex
  • Interact with Databricks through natural language

What is LlamaIndex?

LlamaIndex is a data framework for building LLM applications. It provides tools for connecting LLMs to external data sources and services through agents and tools.

Key features include:

  • ReAct Agent: Reasoning and acting pattern for tool-using agents
  • MCP Tools: Native support for Model Context Protocol
  • Context Management: Maintain conversation context across interactions
  • Async Support: Built for async/await patterns

What is the Databricks MCP server, and what's possible with it?

The Databricks MCP server is an implementation of the Model Context Protocol that connects your AI agent and assistants like Claude, Cursor, etc directly to your Databricks account. It provides structured and secure access so your agent can perform Databricks operations on your behalf.

Supported Tools & Triggers

Tools
Add Member to Security GroupTool to add a user or group as a member to a Databricks security group.
Delete Custom LLM AgentTool to delete a Custom LLM agent created through Agent Bricks.
Create Databricks AppTool to create a new Databricks app with specified configuration.
Delete Databricks AppTool to delete a Databricks app from the workspace.
Deploy Databricks AppTool to create a deployment for a Databricks app.
Get Databricks App DetailsTool to retrieve details about a specific Databricks app by name.
Get Databricks App Permission LevelsTool to retrieve available permission levels for a Databricks app.
Get Databricks App PermissionsTool to retrieve permissions for a Databricks app.
Get App Deployment UpdateTool to retrieve information about a specific app deployment update.
Set Databricks App PermissionsTool to set permissions for a Databricks app, replacing all existing permissions.
Start Databricks AppTool to start the last active deployment of a Databricks app.
Stop Databricks AppTool to stop the active deployment of a Databricks app.
Update Databricks AppTool to update an existing Databricks app configuration.
Update Databricks App PermissionsTool to incrementally update permissions for a Databricks app.
Cancel Databricks Job RunTool to cancel a Databricks job run asynchronously.
Get Catalog Artifact AllowlistTool to retrieve artifact allowlist configuration for a specified artifact type in Unity Catalog.
Delete CatalogTool to delete a catalog from Unity Catalog metastore.
Get Catalog DetailsTool to retrieve details of a specific catalog in Unity Catalog.
Create Catalog ConnectionTool to create a new Unity Catalog connection to external data sources.
Delete Catalog ConnectionTool to delete a Unity Catalog connection to external data sources.
Get Catalog ConnectionTool to retrieve detailed information about a specific Unity Catalog connection.
Update Catalog ConnectionTool to update an existing Unity Catalog connection configuration.
Create Catalog CredentialTool to create a new credential for Unity Catalog access to cloud services.
Delete Catalog CredentialTool to delete a Unity Catalog credential for cloud storage or service access.
Generate Temporary Service CredentialTool to generate temporary credentials from a service credential with admin access.
Get Catalog CredentialTool to retrieve detailed information about a specific Unity Catalog credential.
Update Catalog CredentialTool to update an existing Unity Catalog credential with new properties.
Validate Catalog CredentialTool to validate a Unity Catalog credential for external access.
Get Entity Tag AssignmentTool to retrieve a specific tag assignment for a Unity Catalog entity by tag key.
Create External LocationTool to create a new Unity Catalog external location combining a cloud storage path with a storage credential.
Delete External LocationTool to delete an external location from Unity Catalog metastore.
Get External Location DetailsTool to retrieve details of a specific Unity Catalog external location.
Update External LocationTool to update an existing Unity Catalog external location properties.
Update External MetadataTool to update an external metadata object in Unity Catalog.
Update Catalog FunctionTool to update function owner in Unity Catalog.
Get Catalog GrantsTool to get permissions (grants) for a securable in Unity Catalog without inherited permissions.
Get Effective Catalog PermissionsTool to get effective permissions for a securable in Unity Catalog, including inherited permissions from parent securables.
Update Catalog GrantsTool to update permissions for Unity Catalog securables by adding or removing privileges for principals.
Assign Metastore to WorkspaceTool to assign a Unity Catalog metastore to a workspace.
Create MetastoreTool to create a new Unity Catalog metastore.
Get Current Metastore AssignmentTool to retrieve the current metastore assignment for the workspace being accessed.
Delete MetastoreTool to delete a Unity Catalog metastore.
Get Metastore DetailsTool to retrieve detailed information about a specific Unity Catalog metastore by its ID.
Get Metastore SummaryTool to retrieve summary information about the metastore associated with the current workspace.
Unassign Metastore from WorkspaceTool to unassign a Unity Catalog metastore from a workspace.
Update MetastoreTool to update configuration settings for an existing Unity Catalog metastore.
Update Metastore AssignmentTool to update a metastore assignment for a workspace.
Get Model VersionTool to retrieve detailed information about a specific version of a registered model in Unity Catalog.
Update Model VersionTool to update a Unity Catalog model version.
Delete Online TableTool to delete an online table by name.
Get Quality MonitorTool to retrieve quality monitor configuration for a Unity Catalog table.
List Quality Monitor RefreshesTool to retrieve the refresh history for a quality monitor on a Unity Catalog table.
Get Registered ModelTool to retrieve detailed information about a registered model in Unity Catalog.
Get Resource Quota InformationTool to retrieve usage information for a Unity Catalog resource quota defined by a child-parent pair.
Batch Create Access RequestsTool to batch create access requests for Unity Catalog permissions.
Get Access Request DestinationsTool to retrieve access request destinations for a Unity Catalog securable.
Update Access Request DestinationsTool to update access request notification destinations for Unity Catalog securables.
Get Catalog SchemaTool to retrieve details of a specific schema from Unity Catalog metastore.
Create Storage CredentialTool to create a new storage credential in Unity Catalog for cloud data access.
Delete Storage CredentialTool to delete a storage credential from the Unity Catalog metastore.
Get Storage CredentialTool to retrieve storage credential details from Unity Catalog metastore by name.
Update Storage CredentialTool to update an existing storage credential in Unity Catalog.
Validate Storage CredentialTool to validate a storage credential configuration for Unity Catalog.
Disable System SchemaTool to disable a system schema in Unity Catalog metastore.
Enable System SchemaTool to enable a system schema in Unity Catalog metastore.
Delete Catalog TableTool to delete a table from Unity Catalog.
Check Table ExistsTool to check if a table exists in Unity Catalog metastore.
Get Catalog Table DetailsTool to retrieve comprehensive metadata about a table from Unity Catalog metastore.
Update Catalog TableTool to update Unity Catalog table properties.
Generate Temporary Path CredentialsTool to generate short-lived, scoped temporary credentials for accessing external storage locations registered in Unity Catalog.
Get Catalog Volume DetailsTool to retrieve detailed information about a specific Unity Catalog volume.
Update Catalog Workspace BindingsTool to update workspace bindings for a Unity Catalog securable (catalog).
Get Clean Room AssetTool to retrieve detailed information about a specific asset within a Databricks Clean Room.
Create Clean Room Auto-Approval RuleTool to create a new auto-approval rule for a Databricks Clean Room.
Create Clean RoomTool to create a new Databricks Clean Room for secure data collaboration with specified collaborators.
Create Compute Cluster PolicyTool to create a new cluster policy with prescribed settings for controlling cluster creation.
Delete Compute Cluster PolicyTool to delete a cluster policy.
Edit Compute Cluster PolicyTool to update an existing Databricks cluster policy.
Get Compute Cluster PolicyTool to retrieve detailed information about a specific cluster policy by its ID.
Get Compute Cluster Policy Permission LevelsTool to retrieve available permission levels for a Databricks cluster policy.
Get Compute Cluster Policy PermissionsTool to retrieve permissions for a Databricks cluster policy.
Set Compute Cluster Policy PermissionsTool to set permissions for a Databricks cluster policy, replacing all existing permissions.
Update Cluster Policy PermissionsTool to incrementally update permissions on a Databricks cluster policy.
Delete Compute ClusterTool to terminate a Databricks compute cluster.
Edit Compute ClusterTool to update the configuration of a Databricks cluster.
Get Compute Cluster Permission LevelsTool to retrieve available permission levels for a Databricks compute cluster.
List Compute Cluster Node TypesTool to list all supported Spark node types available for cluster launch in the workspace region.
List Compute Cluster Availability ZonesTool to list availability zones where Databricks clusters can be created.
Permanently Delete Compute ClusterTool to permanently delete a Databricks compute cluster.
Pin Compute ClusterTool to pin a Databricks compute cluster configuration.
List Compute Cluster Spark VersionsTool to list all available Databricks Runtime Spark versions for cluster creation.
Start Compute ClusterTool to start a terminated Databricks compute cluster asynchronously.
Unpin Compute ClusterTool to unpin a Databricks compute cluster configuration.
Update Compute ClusterTool to partially update a Databricks compute cluster configuration using field masks.
Create Global Init ScriptTool to create a new global initialization script in Databricks workspace.
Delete Global Init ScriptTool to delete a global initialization script from Databricks workspace.
Get Global Init ScriptTool to retrieve complete details of a global initialization script in Databricks workspace.
Update Global Init ScriptTool to update a global initialization script in Databricks workspace.
Create Compute Instance PoolTool to create a new Databricks instance pool with specified configuration.
Delete Compute Instance PoolTool to delete a Databricks compute instance pool.
Edit Compute Instance PoolTool to modify the configuration of an existing Databricks instance pool.
Get Instance Pool DetailsTool to retrieve detailed information about a Databricks instance pool by its ID.
Get Instance Pool Permission LevelsTool to retrieve available permission levels for a Databricks instance pool.
Get Instance Pool PermissionsTool to retrieve permissions for a Databricks instance pool.
Set Compute Instance Pool PermissionsTool to set permissions for a Databricks instance pool, replacing all existing permissions.
Update Instance Pool PermissionsTool to incrementally update permissions on a Databricks instance pool.
Add Compute Instance ProfileTool to register an instance profile in Databricks for cluster launches.
Edit Compute Instance ProfileTool to modify an existing AWS EC2 instance profile registered with Databricks.
Remove Compute Instance ProfileTool to remove an instance profile from Databricks.
Enforce Cluster Policy ComplianceTool to update a cluster to be compliant with the current version of its policy.
Get Cluster Policy ComplianceTool to retrieve policy compliance status for a specific cluster.
Get Compute Policy FamiliesTool to retrieve information for a policy family by identifier and optional version.
Create Databricks ClusterTool to create a new Databricks Spark cluster with specified configuration.
Create Genie MessageTool to create a message in a Genie conversation and get AI-generated responses.
Create Genie SpaceTool to create a new Genie space from a serialized payload for programmatic space management.
Delete Genie ConversationTool to delete a conversation from a Genie space programmatically.
Delete Genie Conversation MessageTool to delete a specific message from a Genie conversation.
Execute Message Attachment QueryTool to execute SQL query for an expired message attachment in a Genie space.
Execute Genie Message QueryTool to execute the SQL query associated with a Genie message.
Get Genie MessageTool to retrieve details of a specific message from a Genie conversation.
Get Genie Message Attachment Query ResultTool to retrieve SQL query results from a Genie message attachment.
Get Genie Message Query ResultTool to retrieve SQL query execution results for a Genie message (up to 5000 rows).
Get Genie Message Query ResultTool to retrieve SQL query execution results for a message attachment in a Genie space conversation.
Get Genie Space DetailsTool to retrieve detailed information about a specific Databricks Genie space by ID.
List Genie Conversation MessagesTool to retrieve all messages from a specific conversation thread in a Genie space.
List Genie ConversationsTool to retrieve all existing conversation threads within a Genie space.
List Genie SpacesTool to retrieve all Genie spaces in the workspace that the authenticated user has access to.
Send Genie Message FeedbackTool to send feedback for a Genie message.
Start Genie ConversationTool to start a new Genie conversation in a Databricks space for natural language data queries.
Trash Genie SpaceTool to move a Genie space to trash instead of permanently deleting it.
Update Genie SpaceTool to update an existing Genie space configuration.
Create Lakeview DashboardTool to create a new Lakeview dashboard in Databricks.
Delete Lakeview Dashboard ScheduleTool to delete a dashboard schedule from a Lakeview dashboard.
Get Published Dashboard Token InfoTool to retrieve authorization info for generating downscoped tokens to access published Lakeview dashboards.
Get Lakeview Dashboard DetailsTool to retrieve details about a draft AI/BI Lakeview dashboard from the workspace.
Get Published Lakeview DashboardTool to retrieve the current published version of a Lakeview dashboard.
Get Lakeview Dashboard ScheduleTool to retrieve a specific schedule for a Databricks AI/BI Lakeview dashboard.
Publish Lakeview DashboardTool to publish an AI/BI Lakeview dashboard making it accessible via public link.
Trash Lakeview DashboardTool to move a Lakeview dashboard to trash instead of permanently deleting it.
Unpublish Lakeview DashboardTool to unpublish an AI/BI Lakeview dashboard while preserving its draft version.
Update Lakeview DashboardTool to update a draft Lakeview dashboard configuration and metadata.
Create Database CatalogTool to create a new database catalog in Databricks.
Create Database InstanceTool to create a Lakebase database instance with specified configuration.
Delete Database InstanceTool to delete a Lakebase Postgres database instance.
Delete Synced Database TableTool to delete a synced table from Unity Catalog and stop data refreshes.
Find Database Instance By UIDTool to find a database instance by its unique identifier (UID).
Generate Database CredentialTool to generate OAuth token for database instance authentication.
Get Database InstanceTool to retrieve detailed information about a specific database instance by its name identifier.
Create Data Quality MonitorTool to create a data quality monitor for a Unity Catalog Delta table.
List DBFS Directory ContentsTool to list the contents of a directory or get details of a file in DBFS.
Delete Databricks ClusterTool to terminate a Databricks Spark cluster asynchronously.
Delete Databricks Job RunTool to delete a non-active Databricks job run from the system.
Delete User by IDTool to delete a user from the Databricks workspace by their ID.
Edit Databricks ClusterTool to edit an existing Databricks cluster configuration.
Add Block to DBFS StreamTool to append a block of data to an open DBFS stream.
Create DBFS File StreamTool to open a stream to write to a DBFS file and returns a handle.
Delete DBFS File or DirectoryTool to delete a file or directory from DBFS.
Get DBFS File StatusTool to get the information of a file or directory in DBFS.
Move DBFS File or DirectoryTool to move a file or directory from one location to another within DBFS.
Read DBFS File ContentsTool to read the contents of a file from DBFS.
Get All Library StatusesTool to retrieve status of all libraries across all Databricks clusters.
Get Cluster InformationTool to retrieve comprehensive metadata and configuration details for a Databricks cluster by its unique identifier.
Get Group by IDTool to retrieve information for a specific group in Databricks workspace by its ID.
Get User by IDTool to retrieve information for a specific user in Databricks workspace by their ID.
Update IAM Account Access Control Rule SetTool to update account-level access control rule set for service principals, groups, or budget policies.
Get IAM Account Group V2Tool to retrieve a specific group resource by its unique identifier from a Databricks account using SCIM v2 protocol.
Get Current User InformationTool to retrieve details about the currently authenticated user or service principal making the API request.
Create IAM Group V2Tool to create a new group in Databricks workspace using SCIM v2 protocol.
Delete IAM Group V2Tool to delete a group from Databricks workspace using SCIM v2 protocol.
Get Workspace IAM Group V2Tool to retrieve details of a specific group by ID from Databricks workspace using SCIM v2 protocol.
Patch IAM Group V2Tool to partially update a Databricks workspace group using SCIM 2.
Update IAM Group V2Tool to update an existing group in Databricks workspace using SCIM v2 protocol.
Migrate PermissionsTool to migrate ACL permissions from workspace groups to account groups.
Get IAM PermissionsTool to retrieve IAM permissions for a Databricks workspace object.
Get IAM Permission LevelsTool to retrieve available permission levels for a Databricks workspace object.
Set IAM PermissionsTool to set IAM permissions for a Databricks workspace object, replacing all existing permissions.
Update IAM PermissionsTool to incrementally update permissions on Databricks workspace objects including dashboards, jobs, clusters, warehouses, notebooks, and more.
Create IAM Service Principal V2Tool to create a new service principal in Databricks workspace using SCIM v2 protocol.
Delete IAM Service Principal V2Tool to delete a service principal from Databricks workspace using SCIM v2 protocol.
Get IAM Service Principal V2Tool to retrieve details of a specific service principal by ID from Databricks workspace using SCIM v2 protocol.
Patch IAM Service Principal V2Tool to partially update a service principal using SCIM 2.
Update IAM Service Principal V2Tool to update an existing service principal in Databricks workspace using SCIM v2 protocol.
Create IAM User V2Tool to create a new user in Databricks workspace using SCIM v2 protocol.
Delete IAM User V2Tool to delete a user from Databricks workspace using SCIM v2 protocol.
Get IAM User V2Tool to retrieve detailed information for a specific user by ID from Databricks workspace using SCIM v2 protocol.
Get IAM Users V2 PermissionsTool to retrieve permissions for password-based authentication.
Patch IAM User V2Tool to partially update a user using SCIM 2.
Update IAM User V2Tool to update a user in Databricks workspace using SCIM v2 protocol.
Get Workspace Access Detail LocalTool to retrieve detailed workspace access information for a specific identity in Databricks.
List Job Compliance for PolicyTool to retrieve policy compliance status of all jobs using a given cluster policy.
Get Job Permission LevelsTool to retrieve available permission levels for a Databricks job.
Update Job PermissionsTool to incrementally update permissions for a Databricks job.
Get Job Run By IDTool to retrieve metadata of a single Databricks job run by ID.
List Databricks Job RunsTool to list Databricks job runs in descending order by start time.
Cancel All Databricks Job RunsTool to cancel all active runs of a Databricks job asynchronously.
Cancel Databricks Job RunTool to cancel a Databricks job run asynchronously.
Delete Databricks Job RunTool to delete a non-active Databricks job run.
Get Databricks Job DetailsTool to retrieve detailed information about a single Databricks job.
Get Job Permission LevelsTool to retrieve available permission levels for a Databricks job.
Get Databricks Job Run DetailsTool to retrieve complete metadata for a single Databricks job run.
Get Databricks Job Run OutputTool to retrieve output and metadata of a single Databricks task run.
Set Databricks Job PermissionsTool to set permissions for a Databricks job, completely replacing all existing permissions.
Submit Databricks Job RunTool to submit a one-time Databricks job run without creating a persistent job.
List Databricks JobsTool to retrieve a paginated list of all jobs in the Databricks workspace.
Get Job Policy ComplianceTool to retrieve policy compliance status for a specific job.
List Unity CatalogsTool to retrieve a list of all catalogs in the Unity Catalog metastore.
List ClustersTool to list all pinned, active, and recently terminated Databricks clusters.
List Workspace GroupsTool to list all groups in the Databricks workspace using SCIM v2 protocol.
List Instance PoolsTool to retrieve a list of all active instance pools in the Databricks workspace with their statistics and configuration.
List All Databricks Jobs (API 2.0)Tool to list all jobs in the Databricks workspace using API 2.
List Members of a Security GroupTool to retrieve all members (users and nested groups) of a Databricks security group.
List Model Serving EndpointsTool to retrieve all serving endpoints for model serving in the workspace.
List Node TypesTool to list all supported node types available for cluster launch in the workspace.
List Delta Live Tables PipelinesTool to list Delta Live Tables pipelines in the workspace.
List ReposTool to list Git repos that the calling user has Manage permissions on.
List Databricks Job RunsTool to list Databricks job runs in descending order by start time.
List Catalog SchemasTool to retrieve all schemas in a specified catalog from Unity Catalog.
List SecretsTool to list all secret keys stored in a Databricks secret scope.
List Secret ScopesTool to list all secret scopes available in the Databricks workspace.
List Security GroupsTool to list all security groups in the Databricks workspace using SCIM v2 protocol.
List SQL WarehousesTool to list all SQL warehouses in the Databricks workspace.
List Catalog TablesTool to list all tables in a Unity Catalog schema with pagination support.
List TokensTool to list all valid personal access tokens (PATs) for a user-workspace pair.
List UsersTool to list all users in a Databricks workspace using SCIM 2.
List Vector Search EndpointsTool to list all vector search endpoints in the Databricks workspace.
Create Marketplace Consumer InstallationTool to create a marketplace consumer installation for Databricks Marketplace listings.
Delete Marketplace Consumer InstallationTool to uninstall a Databricks Marketplace installation.
Update Marketplace Consumer InstallationTool to update marketplace consumer installation fields and rotate tokens for marketplace listings.
Batch Get Marketplace Consumer ListingsTool to batch get published listings from the Databricks Marketplace.
Get Marketplace Consumer ListingTool to retrieve a published listing from Databricks Marketplace that consumer has access to.
Get Marketplace Consumer Personalization RequestsTool to retrieve personalization requests for a specific marketplace listing.
Batch Get Marketplace Consumer ProvidersTool to batch get providers from the Databricks Marketplace with visible listings.
Get Marketplace Consumer ProviderTool to retrieve information about a specific provider in the Databricks Marketplace with visible listings.
Delete Listing From ExchangeTool to remove the association between a marketplace exchange and a listing.
Create Marketplace Provider ListingTool to create a new listing in Databricks Marketplace for data providers.
Get Marketplace Provider ListingTool to retrieve a specific marketplace provider listing by its identifier.
Create Provider Analytics DashboardTool to create a provider analytics dashboard for monitoring Databricks Marketplace listing metrics.
Get Provider Analytics DashboardTool to retrieve provider analytics dashboard information for monitoring consumer usage metrics.
Get Latest Provider Analytics Dashboard VersionTool to retrieve the latest logical version of the provider analytics dashboard template.
Create ML ExperimentTool to create a new MLflow experiment for tracking machine learning runs and models.
Create Logged ModelTool to create a new logged model in MLflow that ties together model metadata, parameters, metrics, and artifacts.
Create MLflow Experiment RunTool to create a new MLflow run within an experiment for tracking machine learning execution.
Delete ML ExperimentTool to delete an MLflow experiment and associated metadata, runs, metrics, params, and tags.
Delete Logged ModelTool to delete a logged model from MLflow tracking.
Delete Logged Model TagTool to delete a tag from a logged model in MLflow.
Delete ML Experiment RunTool to mark an MLflow run for deletion in ML experiments.
Delete ML Experiment RunsTool to bulk delete runs in an ML experiment created before a specified timestamp.
Delete ML Experiment Run TagTool to delete a tag from an MLflow experiment run.
Finalize Logged ModelTool to finalize a logged model in MLflow by updating its status to READY or FAILED.
Get ML Experiment By NameTool to retrieve MLflow experiment metadata by name.
Get ML ExperimentTool to retrieve metadata for an MLflow experiment by ID.
Get Logged ModelTool to fetch logged model metadata by unique ID.
Get ML Experiment Permission LevelsTool to retrieve available permission levels for a Databricks ML experiment.
Get ML Experiment PermissionsTool to retrieve permissions for an MLflow experiment.
Get MLflow RunTool to retrieve complete information about a specific MLflow run including metadata, metrics, parameters, tags, inputs, and outputs.
Log Batch MLflow DataTool to log a batch of metrics, parameters, and tags for an MLflow run in a single request.
Log MLflow Dataset InputsTool to log dataset inputs to an MLflow run for tracking data sources used during model development.
Log Logged Model ParametersTool to log parameters for a logged model in MLflow.
Log MLflow MetricTool to log a metric for an MLflow run with timestamp.
Log MLflow ModelTool to log a model artifact for an MLflow run (Experimental API).
Log MLflow Dataset OutputsTool to log dataset outputs from an MLflow run for tracking data generated during model development.
Log MLflow ParameterTool to log a parameter for an MLflow run as a key-value pair.
Restore ML ExperimentTool to restore a deleted MLflow experiment and its associated metadata, runs, metrics, params, and tags.
Restore ML Experiment RunTool to restore a deleted MLflow run and its associated metadata, runs, metrics, params, and tags.
Restore ML Experiment RunsTool to bulk restore runs in an ML experiment that were deleted at or after a specified timestamp.
Search Logged ModelsTool to search for logged models in MLflow experiments based on various criteria.
Set ML Experiment TagTool to set a tag on an MLflow experiment.
Set Logged Model TagsTool to set tags on a logged model in MLflow.
Set ML Experiment PermissionsTool to set permissions for an MLflow experiment, replacing all existing permissions.
Set MLflow Run TagTool to set a tag on an MLflow run.
Update ML ExperimentTool to update MLflow experiment metadata, primarily for renaming experiments.
Update ML Experiment PermissionsTool to incrementally update permissions for an MLflow experiment.
Update ML Experiment RunTool to update MLflow run metadata including status, end time, and run name.
Delete ML Feature Engineering Kafka ConfigTool to delete a Kafka configuration from ML Feature Engineering.
Create ML Feature Store Online StoreTool to create a Databricks Online Feature Store for real-time feature serving.
Delete ML Feature Store Online StoreTool to delete an online store from ML Feature Store.
Delete ML Feature Store Online TableTool to delete an online table from ML Feature Store.
Create ML Forecasting ExperimentTool to create a new AutoML forecasting experiment for time series prediction.
Delete ML Feature TagTool to delete a tag from a feature in a feature table in ML Feature Store.
Get ML Feature TagTool to retrieve a specific tag from a feature in a feature table in ML Feature Store.
Set or Update ML Feature TagTool to set or update a tag on a feature in a feature table in ML Feature Store.
Get ML Model Registry Permission LevelsTool to retrieve available permission levels for a Databricks ML registered model.
Delete OAuth2 Service Principal SecretTool to delete an OAuth secret from a service principal at the account level.
Create OAuth Service Principal SecretTool to create an OAuth secret for service principal authentication.
Delete OAuth2 Service Principal Secret ProxyTool to delete an OAuth secret from a service principal.
Delete Databricks PipelineTool to delete a Databricks Delta Live Tables pipeline permanently and stop any active updates.
Get Pipeline Permission LevelsTool to retrieve available permission levels for a Databricks Delta Live Tables pipeline.
Get Pipeline PermissionsTool to retrieve permissions for a Databricks Delta Live Tables pipeline.
List Pipeline UpdatesTool to retrieve a paginated list of updates for a Databricks Delta Live Tables pipeline.
Update Pipeline PermissionsTool to incrementally update permissions on a Databricks pipeline.
Create Quality Monitor V2Tool to create a quality monitor for Unity Catalog table.
Get Databricks Job Run OutputTool to retrieve output and metadata of a single Databricks task run.
Search MLflow ExperimentsTool to search for MLflow experiments with filtering, ordering, and pagination support.
Search MLflow RunsTool to search for MLflow runs with filtering, ordering, and pagination support.
Create Provisioned Throughput EndpointTool to create a provisioned throughput serving endpoint for AI models in Databricks.
Delete Serving EndpointTool to delete a model serving endpoint and all associated data.
Get Serving Endpoint DetailsTool to retrieve detailed information about a specific serving endpoint by name.
Get Serving Endpoint OpenAPI SpecTool to retrieve the OpenAPI 3.
Get Serving Endpoint Permission LevelsTool to retrieve available permission levels for a Databricks serving endpoint.
Update Serving Endpoint Rate LimitsTool to update rate limits for a Databricks serving endpoint.
Update Serving Endpoint AI GatewayTool to update AI Gateway configuration of a Databricks serving endpoint.
Delete AI/BI Dashboard Embedding Access PolicyTool to delete AI/BI dashboard embedding access policy, reverting to default.
Get AI/BI Dashboard Embedding Access PolicyTool to retrieve workspace AI/BI dashboard embedding access policy setting.
Update AI/BI Dashboard Embedding Access PolicyTool to update AI/BI dashboard embedding workspace access policy at the workspace level.
Delete AI/BI Dashboard Embedding Approved DomainsTool to delete the list of approved domains for AI/BI dashboard embedding, reverting to default.
Get AI/BI Dashboard Embedding Approved DomainsTool to retrieve the list of domains approved to host embedded AI/BI dashboards.
Update AI/BI Dashboard Embedding Approved DomainsTool to update the list of domains approved to host embedded AI/BI dashboards at the workspace level.
Get Automatic Cluster Update SettingTool to retrieve automatic cluster update setting for the workspace.
Update Automatic Cluster Update SettingTool to update workspace automatic cluster update configuration with etag-based concurrency control.
Get Compliance Security Profile SettingTool to retrieve workspace compliance security profile setting.
Delete Dashboard Email Subscriptions SettingTool to delete the dashboard email subscriptions setting, reverting to default value.
Get Dashboard Email Subscriptions SettingTool to retrieve dashboard email subscriptions setting for the workspace.
Update Dashboard Email Subscriptions SettingTool to update the Dashboard Email Subscriptions setting for the workspace with etag-based concurrency control.
Delete Default Namespace SettingTool to delete the default namespace setting for the workspace, removing the default catalog configuration.
Get Default Namespace SettingTool to retrieve the default catalog namespace setting for the workspace.
Update Default Namespace SettingTool to update the default catalog namespace configuration for workspace queries with etag-based concurrency control.
Delete Default Warehouse ID SettingTool to delete the default warehouse ID setting for the workspace, reverting to default state.
Get Default Warehouse ID SettingTool to retrieve the default SQL warehouse ID setting for the workspace.
Update Default Warehouse ID SettingTool to update the default SQL warehouse configuration for the workspace with etag-based concurrency control.
Delete Disable Legacy Access SettingTool to delete the disable legacy access workspace setting, re-enabling legacy features.
Get Disable Legacy Access SettingTool to retrieve the disable legacy access workspace setting.
Update Disable Legacy Access SettingTool to update workspace disable legacy access setting with etag-based concurrency control.
Delete Disable Legacy DBFS SettingTool to delete the disable legacy DBFS workspace setting, reverting to default DBFS access behavior.
Get Disable Legacy DBFS SettingTool to retrieve the disable legacy DBFS workspace setting.
Update Disable Legacy DBFS SettingTool to update workspace disable legacy DBFS setting with etag-based concurrency control.
Get Enable Export Notebook SettingTool to retrieve workspace setting controlling notebook export functionality.
Update Enable Export NotebookTool to update workspace notebook and file export setting.
Get Enable Notebook Table Clipboard SettingTool to retrieve notebook table clipboard setting for the workspace.
Update Enable Notebook Table ClipboardTool to update workspace setting for notebook table clipboard.
Get Enable Results Downloading SettingTool to retrieve workspace setting controlling notebook results download functionality.
Update Enable Results DownloadingTool to update workspace notebook results download setting.
Get Enhanced Security Monitoring SettingTool to retrieve enhanced security monitoring workspace setting.
Update Enhanced Security MonitoringTool to update enhanced security monitoring workspace settings.
Create IP Access ListTool to create a new IP access list for workspace access control.
Get IP Access ListTool to retrieve details of a specific IP access list by its ID.
Delete LLM Proxy Partner Powered SettingTool to delete (revert to default) the partner-powered AI features workspace setting.
Get LLM Proxy Partner Powered SettingTool to retrieve workspace-level setting that controls whether partner-powered AI features are enabled.
Update LLM Proxy Partner Powered SettingTool to update workspace-level setting controlling whether AI features are powered by partner-hosted models with etag-based concurrency control.
Create Notification DestinationTool to create a notification destination for alerts and jobs.
Delete Notification DestinationTool to delete a notification destination from the Databricks workspace.
Get Notification DestinationTool to retrieve details of a notification destination by its UUID identifier.
Update Notification DestinationTool to update an existing notification destination configuration.
Delete Restrict Workspace Admins SettingTool to delete/revert the restrict workspace admins setting to its default state.
Get Restrict Workspace Admins SettingTool to retrieve the restrict workspace admins setting for the workspace.
Update Restrict Workspace Admins SettingTool to update the restrict workspace admins setting with etag-based concurrency control.
Delete SQL Results Download SettingTool to delete SQL results download workspace setting, reverting to default state where users are permitted to download results.
Get SQL Results Download SettingTool to retrieve SQL results download workspace setting.
Update SQL Results Download SettingTool to update workspace SQL results download setting controlling whether users can download results from SQL Editor and AI/BI Dashboards.
Delete Token via Token ManagementTool to delete a token specified by ID via token management.
Get Token InformationTool to retrieve detailed information about a specific token by its ID from the token management system.
Get Token Management Permission LevelsTool to retrieve available permission levels for personal access token management.
Get Token Management PermissionsTool to retrieve permissions for workspace token management.
Set Token Management PermissionsTool to set permissions for personal access token management, replacing all existing permissions.
Update Token Management PermissionsTool to incrementally update permissions for personal access token management.
Create Personal Access TokenTool to create a personal access token (PAT) for Databricks API authentication.
Get Public Workspace SettingTool to retrieve workspace-level settings by setting ID.
Set Workspace Configuration StatusTool to set workspace configuration settings for a Databricks workspace.
Create Sharing ProviderTool to create a new authentication provider in Unity Catalog for Delta Sharing.
Get Sharing ProviderTool to retrieve information about a specific Delta Sharing provider in Unity Catalog.
Update Sharing ProviderTool to update an existing Delta Sharing authentication provider in Unity Catalog.
Create Sharing RecipientTool to create a Delta Sharing recipient in Unity Catalog metastore.
Delete Sharing RecipientTool to delete a Delta Sharing recipient from Unity Catalog metastore.
Get Sharing RecipientTool to retrieve a Delta Sharing recipient from Unity Catalog metastore by name.
Create ShareTool to create a new share for data objects in Unity Catalog.
Delete ShareTool to delete a Unity Catalog share from the metastore.
Get Share DetailsTool to retrieve details of a specific share from Unity Catalog.
Get Share PermissionsTool to retrieve permissions for a Delta Sharing share from Unity Catalog.
Update ShareTool to update an existing share in Unity Catalog with changes to metadata or data objects.
Get Spark VersionsTool to retrieve all available Databricks Runtime and Spark versions for cluster creation.
Create SQL AlertTool to create a new Databricks SQL alert for query monitoring.
Delete SQL AlertTool to delete a Databricks SQL alert (soft delete to trash).
Get SQL Alert DetailsTool to retrieve details of a specific Databricks SQL alert by its UUID.
Create Legacy SQL AlertTool to create a legacy SQL alert that periodically runs a query and notifies when conditions are met.
Delete Legacy SQL AlertTool to permanently delete a legacy SQL alert (permanent deletion).
Get Legacy SQL AlertTool to retrieve details of a specific legacy SQL alert by its ID.
List Legacy SQL AlertsTool to list all legacy SQL alerts accessible to the authenticated user.
Update Legacy SQL AlertTool to update a legacy SQL alert configuration including name, query reference, trigger conditions, and notification settings.
Update SQL AlertTool to update an existing Databricks SQL alert using partial update with field mask.
Delete SQL DashboardTool to delete a legacy Databricks SQL dashboard by moving it to trash (soft delete).
Get SQL DashboardTool to retrieve complete legacy dashboard definition with metadata, widgets, and queries.
Update SQL DashboardTool to update legacy Databricks SQL dashboard attributes (name, run_as_role, tags).
Get SQL Object PermissionsTool to retrieve the access control list for a specified SQL object (alerts, dashboards, queries, or data_sources).
Set SQL Object PermissionsTool to set access control list for SQL objects (alerts, dashboards, queries, or data_sources).
Create SQL QueryTool to create a saved SQL query object in Databricks.
Delete SQL QueryTool to delete a Databricks SQL query (soft delete to trash).
Get SQL Query DetailsTool to retrieve detailed information about a specific SQL query by its UUID.
Create Legacy SQL QueryTool to create a new SQL query definition using the legacy API.
Delete Legacy SQL QueryTool to delete a legacy SQL query (soft delete to trash).
Get Legacy SQL QueryTool to retrieve details of a specific legacy SQL query by its UUID.
Restore SQL Query (Legacy)Tool to restore a trashed SQL query to active state.
Update Legacy SQL QueryTool to update an existing SQL query definition using the legacy API.
Update SQL QueryTool to update a saved SQL query object in Databricks using partial field updates.
List SQL Query HistoryTool to retrieve the history of SQL queries executed against SQL warehouses and serverless compute.
Create SQL Query VisualizationTool to create a new visualization for a Databricks SQL query.
Create Legacy SQL Query VisualizationTool to create a visualization in a SQL query using the legacy API.
Delete Legacy SQL Query VisualizationTool to permanently delete a legacy SQL query visualization.
Update Legacy SQL Query VisualizationTool to update a visualization in a SQL query using the legacy API.
Update SQL Query VisualizationTool to update an existing Databricks SQL query visualization using partial update with field mask.
Get Redash V2 ConfigTool to retrieve workspace configuration for Redash V2 in Databricks SQL.
Cancel SQL Statement ExecutionTool to cancel an executing SQL statement on a Databricks warehouse.
Delete SQL WarehouseTool to delete a SQL warehouse from the Databricks workspace.
Edit SQL WarehouseTool to update the configuration of an existing SQL warehouse.
Get SQL Warehouse DetailsTool to retrieve detailed information about a specific SQL warehouse by its ID.
Get SQL Warehouse Permission LevelsTool to retrieve available permission levels for a Databricks SQL warehouse.
Get SQL Warehouse PermissionsTool to retrieve permissions for a Databricks SQL warehouse.
Get Workspace Warehouse ConfigTool to retrieve workspace-level SQL warehouse configuration settings.
Set SQL Warehouse PermissionsTool to set permissions for a Databricks SQL warehouse, replacing all existing permissions.
Set Workspace Warehouse ConfigTool to configure workspace-level SQL warehouse settings shared by all SQL warehouses.
Start SQL WarehouseTool to start a stopped Databricks SQL warehouse asynchronously.
Update SQL Warehouse PermissionsTool to incrementally update permissions for a Databricks SQL warehouse.
Submit One-Time RunTool to submit a one-time run without creating a job.
Create Tag PolicyTool to create a new tag policy (governed tag) in Databricks with built-in rules for consistency and control.
Delete Tag PolicyTool to delete a tag policy by its key, making the tag ungoverned.
Get Tag PolicyTool to retrieve a specific tag policy by its associated governed tag's key.
Update Tag PolicyTool to update an existing tag policy (governed tag) with specified fields.
Update GroupTool to update a Databricks group using SCIM 2.
Delete Group CopyTool to delete a group from Databricks workspace using SCIM v2 protocol.
Update Databricks Job By IDTool to completely reset all settings for a Databricks job.
Update User by ID (PATCH)Tool to update a Databricks user by applying SCIM 2.
Create Vector Search EndpointTool to create a new vector search endpoint to host indexes in Databricks Mosaic AI Vector Search.
Delete Vector Search IndexTool to delete a vector search index from Databricks workspace.
Query Vector Search IndexTool to query vector search index to find similar vectors and return associated documents.
Upsert Data Vector IndexTool to upsert (insert or update) data into a Direct Vector Access Index.
Create Workspace Git CredentialsTool to create Git credentials for authenticating with remote Git repositories in Databricks.
Delete Workspace Git CredentialsTool to delete Git credentials for remote repository authentication in Databricks.
Get Workspace Git CredentialsTool to retrieve Git credentials for authenticating with remote Git repositories in Databricks.
Update Workspace Git CredentialsTool to update existing Git credentials for authenticating with remote Git repositories in Databricks.
List Workspace DirectoryTool to list the contents of a directory in Databricks workspace.
Create Workspace RepoTool to create and optionally checkout a Databricks Repo linking a Git repository to the workspace.
Delete Workspace RepoTool to delete a Git repository from Databricks workspace.
Get Workspace Repo Permission LevelsTool to retrieve available permission levels for a Databricks workspace repository.
Set Workspace Repo PermissionsTool to set permissions for a workspace repository, replacing all existing permissions.
Update Workspace RepoTool to update a workspace repo to a different branch or tag.
Update Workspace Repo PermissionsTool to incrementally update permissions on a Databricks workspace repository.
Create Secret ScopeTool to create a new secret scope in Databricks workspace.
Delete Secrets ACLTool to delete an access control list from a Databricks secret scope.
Delete Secret ScopeTool to delete a secret scope and all associated secrets and ACLs.
Delete Workspace SecretTool to delete a secret from a Databricks secret scope.
Get Secrets ACLTool to retrieve ACL details for a principal on a Databricks secret scope.
Get Secret ValueTool to get a secret value from a Databricks secret scope.
Put Secrets ACLTool to create or overwrite access control list for a principal on a Databricks secret scope.
Put Secret in ScopeTool to insert or update a secret in a Databricks secret scope.
Delete Workspace ObjectTool to permanently delete a workspace object or directory.
Export Workspace ObjectTool to export a workspace object (notebook, dashboard, or file) as file content or base64-encoded string.
Get Workspace Object StatusTool to retrieve status and metadata for any workspace object including notebooks, directories, dashboards, and files.
Import Workspace ObjectTool to import a notebook or file into the Databricks workspace.
Create Workspace DirectoryTool to create a directory and necessary parent directories in the workspace.

What is the Composio tool router, and how does it fit here?

What is Tool Router?

Composio's Tool Router helps agents find the right tools for a task at runtime. You can plug in multiple toolkits (like Gmail, HubSpot, and GitHub), and the agent will identify the relevant app and action to complete multi-step workflows. This can reduce token usage and improve the reliability of tool calls. Read more here: Getting started with Tool Router

The tool router generates a secure MCP URL that your agents can access to perform actions.

How the Tool Router works

The Tool Router follows a three-phase workflow:

  1. Discovery: Searches for tools matching your task and returns relevant toolkits with their details.
  2. Authentication: Checks for active connections. If missing, creates an auth config and returns a connection URL via Auth Link.
  3. Execution: Executes the action using the authenticated connection.

Step-by-step Guide

Prerequisites

Before you begin, make sure you have:
  • Python 3.8/Node 16 or higher installed
  • A Composio account with the API key
  • An OpenAI API key
  • A Databricks account and project
  • Basic familiarity with async Python/Typescript

Getting API Keys for OpenAI, Composio, and Databricks

OpenAI API key (OPENAI_API_KEY)
  • Go to the OpenAI dashboard
  • Create an API key if you don't have one
  • Assign it to OPENAI_API_KEY in .env
Composio API key and user ID
  • Log into the Composio dashboard
  • Copy your API key from Settings
    • Use this as COMPOSIO_API_KEY
  • Pick a stable user identifier (email or ID)
    • Use this as COMPOSIO_USER_ID

Installing dependencies

pip install composio-llamaindex llama-index llama-index-llms-openai llama-index-tools-mcp python-dotenv

Create a new Python project and install the necessary dependencies:

  • composio-llamaindex: Composio's LlamaIndex integration
  • llama-index: Core LlamaIndex framework
  • llama-index-llms-openai: OpenAI LLM integration
  • llama-index-tools-mcp: MCP client for LlamaIndex
  • python-dotenv: Environment variable management

Set environment variables

bash
OPENAI_API_KEY=your-openai-api-key
COMPOSIO_API_KEY=your-composio-api-key
COMPOSIO_USER_ID=your-user-id

Create a .env file in your project root:

These credentials will be used to:

  • Authenticate with OpenAI's GPT-5 model
  • Connect to Composio's Tool Router
  • Identify your Composio user session for Databricks access

Import modules

import asyncio
import os
import dotenv

from composio import Composio
from composio_llamaindex import LlamaIndexProvider
from llama_index.core.agent.workflow import ReActAgent
from llama_index.core.workflow import Context
from llama_index.llms.openai import OpenAI
from llama_index.tools.mcp import BasicMCPClient, McpToolSpec

dotenv.load_dotenv()

Create a new file called databricks_llamaindex_agent.py and import the required modules:

Key imports:

  • asyncio: For async/await support
  • Composio: Main client for Composio services
  • LlamaIndexProvider: Adapts Composio tools for LlamaIndex
  • ReActAgent: LlamaIndex's reasoning and action agent
  • BasicMCPClient: Connects to MCP endpoints
  • McpToolSpec: Converts MCP tools to LlamaIndex format

Load environment variables and initialize Composio

OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
COMPOSIO_API_KEY = os.getenv("COMPOSIO_API_KEY")
COMPOSIO_USER_ID = os.getenv("COMPOSIO_USER_ID")

if not OPENAI_API_KEY:
    raise ValueError("OPENAI_API_KEY is not set in the environment")
if not COMPOSIO_API_KEY:
    raise ValueError("COMPOSIO_API_KEY is not set in the environment")
if not COMPOSIO_USER_ID:
    raise ValueError("COMPOSIO_USER_ID is not set in the environment")

What's happening:

This ensures missing credentials cause early, clear errors before the agent attempts to initialise.

Create a Tool Router session and build the agent function

async def build_agent() -> ReActAgent:
    composio_client = Composio(
        api_key=COMPOSIO_API_KEY,
        provider=LlamaIndexProvider(),
    )

    session = composio_client.create(
        user_id=COMPOSIO_USER_ID,
        toolkits=["databricks"],
    )

    mcp_url = session.mcp.url
    print(f"Composio MCP URL: {mcp_url}")

    mcp_client = BasicMCPClient(mcp_url, headers={"x-api-key": COMPOSIO_API_KEY})
    mcp_tool_spec = McpToolSpec(client=mcp_client)
    tools = await mcp_tool_spec.to_tool_list_async()

    llm = OpenAI(model="gpt-5")

    description = "An agent that uses Composio Tool Router MCP tools to perform Databricks actions."
    system_prompt = """
    You are a helpful assistant connected to Composio Tool Router.
    Use the available tools to answer user queries and perform Databricks actions.
    """
    return ReActAgent(tools=tools, llm=llm, description=description, system_prompt=system_prompt, verbose=True)

What's happening here:

  • We create a Composio client using your API key and configure it with the LlamaIndex provider
  • We then create a tool router MCP session for your user, specifying the toolkits we want to use (in this case, databricks)
  • The session returns an MCP HTTP endpoint URL that acts as a gateway to all your configured tools
  • LlamaIndex will connect to this endpoint to dynamically discover and use the available Databricks tools.
  • The MCP tools are mapped to LlamaIndex-compatible tools and plug them into the Agent.

Create an interactive chat loop

async def chat_loop(agent: ReActAgent) -> None:
    ctx = Context(agent)
    print("Type 'quit', 'exit', or Ctrl+C to stop.")

    while True:
        try:
            user_input = input("\nYou: ").strip()
        except (KeyboardInterrupt, EOFError):
            print("\nBye!")
            break

        if not user_input or user_input.lower() in {"quit", "exit"}:
            print("Bye!")
            break

        try:
            print("Agent: ", end="", flush=True)
            handler = agent.run(user_input, ctx=ctx)

            async for event in handler.stream_events():
                # Stream token-by-token from LLM responses
                if hasattr(event, "delta") and event.delta:
                    print(event.delta, end="", flush=True)
                # Show tool calls as they happen
                elif hasattr(event, "tool_name"):
                    print(f"\n[Using tool: {event.tool_name}]", flush=True)

            # Get final response
            response = await handler
            print()  # Newline after streaming
        except KeyboardInterrupt:
            print("\n[Interrupted]")
            continue
        except Exception as e:
            print(f"\nError: {e}")

What's happening here:

  • We're creating a direct terminal interface to chat with your Databricks database
  • The LLM's responses are streamed to the CLI for faster interaction.
  • The agent uses context to maintain conversation history
  • You can type 'quit' or 'exit' to stop the chat loop gracefully
  • Agent responses and any errors are displayed in a clear, readable format

Define the main entry point

async def main() -> None:
    agent = await build_agent()
    await chat_loop(agent)

if __name__ == "__main__":
    # Handle Ctrl+C gracefully
    signal.signal(signal.SIGINT, lambda s, f: (print("\nBye!"), exit(0)))
    try:
        asyncio.run(main())
    except KeyboardInterrupt:
        print("\nBye!")

What's happening here:

  • We're orchestrating the entire application flow
  • The agent gets built with proper error handling
  • Then we kick off the interactive chat loop so you can start talking to Databricks

Run the agent

npx ts-node llamaindex-agent.ts

When prompted, authenticate and authorise your agent with Databricks, then start asking questions.

Complete Code

Here's the complete code to get you started with Databricks and LlamaIndex:

import asyncio
import os
import signal
import dotenv

from composio import Composio
from composio_llamaindex import LlamaIndexProvider
from llama_index.core.agent.workflow import ReActAgent
from llama_index.core.workflow import Context
from llama_index.llms.openai import OpenAI
from llama_index.tools.mcp import BasicMCPClient, McpToolSpec

dotenv.load_dotenv()

OPENAI_API_KEY = os.getenv("OPENAI_API_KEY")
COMPOSIO_API_KEY = os.getenv("COMPOSIO_API_KEY")
COMPOSIO_USER_ID = os.getenv("COMPOSIO_USER_ID")

if not OPENAI_API_KEY:
    raise ValueError("OPENAI_API_KEY is not set")
if not COMPOSIO_API_KEY:
    raise ValueError("COMPOSIO_API_KEY is not set")
if not COMPOSIO_USER_ID:
    raise ValueError("COMPOSIO_USER_ID is not set")

async def build_agent() -> ReActAgent:
    composio_client = Composio(
        api_key=COMPOSIO_API_KEY,
        provider=LlamaIndexProvider(),
    )

    session = composio_client.create(
        user_id=COMPOSIO_USER_ID,
        toolkits=["databricks"],
    )

    mcp_url = session.mcp.url
    print(f"Composio MCP URL: {mcp_url}")

    mcp_client = BasicMCPClient(mcp_url, headers={"x-api-key": COMPOSIO_API_KEY})
    mcp_tool_spec = McpToolSpec(client=mcp_client)
    tools = await mcp_tool_spec.to_tool_list_async()

    llm = OpenAI(model="gpt-5")
    description = "An agent that uses Composio Tool Router MCP tools to perform Databricks actions."
    system_prompt = """
    You are a helpful assistant connected to Composio Tool Router.
    Use the available tools to answer user queries and perform Databricks actions.
    """
    return ReActAgent(
        tools=tools,
        llm=llm,
        description=description,
        system_prompt=system_prompt,
        verbose=True,
    );

async def chat_loop(agent: ReActAgent) -> None:
    ctx = Context(agent)
    print("Type 'quit', 'exit', or Ctrl+C to stop.")

    while True:
        try:
            user_input = input("\nYou: ").strip()
        except (KeyboardInterrupt, EOFError):
            print("\nBye!")
            break

        if not user_input or user_input.lower() in {"quit", "exit"}:
            print("Bye!")
            break

        try:
            print("Agent: ", end="", flush=True)
            handler = agent.run(user_input, ctx=ctx)

            async for event in handler.stream_events():
                # Stream token-by-token from LLM responses
                if hasattr(event, "delta") and event.delta:
                    print(event.delta, end="", flush=True)
                # Show tool calls as they happen
                elif hasattr(event, "tool_name"):
                    print(f"\n[Using tool: {event.tool_name}]", flush=True)

            # Get final response
            response = await handler
            print()  # Newline after streaming
        except KeyboardInterrupt:
            print("\n[Interrupted]")
            continue
        except Exception as e:
            print(f"\nError: {e}")

async def main() -> None:
    agent = await build_agent()
    await chat_loop(agent)

if __name__ == "__main__":
    # Handle Ctrl+C gracefully
    signal.signal(signal.SIGINT, lambda s, f: (print("\nBye!"), exit(0)))
    try:
        asyncio.run(main())
    except KeyboardInterrupt:
        print("\nBye!")

Conclusion

You've successfully connected Databricks to LlamaIndex through Composio's Tool Router MCP layer. Key takeaways:
  • Tool Router dynamically exposes Databricks tools through an MCP endpoint
  • LlamaIndex's ReActAgent handles reasoning and orchestration; Composio handles integrations
  • The agent becomes more capable without increasing prompt size
  • Async Python provides clean, efficient execution of agent workflows
You can easily extend this to other toolkits like Gmail, Notion, Stripe, GitHub, and more by adding them to the toolkits parameter.

How to build Databricks MCP Agent with another framework

FAQ

What are the differences in Tool Router MCP and Databricks MCP?

With a standalone Databricks MCP server, the agents and LLMs can only access a fixed set of Databricks tools tied to that server. However, with the Composio Tool Router, agents can dynamically load tools from Databricks and many other apps based on the task at hand, all through a single MCP endpoint.

Can I use Tool Router MCP with LlamaIndex?

Yes, you can. LlamaIndex fully supports MCP integration. You get structured tool calling, message history handling, and model orchestration while Tool Router takes care of discovering and serving the right Databricks tools.

Can I manage the permissions and scopes for Databricks while using Tool Router?

Yes, absolutely. You can configure which Databricks scopes and actions are allowed when connecting your account to Composio. You can also bring your own OAuth credentials or API configuration so you keep full control over what the agent can do.

How safe is my data with Composio Tool Router?

All sensitive data such as tokens, keys, and configuration is fully encrypted at rest and in transit. Composio is SOC 2 Type 2 compliant and follows strict security practices so your Databricks data and credentials are handled as safely as possible.

Used by agents from

Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai
Context
Letta
glean
HubSpot
Agent.ai
Altera
DataStax
Entelligence
Rolai

Never worry about agent reliability

We handle tool reliability, observability, and security so you never have to second-guess an agent action.