Spark SQL MCP Server
Connects to Apache Spark clusters (including AWS EMR and other HiveServer2-compatible endpoints) over the Thrift/HiveServer2 protocol to run read-only SQL queries, list databases and tables, and describe table schemas, with support for NONE, LDAP, NOSASL and Kerberos authentication.
Can query Presto clusters that expose a HiveServer2-compatible interface, executing read-only SQL statements and performing schema discovery (listing databases/tables and describing table structures).
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@Spark SQL MCP Servershow me the schema of the sales.transactions table"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
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
Related MCP server: VAST DB MCP Server
Installation
pip install spark-sql-mcp-serverOr run directly with uvx:
uvx spark-sql-mcp-serverQuick Start
1. Set Environment Variables
export SPARK_HOST="your-emr-master-node.amazonaws.com"
export SPARK_PORT="10000" # default
export SPARK_DATABASE="default" # default
export SPARK_AUTH="NONE" # NONE | LDAP | KERBEROS | CUSTOM | NOSASL2. Add to Claude Code
Global (all projects) — add to ~/.claude.json under your project's mcpServers:
{
"mcpServers": {
"spark-sql": {
"command": "uvx",
"args": ["spark-sql-mcp-server"],
"env": {
"SPARK_HOST": "your-emr-master-node.amazonaws.com",
"SPARK_PORT": "10000",
"SPARK_AUTH": "NONE"
}
}
}
}Project-level — add to .claude/mcp.json in your repo:
{
"mcpServers": {
"spark-sql": {
"command": "uvx",
"args": ["spark-sql-mcp-server"],
"env": {
"SPARK_HOST": "your-emr-master-node.amazonaws.com",
"SPARK_PORT": "10000",
"SPARK_AUTH": "NONE"
}
}
}
}3. Add to Claude Desktop
Add to your claude_desktop_config.json:
{
"mcpServers": {
"spark-sql": {
"command": "uvx",
"args": ["spark-sql-mcp-server"],
"env": {
"SPARK_HOST": "your-emr-master-node.amazonaws.com",
"SPARK_PORT": "10000"
}
}
}
}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
Tool | Description |
| List all available databases |
| List tables in a database |
| Get table schema (columns, types) |
| Run read-only SQL queries with formatted results |
Authentication
No Auth (default)
export SPARK_AUTH="NONE"LDAP
export SPARK_AUTH="LDAP"
export SPARK_USERNAME="your-username"
export SPARK_PASSWORD="your-password"Kerberos
export SPARK_AUTH="KERBEROS"
export SPARK_KERBEROS_SERVICE_NAME="hive" # default
# Ensure you have a valid Kerberos ticket (kinit)AWS EMR Setup
Security Group — Allow inbound traffic on port 10000 from your IP
SSH Tunnel (recommended):
ssh -i your-key.pem -L 10000:localhost:10000 hadoop@your-emr-masterSet
SPARK_HOST=localhost
Development
git clone https://github.com/aidancorrell/spark-sql-mcp-server.git
cd spark-sql-mcp-server
pip install -e ".[dev]"
pytest
ruff check .Local Testing with Docker
A Docker Compose setup provides a local Spark Thrift Server with sample data for integration testing.
# Start the Spark Thrift Server
cd docker && docker compose up -d
# Wait for it to be ready (takes ~30s on first start)
docker logs -f spark-thrift-server # look for "Sample data loaded."
# Run integration tests
pytest -m integration -v
# Tear down
cd docker && docker compose down -vThe 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:
{
"spark-sql": {
"command": "uvx",
"args": ["spark-sql-mcp-server"],
"env": {
"SPARK_HOST": "localhost",
"SPARK_PORT": "10000",
"SPARK_AUTH": "NONE"
}
}
}Project-level — add to .claude/mcp.json:
{
"mcpServers": {
"spark-sql": {
"command": "uvx",
"args": ["spark-sql-mcp-server"],
"env": {
"SPARK_HOST": "localhost",
"SPARK_PORT": "10000",
"SPARK_AUTH": "NONE"
}
}
}
}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 representationSPARK_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
This server cannot be deployed
Maintenance
Related MCP Connectors
Query Postgres, MySQL, SQL Server, Oracle, BigQuery, ClickHouse and Redshift from your AI client.
Query your org's data in natural language — read-only MCP access to SQL, NoSQL, files & warehouses.
Safe, read-only Postgres and MySQL access for AI agents. Audit log + column-level controls.
Query 40 databases from Claude, ChatGPT, or Cursor — on any device. Read-only, encrypted, audited.
Related MCP Servers
- AlicenseAqualityCmaintenanceProvides secure, read-only access to Snowflake data warehouses, enabling AI assistants to explore schemas, write queries, and analyze data with SSO authentication and smart caching.65 npm5MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI agents to securely query VAST Data databases for schema, metadata, and sample data via read-only SQL and MCP resources.MIT
- AlicenseNot gradedqualityDmaintenanceEnables AI assistants to execute SQL queries and explore databases, tables, and catalogs on Databricks using Unity Catalog.1MIT
- AlicenseNot gradedqualityBmaintenanceEnables secure, read-only access to Amazon Redshift data warehouses for AI assistants, allowing schema inspection, query execution, and data understanding.31 npm1MIT