MCP Apache Spark History Server logo

MCP Apache Spark History Server

Organization
kubeflow

MCP Server and CLI for Apache Spark History Server. Debug Spark applications from AI agents, scripts, or the terminal.

Publisherkubeflow
Repositorymcp-apache-spark-history-server
LanguagePython
Forks
76
Stars
203
Available tools
0
Transport typestdio
LicenseApache-2.0
Links
  • Connect tools to AI workflows

    MCP Apache Spark History Server exposes MCP capabilities that can be used by compatible AI clients and agents.

  • 0 available tools

    Browse the callable actions below, including names and descriptions when provided by the server.

  • Ready-to-copy setup

    Use the installation snippets to configure this server in your preferred MCP client.

  • Open source signals

    203 stars and 76 forks from the linked repository.

Kubeflow Spark AI Toolkit

CI Python 3.12+ MCP License Kubeflow Slack

Connect AI agents and engineers to Apache Spark History Server for intelligent job analysis, performance monitoring, and investigation


[!IMPORTANT]

✨ NEW — Spark History Server CLI is now available

SHS CLI

A standalone Go binary that queries Spark History Server directly from your terminal — no MCP, no AI framework, no daemon process. Inspect jobs, compare runs, investigate failures, and script against the Spark REST API.

Get started with the SHS CLI →


This project provides two interfaces to your Spark History Server data:

🛠️ SHS CLI (shs)⚡ MCP Server
ForEngineers, shell scripts, CI/CD, coding agentsAI agents and MCP-compatible clients
Mental model"I know the command I want to run""Agent, investigate this Spark app"
InstallSingle static binary — no dependenciesPython 3.12+, uv
Get startedCLI docs →MCP docs →

📺 See it in action: Watch the demo video


🛠️ SHS CLI (shs) — For Engineers & Scripts

A standalone Go binary. Query your Spark History Server directly from the terminal, shell scripts, or CI/CD pipelines. Also works as a skill for coding agents like Claude Code and Kiro.

Install

bash
# Auto-detect latest version, OS, and architecture
VERSION=$(curl -s https://api.github.com/repos/kubeflow/mcp-apache-spark-history-server/releases | grep -m1 '"tag_name": "cli/' | cut -d'"' -f4 | sed 's|cli/||')
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
ARCH=$(uname -m)
[ "$ARCH" = "x86_64" ] && ARCH="amd64"
[ "$ARCH" = "aarch64" ] && ARCH="arm64"

curl -sSL "https://github.com/kubeflow/mcp-apache-spark-history-server/releases/download/cli%2F${VERSION}/shs-${VERSION}-${OS}-${ARCH}.tar.gz" | tar xz
sudo mv shs /usr/local/bin/

Quick Start

bash
# Generate a config file
shs setup config > config.yaml   # then set your Spark History Server URL

# Explore applications
shs apps
shs jobs -a APP_ID --status failed
shs stages -a APP_ID --sort duration
shs compare apps --app-a APP1 --app-b APP2

# Use as a skill with Claude Code or Kiro
shs setup skill > ~/.claude/skills/spark-history.md

CLI documentation for full usage, or check out a real-world example of Claude Code comparing two TPC-DS 3TB benchmark runs.


⚡ MCP Server — For AI Agents

An MCP (Model Context Protocol) server that exposes Spark History Server data as tools for AI agents. Agents query your Spark infrastructure using natural language — the server handles tool selection, multi-server routing, and structured data retrieval.

Use the MCP server when you want an AI agent to conduct multi-step investigations, synthesize findings across tools, or answer natural-language questions about your Spark applications.

Install

bash
# Run directly with uvx (no install needed)
uvx --from mcp-apache-spark-history-server spark-mcp

# Or install with pip
uv tool install mcp-apache-spark-history-server
spark-mcp

The package is published to PyPI.

Coding Agent Integration

Register the server with a single command. Both examples run it over stdio via uvx. With no config file present, the server defaults to a Spark History Server at http://localhost:18080; point it elsewhere with a config file or SHS_SERVERS__LOCAL__URL.

Claude Code (claude mcp add):

bash
claude mcp add --env SHS_MCP__TRANSPORT=stdio --env SHS_SERVERS__LOCAL__URL=http://localhost:18080\
  --transport stdio spark-history \
  -- uvx --from mcp-apache-spark-history-server spark-mcp

Kiro CLI (kiro-cli mcp add):

bash
kiro-cli mcp add --name spark-history --command uvx \
  --args --from --args mcp-apache-spark-history-server --args spark-mcp \
  --env SHS_MCP__TRANSPORT=stdio --env SHS_SERVERS__LOCAL__URL=http://localhost:18080

Verify in either client with claude mcp list / kiro-cli mcp list, then ask the agent to "list the available Spark applications."

The server also ships prompts — guided, multi-step workflows you run as a command. In Claude Code: /mcp__spark-history__investigate_failure <app_id>. In Kiro CLI: /prompts investigate_failure (or @investigate_failure). See Prompts for the full list and arguments.

Passing server flags and environment

The commands above have two layers: the client's own options and the arguments/environment forwarded to spark-mcp. spark-mcp itself takes a single flag, --config / -c; everything else is set through SHS_* environment variables.

To pass to spark-mcp…Claude CodeKiro CLI
A flag (e.g. --config)append after --: … spark-mcp --config /path/config.yamladd --args pairs: --args --config --args /path/config.yaml
An environment variable--env KEY=value (before --transport)--env KEY=value

For example, to point at a remote Spark History Server with an explicit config file:

bash
# Claude Code
claude mcp add --env SHS_MCP__TRANSPORT=stdio --transport stdio spark-history \
  -- uvx --from mcp-apache-spark-history-server spark-mcp --config ~/.config/spark-mcp/config.yaml

# Kiro CLI
kiro-cli mcp add --name spark-history --command uvx \
  --args --from --args mcp-apache-spark-history-server --args spark-mcp \
  --args --config --args ~/.config/spark-mcp/config.yaml \
  --env SHS_MCP__TRANSPORT=stdio

Configure

Basic configuration below. Create a file named config.yaml:

yaml
servers:
  local:
    default: true
    url: "http://your-spark-history-server:18080"
    auth:            # optional
      username: "user"
      password: "pass"
    include_plan_description: false   # include SQL plans by default (default: false)

mcp:
  transport: "streamable-http"   # or: stdio
  port: "18888"
  debug: false

Config file location

The server looks for its config file in the following order and uses the first one it finds:

  1. The --config / -c flag (e.g. spark-mcp --config /path/to/config.yaml)
  2. The SHS_MCP_CONFIG environment variable
  3. ./config.yaml in the current working directory
  4. ~/.config/spark-mcp/config.yaml (honors $XDG_CONFIG_HOME when set)

If none exist, the server starts with built-in defaults that can be overridden by SHS_* environment variables. When a path is given explicitly via the flag or SHS_MCP_CONFIG but the file is missing, the server fails fast instead of falling back.

Tip for MCP clients: when the server is launched by an MCP client (Claude Desktop, Kiro, etc.), the working directory is not guaranteed, so a ./config.yaml may not be found. Prefer --config / SHS_MCP_CONFIG, or place the file at ~/.config/spark-mcp/config.yaml.

Configurations can be overridden with environment variables. Nesting levels are separated by a double underscore (__), so field names and server names may themselves contain single underscores (e.g. SHS_SERVERS__MY_SERVER__URL maps to servers.my_server.url).

SHS_MCP__PORT          Port for MCP server (default: 18888)
SHS_MCP__TRANSPORT     Transport mode: streamable-http or stdio
SHS_MCP__DEBUG         Enable debug mode (default: false)
SHS_MCP__ADDRESS       Bind address (default: localhost)
SHS_SERVERS__*__URL     URL for a specific server
SHS_SERVERS__*__AUTH__USERNAME
SHS_SERVERS__*__AUTH__PASSWORD
SHS_SERVERS__*__AUTH__TOKEN
SHS_SERVERS__*__VERIFY_SSL
SHS_SERVERS__*__SSL_CA_CERT    Path to a PEM CA bundle for a specific server
SHS_SERVERS__*__TIMEOUT
SHS_SERVERS__*__EMR_CLUSTER_ARN
SHS_SERVERS__*__INCLUDE_PLAN_DESCRIPTION

Multi-Server Setup

Configure multiple Spark History Servers and route queries to specific ones:

yaml
servers:
  production:
    default: true
    url: "http://prod-spark-history:18080"
    auth:
      username: "user"
      password: "pass"
  staging:
    url: "http://staging-spark-history:18080"

Agents can target a specific server per query:

"Get application <app_id> from the production server"

Custom CA bundle

For a private CA or TLS-inspecting proxy, keep verify_ssl: true and point ssl_ca_cert to a mounted PEM bundle:

yaml
servers:
  local:
    ssl_ca_cert: "/etc/ssl/custom-ca/ca-bundle.pem"

Set the same path with SHS_SERVERS__LOCAL__SSL_CA_CERT. The CA certificates in the bundle are added to the container's default trust roots, so include the issuing CA and intermediates.

🏗️ Architecture

Connect an AI Agent

AgentTransportGuide
Claude DesktopstdioSetup →
Claude Codestdio or streamable-httpSetup →
Kirostreamable-httpSetup →
LangGraphstreamable-httpSetup →
Strands Agentsstreamable-httpSetup →
Local / Inspectorstreamable-httpSetup →

Available Tools (19)

Application Information

ToolDescription
list_applicationsList applications with optional status, date, and limit filters; pass app_id for a single application's detail (status, resources, duration, attempts). Returned applications always include their attempts.

Job Analysis

ToolDescription
list_jobsList jobs with status/job-id filtering and sorting (e.g. slowest by duration)

Stage Analysis

ToolDescription
list_stagesList stages with status filtering and sorting (e.g. slowest by duration)
get_stageStage detail with attempt and task metric distributions
list_stage_task_failuresFailed tasks of a stage with their error messages (exception/stack trace)

Executor & Resource Analysis

ToolDescription
list_executorsList executors with executor-id filtering and sorting (failed-tasks/duration/gc/id)
get_executor_summaryAggregate metrics across all executors
get_resource_usage_timelineChronological executor add/remove with resource totals
get_executor_thread_dumpJVM thread dump for a driver/executor, with state/name/blocked filters (running apps only)

Configuration & Environment

ToolDescription
get_environmentSpark config, JVM info, system properties, classpath; optional section filter to return a single part

SQL & Query Analysis

ToolDescription
list_sql_executionsList SQL executions as curated summaries, with status/description filters, sorting, and a default limit
get_sql_executionSQL execution header by default; opt-in plan, node metrics, job summaries, aggregated stage metrics, and stage list
compare_sql_executionsCompare aggregated performance metrics (stages, tasks, shuffle, spill, GC) between two SQL executions; opt-in plan-structure diff

Performance & Bottleneck Analysis

ToolDescription
get_job_bottlenecksIdentify bottlenecks across stages, tasks, and executors

Comparative Analysis

ToolDescription
compare_job_environmentsDiff Spark configs between two applications
compare_job_performanceDiff performance metrics between two applications
compare_stagesCompare two stages (optionally across applications): stage metrics and per-task p25/p50/p75/max quantiles

AWS Spark Troubleshooting (opt-in)

ToolDescription
aws_analyze_spark_workloadOne-shot root cause analysis of failed/slow Spark workloads
aws_spark_code_recommendationCode fix recommendations for identified Spark issues

Automatically available when AWS credentials and region are configured. See IAM setup guide.

Example Agent Queries

  • "Why is my ETL job running slower than yesterday?" → get_job_bottlenecks + list_stages + compare_job_performance
  • "What caused job 42 to fail?" → list_jobs + get_stage
  • "Compare today's batch with yesterday's run" → compare_job_performance + compare_job_environments
  • "Find my slowest SQL queries and explain why" → list_sql_executions + get_sql_execution + compare_sql_executions

Prompts (2)

Beyond tools, the server exposes MCP prompts — reusable, multi-step investigation workflows that your agent runs as a single command. Each prompt expands into a guided sequence of tool calls (which the agent still executes one at a time), so you get a consistent, evidence-driven analysis without having to remember the right tool order.

PromptArgumentsDescription
investigate_failureapp_id (required), server (optional)Guided root-cause investigation for a failed Spark application — walks from the failed app down to the individual task exceptions.
compare_applicationsapp_a (required), app_b (required), server (optional), context (optional)Layered, descriptive comparison of two applications (configuration → app metrics → SQL/jobs → stages).

server is optional: when omitted, the prompt searches every configured server for the application(s). Pass server="<name>" only to target a specific server or disambiguate an id that exists on more than one.

Using prompts in Claude Code

MCP prompts surface as slash commands with the format /mcp__<server>__<prompt> (note the double underscores), where <server> is the name you registered the server under (spark-history in the examples above). Type / to discover them, then pass arguments space-separated after the command:

text
# Investigate a failed application
/mcp__spark-history__investigate_failure spark-cc4d615a5e6b4500b8eb1e9deb48cb4e

# Target a specific configured server
/mcp__spark-history__investigate_failure spark-cc4d615a5e6b4500b8eb1e9deb48cb4e production

# Compare two applications
/mcp__spark-history__compare_applications spark-app-A spark-app-B

Using prompts in Kiro CLI

List and run prompts with the /prompts command, or type @ then Tab to autocomplete. Run a prompt by name and supply its arguments:

text
# Open the prompt picker (shows prompts from all MCP servers)
/prompts

# Run a prompt directly
/prompts investigate_failure

# Or use the @ shortcut
@investigate_failure

Kiro CLI prompts you for arguments interactively when the prompt declares them, so you can run /prompts investigate_failure and provide app_id (and optionally server) when asked.


📸 Screenshots

🔍 Get Spark Application

Get Application

⚡ Job Performance Comparison

Job Comparison


🚀 Kubernetes Deployment

Deploy the MCP server using Helm:

bash
helm install spark-history-mcp ./deploy/kubernetes/helm/mcp-apache-spark-history-server/

# Production configuration
helm install spark-history-mcp ./deploy/kubernetes/helm/mcp-apache-spark-history-server/ \
  --set replicaCount=3 \
  --set autoscaling.enabled=true

See deploy/kubernetes/helm/ for full configuration options.

When deployed in Kubernetes, connect Claude Desktop via mcp-remote:

bash
kubectl port-forward svc/spark-history-mcp 18888:18888

📔 AWS Integration

  • AWS Glue — Connect to Glue Spark History Server
  • Amazon EMR — Use EMR Persistent UI for Spark analysis
  • AWS Spark Troubleshooting — One-shot root cause analysis and code fix recommendations for failed Spark workloads (EMR EC2, EMR Serverless). Automatically available when AWS credentials and region are configured. See IAM setup guide for required permissions.

🔧 Development Setup

bash
git clone https://github.com/kubeflow/mcp-apache-spark-history-server.git
cd mcp-apache-spark-history-server

# Install Task runner
brew install go-task   # macOS; see https://taskfile.dev/installation/ for others

# MCP Server
task install           # install Python dependencies
task start-spark-bg    # start Spark History Server with sample data
task start-mcp-bg      # start MCP server
task start-inspector-bg  # open MCP Inspector at http://localhost:6274
task stop-all

# CLI
cd skills/cli
task build             # build ./bin/shs
task test              # unit tests
task test-e2e          # e2e tests (starts/stops Docker SHS automatically)
task start-shs         # start SHS with CLI e2e sample data

🌍 Adopters

Using this project? Add your organization to ADOPTERS.md and help grow the community.

🤝 Contributing

See CONTRIBUTING.md for guidelines.

📄 License

Apache License 2.0 — see LICENSE.

📝 Trademark Notice

Built for use with Apache Spark™ History Server. Not affiliated with or endorsed by the Apache Software Foundation.


Connect your Spark infrastructure to AI agents and engineers

🛠️ SHS CLI · ⚡ MCP Server · 🧪 Test · 🤝 Contribute

Built by the community, for the community 💙

Use MCP Apache Spark History Server MCP with multiple AI models

TypingMind connects MCP tools at the workspace level, so once MCP Apache Spark History Server is connected, you can use it with different AI models in TypingMind instead of setting it up separately for each model. This MCP runs locally through the TypingMind MCP connector on your device.

Setup guide to use the local connector

Use this when the MCP server needs access to local files, apps, or private resources on your computer.

1

Open the MCP settings

In TypingMind, go to Settings, Advanced Settings, then Model Context Protocol and choose Setup Connector.

  1. Open TypingMind in your browser.
  2. Click the Settings icon.
  3. Go to Advanced Settings.
  4. Open the Model Context Protocol section.
  5. Click Setup Connector and choose This Device.
TypingMind MCP connector setup screen with This Device selected
2

Run the connector command

Choose This Device, copy the command from TypingMind, and run it in Terminal. Keep the process running while you use MCP.

  1. Copy the setup command shown by TypingMind.
  2. Open Terminal on macOS or Windows Terminal on Windows.
  3. Paste and run the command.
  4. Approve the package install if Terminal asks you to proceed.
  5. Keep the Terminal window running while using MCP tools.
3

Add MCP Apache Spark History Server as a server

When the connector status is Ready, click Edit Servers and paste the MCP server configuration.

  1. Wait until the connector status shows Ready.
  2. Click Edit Servers.
  3. Paste the MCP Apache Spark History Server MCP server configuration.
  4. Save the server list.
  5. Refresh if you want to confirm the connector is still ready.
TypingMind MCP settings showing active server and Edit Servers button
{
  "mcpServers": {
    "mcp-apache-spark-history-server": {
      "command": "npx",
      "args": [
        "-y",
        "<mcp-server-package>"
      ]
    }
  }
}
4

Use it across models

Save the server list, open Plugins, enable the MCP Apache Spark History Server MCP tools, then select any supported AI model in TypingMind and use the tools in chat or assign them to an AI agent.

  1. Open the Plugins page in TypingMind.
  2. Enable the MCP Apache Spark History Server MCP tools.
  3. Start a chat and choose the AI model you want to use.
  4. Use the MCP tools in chat or assign them to an AI agent.
  5. Switch to another AI model whenever needed without reconnecting MCP.
TypingMind chat using enabled MCP tools with a selected AI model
Can you use MCP Apache Spark History Server to help me with this task?
MCP Apache Spark History Server
Sure. I read it.
Here is what I found using MCP Apache Spark History Server.

Frequently asked questions

What is the MCP Apache Spark History Server MCP server used for?

MCP Apache Spark History Server is an MCP server that lets compatible AI clients connect to external tools and context. In TypingMind, you can add this MCP server once and make its tools available in your AI workspace.

Can I use MCP Apache Spark History Server MCP with multiple AI models in TypingMind?

Yes. TypingMind connects MCP tools at the workspace level, so you can use MCP Apache Spark History Server with different AI models such as Claude, ChatGPT, Gemini, or other models you have configured in TypingMind without setting up the MCP server separately for each model.

Why use MCP Apache Spark History Server MCP with TypingMind?

TypingMind is one of the best frontends for LLM chat because it brings multiple AI models, prompts, plugins, AI agents, API keys, and MCP tools into one workspace. With MCP Apache Spark History Server connected, you can use its MCP tools across your preferred models while keeping your chat workflow organized in TypingMind.

How do I connect MCP Apache Spark History Server MCP to TypingMind?

MCP Apache Spark History Server runs through the TypingMind local MCP connector. This is best when the MCP server needs access to local files, desktop apps, command-line tools, or private resources on your computer.

What tools does MCP Apache Spark History Server MCP provide in TypingMind?

MCP Apache Spark History Server exposes MCP capabilities that can be enabled from the TypingMind Plugins page and used in chat or assigned to AI agents.

Do I need to share my API keys with TypingMind to use MCP Apache Spark History Server MCP?

No. TypingMind is local-first and lets you keep your model providers, API keys, prompts, and MCP configuration under your control. If MCP Apache Spark History Server requires authentication, add the required headers, OAuth settings, or local configuration for that MCP server when you create the connection.

Related MCP Servers

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇