
Spark SQL
io.github.aidancorrell由 GitHub 账号 aidancorrell 发布v0.1.2更新于 Oct 24, 2026
Query Spark SQL clusters via Thrift/HiveServer2. Works with Spark, EMR, Hive, Impala.
概览
让助手通过 Thrift/HiveServer2 对 Spark、EMR、Hive 或 Impala 集群执行只读 SQL 查询并查看表结构。
- 可以做什么
- 连接到兼容 HiveServer2 的端点,提供四个工具:list_databases、list_tables、describe_table 和 execute_query。查询仅限只读语句(SELECT、SHOW、DESCRIBE、DESC、EXPLAIN、WITH),无限制的查询会自动加上 LIMIT,数据库错误在返回前会被脱敏。支持 NONE、LDAP、NOSASL、CUSTOM 和 Kerberos 认证。
- 适用场景
- 适合让助手在不打开独立 SQL 客户端的情况下浏览或查询已有的 Spark、EMR、Hive、Impala 或 Presto 数据仓库。适用于表结构发现和临时只读分析,不适用于写入或集群管理。
- 运行要求
- 需要本地 Python 运行环境,可通过 pip 安装或用 uvx 运行。必须设置 SPARK_HOST,可选 SPARK_PORT(默认 10000)、SPARK_DATABASE、SPARK_AUTH;LDAP 需要 SPARK_USERNAME 和 SPARK_PASSWORD,Kerberos 需要有效票据。需要能访问 Thrift 服务器,通常经由 SSH 隧道。
安装
在 SourceWeft 中
- 打开 控制台中的 Spark SQL,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
Spark SQL MCP Server
An MCP server that enables AI assistants to query Spark SQL clusters via the Thrift/HiveServer2 protocol.
Works with any HiveServer2-compatible system: Apache Spark, AWS EMR, Hive, Impala, Presto.
Features
- Query Spark SQL — Execute read-only SQL queries against your Spark cluster
- Schema Discovery — List databases, tables, and describe table structures
- Multiple Auth Methods — NONE, LDAP, NOSASL, CUSTOM, and Kerberos authentication
- EMR Compatible — Works with AWS EMR clusters out of the box
- Read-Only Enforcement — Only SELECT, SHOW, DESCRIBE, EXPLAIN, and WITH statements are allowed
- Safety Defaults — Automatic LIMIT clause on unbounded queries, sanitized error messages
Installation
Or run directly with uvx:
Quick Start
1. Set Environment Variables
2. Add to Claude Code
Global (all projects) — add to ~/.claude.json under your project's mcpServers:
Project-level — add to .claude/mcp.json in your repo:
3. Add to Claude Desktop
Add to your claude_desktop_config.json:
4. Query
Ask Claude things like:
- "What databases are available in our Spark cluster?"
- "Show me the schema of the
sales.transactionstable" - "Query the top 10 customers by revenue from the analytics database"
Available Tools
Authentication
No Auth (default)
LDAP
Kerberos
AWS EMR Setup
- Security Group — Allow inbound traffic on port 10000 from your IP
- SSH Tunnel (recommended):
- Set
SPARK_HOST=localhost
Development
Local Testing with Docker
A Docker Compose setup provides a local Spark Thrift Server with sample data for integration testing.
The local server comes with sample tables: default.employees, default.orders, and test_db.metrics.
Unit tests run by default with pytest (integration tests are skipped unless -m integration is specified).
Using the local server with Claude Code
With the Docker Spark server running, add it to your MCP config to test the server interactively.
Global — add to ~/.claude.json under your project's mcpServers:
Project-level — add to .claude/mcp.json:
Then start a new Claude Code session and ask it to query the sample data.
Security
Read-Only Enforcement
The execute_query tool only allows read-only SQL statements. Queries must start with one of: SELECT, SHOW, DESCRIBE, DESC, EXPLAIN, or WITH. All other statement types (DROP, INSERT, DELETE, CREATE, ALTER, SET, ADD JAR, etc.) are rejected before reaching the Spark cluster.
Error Sanitization
Database errors are sanitized before being returned to the MCP client. Internal details such as server hostnames, file paths, and stack traces are not exposed. Connection failures report only the target host/port and error type.
Credential Handling
- Passwords are never included in log output or error messages
- The
SparkConfigobject masks passwords in its string representation SPARK_PASSWORDis marked as a secret in the MCP registry schema
Known Limitations
- No TLS/SSL support — Thrift connections are unencrypted. For production use with LDAP auth, use an SSH tunnel to protect credentials in transit.
- No query timeout — Long-running queries are not automatically cancelled. Rely on Spark cluster-level timeout configuration.
- No per-user access control — All queries execute with the privileges of the configured Spark user. Use HiveServer2 authorization (Ranger, Sentry) to restrict access at the database level.
- Auth mode defaults to NONE — Appropriate for local development but not for production. Set
SPARK_AUTHtoLDAPorKERBEROSfor authenticated environments.
License
MIT
来源:README.md,提交 691cee7
工具
0版本历史
1- v0.1.2最新Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分