| name | add-tools |
| description | Add tools to your agent and grant required permissions in databricks.yml. Use when: (1) Adding MCP servers, Genie spaces, vector search, or UC functions to agent, (2) Permission errors at runtime, (3) User says 'add tool', 'connect to', 'grant permission', (4) Configuring databricks.yml resources. |
Add Tools & Grant Permissions
After adding any MCP server to your agent, you MUST grant the app access in databricks.yml.
Without this, you'll get permission errors when the agent tries to use the resource.
Workflow
Step 1: Add MCP server in src/mcp-servers.ts:
import { DatabricksMCPServer } from "@databricks/langchainjs";
export function getMCPServers(): DatabricksMCPServer[] {
return [
DatabricksMCPServer.fromGenieSpace("01f1037ebc531bbdb27b875271b31bf4"),
];
}
Step 2: Grant access in databricks.yml:
resources:
apps:
agent_langchain_ts:
resources:
- name: 'f1_genie_space'
genie_space:
name: 'Formula 1 Race Analytics'
space_id: '01f1037ebc531bbdb27b875271b31bf4'
permission: 'CAN_RUN'
Step 3: Deploy with databricks bundle deploy (see deploy skill)
Resource Type Examples
See the examples/ directory for complete YAML snippets:
| File | Resource Type | When to Use |
|---|
uc-function.yaml | Unity Catalog function | UC functions via MCP |
uc-connection.yaml | UC connection | External MCP servers |
vector-search.yaml | Vector search index | RAG applications |
sql-warehouse.yaml | SQL warehouse | SQL execution |
serving-endpoint.yaml | Model serving endpoint | Model inference |
genie-space.yaml | Genie space | Natural language data |
experiment.yaml | MLflow experiment | Tracing (already configured) |
custom-mcp-server.md | Custom MCP apps | Apps starting with mcp-* |
Custom MCP Servers (Databricks Apps)
Apps are not yet supported as resource dependencies in databricks.yml. Manual permission grant required:
Step 1: Get your agent app's service principal:
databricks apps get <your-agent-app-name> --output json | jq -r '.service_principal_name'
Step 2: Grant permission on the MCP server app:
databricks apps update-permissions <mcp-server-app-name> \
--service-principal <agent-app-service-principal> \
--permission-level CAN_USE
See examples/custom-mcp-server.md for detailed steps.
TypeScript-Specific Patterns
Adding Multiple MCP Servers
Edit src/mcp-servers.ts:
export function getMCPServers(): DatabricksMCPServer[] {
const servers: DatabricksMCPServer[] = [];
servers.push(
DatabricksMCPServer.fromGenieSpace("01f1037ebc531bbdb27b875271b31bf4")
);
servers.push(
new DatabricksMCPServer({
name: "dbsql",
path: "/api/2.0/mcp/sql",
})
);
servers.push(
DatabricksMCPServer.fromUCFunction("main", "default")
);
servers.push(
DatabricksMCPServer.fromVectorSearch("main", "default", "my_index")
);
return servers;
}
LangChain Agent Pattern
The agent uses standard LangGraph createReactAgent API:
import { createReactAgent } from "@langchain/langgraph/prebuilt";
export async function createAgent(config: AgentConfig = {}) {
const tools = await getAllTools(config.mcpServers);
const agent = createReactAgent({
llm: model,
tools,
});
return new StandardAgent(agent, systemPrompt);
}
MCP Tool Types
| Tool Type | Use Case | MCP URL Pattern |
|---|
| Databricks SQL | Execute SQL queries on Unity Catalog tables | /api/2.0/mcp/sql |
| UC Functions | Call Unity Catalog functions as tools | /api/2.0/mcp/functions/{catalog}/{schema} |
| Vector Search | Semantic search over embeddings for RAG | /api/2.0/mcp/vector-search/{catalog}/{schema}/{index} |
| Genie Spaces | Natural language data queries | /api/2.0/mcp/genie/{space_id} |
Troubleshooting
See Troubleshooting Guide for common issues.
Quick tips:
- Permission errors: Check
databricks.yml and redeploy
- Tool not found: Verify
src/mcp-servers.ts and restart server
- MCP issues: See
mcp-known-issues.md and mcp-best-practices.md in this directory
Additional Resources
mcp-known-issues.md - Known MCP integration issues and status
mcp-best-practices.md - Correct implementation patterns for MCP tools
examples/ - YAML configuration examples for all resource types
Important Notes
- MLflow experiment: Already configured in template, no action needed
- Multiple resources: Add multiple entries under
resources: list
- Permission types vary: Each resource type has specific permission values
- Deploy after changes: Run
databricks bundle deploy after modifying databricks.yml
- Genie spaces: Use
CAN_RUN permission for Genie spaces
- Service principal: Deployed apps run as service principals and need explicit resource grants