Databricks MCP精灵
具有增强的Genie AI集成的模型上下文协议(MCP)服务器,可在AI助手(如Claude Desktop、Cursor)和copula工作区之间提供无缝的自然语言交互。
这有什么作用
使AI助手能够直接与您的copula工作区进行交互:
- 执行SQL查询并管理仓库
- 控制集群(创建、启动、停止、监视)
- 运行作业和笔记本
- 使用Genie AI提出自然语言问题
- 管理Unity目录(目录、模式、表)
- 使用DBFS、repos和库
快速开始
对于游标用户
推荐设置:无需手动安装!使用 uvx 自动运行服务器。
- 安装
uv(一次性):curl -LsSf https://astral.sh/uv/install.sh | sh - 通过以下方式配置光标MCP设置:
{
"command": "uvx",
"args": ["databricks-mcp-genie"]
}- 将您的copula凭据添加到
env章节
详细信息请参见 光标设置指南.
自动代码审查
该项目现在包括自动化的Claude Code PR审查!每个pull请求都会收到:
- 全面的代码质量分析
- 安全漏洞扫描
- 性能优化建议
- 最佳实践验证
PR会使用Claude支持的GitHub Actions自动审核。
先决条件
- Python 3.10或更高版本
- 带有个人访问令牌的Rancher工作区
- Cursor IDE、Claude Desktop或任何兼容MCP的客户端
安装
适用于MCP客户端(推荐): 无需手动安装!使用 uvx 在MCP客户端配置中,它会自动下载并运行服务器。
为了发展:
# Clone the repository
git clone https://github.com/sidart10/databrics-mcp-server.git
cd databrics-mcp-server
# Install with uv
uv sync配置
- 获取您的copula凭据:
- 工作区URL: https://your-workspace.cloud.databricks.com - 个人访问令牌:从用户设置>开发人员>访问令牌生成
- 配置MCP客户端:
对于光标:参见 光标设置指南 详细说明。
适用于克劳德桌面:编辑 ~/.config/Claude/claude_desktop_config.json:
{
"mcpServers": {
"databricks": {
"command": "uvx",
"args": ["databricks-mcp-genie"],
"env": {
"DATABRICKS_HOST": "https://your-workspace.cloud.databricks.com",
"DATABRICKS_TOKEN": "your-personal-access-token-here"
}
}
}
}备注:uvx(包括在内uv)自动下载并运行MCP服务器。无需手动安装!
- 重新启动克劳德桌面
验证安装
使用uvx (配置Cursor/Claude Desktop后):
- 重新启动MCP客户端
- 尝试:“列出我的ViewModel集群”
- 如果你看到结果,它正在发挥作用!
来源 (开发):
uv run -m databricks_mcp.main可用特征
9个API模块中的43个MCP工具
精灵AI(5个工具) -自然语言数据分析
list_genie_spaces-列出可用的Genie AI空间start_genie_conversation-用自然语言提问send_genie_followup-根据上下文继续对话get_genie_message_status-检查消息处理状态get_genie_query_results-从Genie检索SQL结果
集群API(6个工具)
list_clusters,create_cluster,get_clusterstart_cluster,terminate_cluster
SQL API(1个工具)
execute_sql-使用仓库运行SQL查询
工作API(9个工具)
list_jobs,create_job,delete_job,run_joblist_job_runs,get_run_status,cancel_runrun_notebook,sync_repo_and_run_notebook
笔记本API(5个工具)
list_notebooks,export_notebook,import_notebookdelete_workspace_object,get_workspace_file_content,get_workspace_file_info
DBFS API(3个工具)
list_files,dbfs_put,dbfs_delete
Unity目录API(7个工具)
list_catalogs,create_cataloglist_schemas,create_schemalist_tables,create_table,get_table_lineage
回购API(4个工具)
list_repos,create_repo,update_repo,pull_repo
库API(3个工具)
install_library,uninstall_library,list_cluster_libraries
用法示例
与Claude Desktop一起使用
配置后,您可以要求Claude与ViewModel交互:
"List all my running clusters"
"Execute this SQL query: SELECT * FROM my_catalog.my_schema.my_table LIMIT 10"
"Ask Genie: What were the top products by revenue last month?"
"Create a new job to run my ETL notebook daily"程序化使用
from databricks_mcp.server import DatabricksMCPServer
# Initialize server
server = DatabricksMCPServer()
# Use via MCP protocol
server.run()API直接使用
from databricks_mcp.api import clusters, genie, sql
# List clusters
clusters_list = await clusters.list_clusters()
# Ask Genie a question
response = await genie.start_conversation(
space_id="01efc298aabd1ae9bac6128988a6eaaa",
question="Show me revenue trends by product category"
)
# Execute SQL
results = await sql.execute_sql(
statement="SELECT * FROM sales.orders LIMIT 100",
warehouse_id="your-warehouse-id"
)项目结构
databrics-mcp-server/
├── databricks_mcp/ # Main Python package
│ ├── api/ # API modules (clusters, sql, genie, etc.)
│ ├── core/ # Core utilities and config
│ ├── server/ # MCP server implementation
│ └── cli/ # CLI commands
├── tests/ # Test suite
├── examples/ # Usage examples
├── scripts/ # Utility scripts
├── docs/ # Documentation
├── pyproject.toml # Package configuration
├── .mcp.json # MCP client configuration
└── test_server.sh # Quick server test故障排除
服务器无法启动
检查日志: databricks_mcp.log
常见问题:
- 中的凭据无效
.mcp.json - MCP配置中的Python路径不正确
- 缺少依赖项(运行
pip install -e ".[dev]")
导入错误
# Verify all imports work
.venv/bin/python -c "from databricks_mcp.server import DatabricksMCPServer"
.venv/bin/python -c "from databricks_mcp.api import clusters, sql, genie"连接问题
验证凭据:
export DATABRICKS_HOST="https://your-workspace.cloud.databricks.com"
export DATABRICKS_TOKEN="your-token"
.venv/bin/python -c "
from databricks_mcp.api import clusters
import asyncio
print(asyncio.run(clusters.list_clusters()))
"看 故障排除.md 详细的解决方案。
发展
运行测试
# All tests
.venv/bin/pytest tests/ -v
# Specific test file
.venv/bin/pytest tests/test_clusters.py -v
# With coverage
.venv/bin/pytest tests/ --cov=databricks_mcp代码质量
# Format code
.venv/bin/black databricks_mcp/
# Lint
.venv/bin/pylint databricks_mcp/添加新工具
- 在中添加API函数
databricks_mcp/api/ - 在中注册工具
databricks_mcp/server/databricks_mcp_server.py:
@self.tool(
name="your_tool_name",
description="What your tool does with parameters: param1 (required), param2 (optional)"
)
async def your_tool(params: Dict[str, Any]) -> List[TextContent]:
try:
actual_params = _unwrap_params(params)
result = await your_api_module.your_function(actual_params)
return [{"type": "text", "text": json.dumps(result)}]
except Exception as e:
logger.error(f"Error: {str(e)}")
return [{"type": "text", "text": json.dumps({"error": str(e)})}]文档
设置和安装
开发与出版
- 发布.md -如何发布到PyPI
- 故障排除.md -常见问题和解决方案
- ENHANCEMENTS.md -功能增强和路线图
需求
- Python>=3.10
- mcp\[cli\]>=1.2.0
- httpx
- sdk数据库
- pytest(开发)
- 黑色(dev)
- pylint(开发)
许可证
MIT许可证-有关详细信息,请参阅许可证文件
致谢
PyPI包: 数据块mcp精灵 源存储库: https://github.com/sidart10/databrics-mcp-server 维护人员: 西德 原作者: Olivier Debeuf De Rijker(数据图表mcp)
特别感谢:
- Olivier Debeuf De Rijker为原始数据包mcp实现
- 克劳德的拟人化和MCP协议
- 提供全面的SDK和Genie AI
- 开源社区
______________________________________________________________________
使用克劳德代码构建 -人工智能辅助开发工具Anthropic
