Sparkforensics Mcp

io.github.shuffle-works由 GitHub 帳號 shuffle-works 發布v0.1.0更新於 Oct 24, 2026

MCP server for diagnosing Apache Spark event-log performance issues and comparing runs.

已驗證STDIO僅桌面開發者工具資料與分析

概覽

AI 產生的概覽

本機 MCP 伺服器,讓助理診斷 Apache Spark 事件日誌中的慢階段、資料傾斜、溢寫、GC 與失敗,並比較多次執行。

可以做什麼
  • 依事件日誌診斷 Spark 執行,提出有證據支撐的傾斜、shuffle、溢寫、GC 壓力、落後任務、冷啟動與失敗等問題
  • 彙整執行的指標與預算檢查結果
  • 比較同一作業的兩次執行,指出哪些階段出現退步
  • 列出分析可回報的偵測器類型
  • 從本機檔案或目錄讀取日誌,或在本機伺服器模式下從 Spark History Server 取得
適用情境
當你手上有 Spark 事件日誌,希望助理說明作業為何變慢、依預估實際耗時影響排序修正項目,或判斷新一次執行相對基準是否退步時適用。
執行需求
透過 npm 套件 sparkforensics-mcp 以本機程序方式執行(stdio);以 npx sparkforensics-server 啟動的本機伺服器也會在 /mcp 以 streamable HTTP 提供同一批工具。需要 Node 18 或更新版本。不需帳號或 API 金鑰。從 History Server 取得資料需本機伺服器模式,且 History Server 可連線。
安裝前請注意
分析會讀取事件日誌,其中可能包含應用程式名稱、主機名稱、IP 位址、使用者名稱、路徑與 SQL 文字;CLI 提供去識別化選項,但 README 說明其涵蓋範圍有限。從 Spark History Server 取得資料時,會向該伺服器送出不含憑證的請求。結論是標示了可信度的線索,而非確定的診斷。

安裝

在 SourceWeft 中

  1. 開啟 儀表板中的 Sparkforensics Mcp,將其新增到工作區。
  2. 為需要使用其工具的對話啟用該服務。

Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。

其他 MCP 客戶端

參照 儲存庫 中的啟動說明。

README

SparkForensics

[CI] [Coverage Status] [License: MIT]

Your Spark job is slow. SparkForensics tells you why, and what to do about it.

Drop a Spark event log in and get an evidence-backed breakdown of which stages are slow, why, and how to fix them. Nothing installs on your cluster and nothing leaves your machine.

Try it now → with your own event log. No install, no account, no upload. Read the documentation for a guided tour.

[Demo: dropping a Spark event log into SparkForensics and browsing its findings]

Spark's own History Server gives you raw metrics. It won't tell you that stage 14 spilled 40GB because of a skewed join key, or that cold start is eating a third of the job. SparkForensics reads the same event logs and turns them into findings.

Why SparkForensics

  • Your data stays on your machine. Drop a log file and read the dashboard; nothing is uploaded anywhere. Local-server mode adds a small Node companion that can also pull runs from a Spark History Server.
  • Event logs are streamed and parsed off the main thread in a Web Worker, so a 240MB+ (or multi-GB) NDJSON log doesn't freeze the tab.
  • The finding types cover skew, shuffle, spill, GC pressure, stragglers, cold start, cache/memory utilization, autoscaling churn, job/stage failures and partition sizing, plus a SQL Plan Advisor (duplicate subtrees, small files, broadcast sizing) and a config audit. Each has a page in the detector catalog, and its thresholds are in the detector table.
  • Fix These First orders every finding by its estimated wall-clock impact, not severity alone, so the top row is the fix worth doing first.
  • Run comparison (A/B) mode structurally matches stages across two runs of the same job and shows which stages regressed, rather than every difference.
  • Every finding tracks what it could and couldn't confirm from the log, so you know when to trust a flag and when it's a hint worth checking manually.
  • A headless CLI (sparkforensics-analyze) evaluates a run against budget thresholds (max runtime, skew, spill, failure rate...) and exits non-zero on violation, so a regression can fail a build. The run can come from a local event-log file/directory or, with --shs-base-url, fetched directly from a Spark History Server.
  • An MCP server (sparkforensics-mcp) exposes tools for diagnosing, summarizing and comparing runs, so an LLM agent can investigate a run directly. The full tool list is in MCP tools.
  • For running the analyze CLI automatically after every Spark job instead of by hand, see sparkforensics-operator, an Airflow operator that runs SparkForensics on a job's event log and acts on the result.

Unlike tools that need a cluster-side plugin or a running server plus an LLM agent (Spark History Server MCP tools), SparkForensics needs nothing installed anywhere else: the event log and a browser tab are enough.

Get started

Run the dashboard locally:

bash
npx sparkforensics-server

The Getting started guide covers what it serves, the live demo alternative, and loading a run. To work on SparkForensics itself, see Development.

For a one-shot check with no browser, the kind a CI pipeline can gate on:

bash
npx -p sparkforensics-cli sparkforensics-analyze path/to/eventlog --max-runtime 3600000 --max-skew 3

The command ships in the sparkforensics-cli package. To install it once instead: npm i -g sparkforensics-cli, then run sparkforensics-analyze directly. The sparkforensics-analyze alias package also works: npx sparkforensics-analyze.

That's a headless run against budget thresholds. See Command-line reference below for HTML export, Spark History Server fetching, baseline comparisons, and redaction. To run a detector check with your own threshold, see Tuning detector thresholds.

Development

Install and run

From a checkout:

bash
git clone [email protected]:shuffle-works/sparkforensics.gitcd sparkforensicsnpm installnpm run dev

Open the URL Vite prints. For a production bundle: npm run build, then serve dist/ with any static file server. Asset URLs are relative, so the bundle also works under a URL subpath.

Note: The app must be served over HTTP: file:// URLs block Web Worker module imports in Chrome.

Deploy modes

This app runs in two modes:

  • Static mode (e.g. GitHub Pages, or any plain file server): Choose file is the normal browser-local path for a single event log. Choose rolling-log folder is available only for an eventlog_v2_* directory. Deploy the output of npm run build from dist/. Fetching directly from a Spark History Server is not available: the browser's CORS policy blocks it and a static host can't proxy the request. If a History Server load cannot be used, choose a local event-log file instead.
  • Local-server mode is a small Node companion that serves this app and fetches from a Spark History Server on your behalf (server-to-server, so no browser CORS restriction). Useful when the SHS is behind a VPN or isn't CORS-configured.

Run local-server mode with:

bash
npx sparkforensics-server

It listens on http://127.0.0.1:4173 by default (override with --port or the PORT env var) and binds to localhost only. Open the URL in Chrome and use the Fetch from Spark History Server disclosure on the intake screen. The same server serves the MCP tools over streamable HTTP at /mcp, for clients on the same machine; see Connecting over HTTP.

History Server fetching requires local-server mode, a History Server reachable from the machine running that server, and a supported base application ID (see Getting started for the full list of accepted forms). Enter an optional attempt separately from the base application ID. The local server sends no credentials and follows no upstream redirects. Its recoverable errors intentionally omit upstream response details; edit the fields or choose a local event-log file to recover.

During development from a checkout, npm run local-server does the same thing without publishing or installing the package.

Server configuration

All settings have working defaults. The port (PORT or --port) and the SPARKFORENSICS_* environment variables are listed in Server configuration.

SHS-proxy route test fixture

The /shs-proxy route (packages/core/src/proxy.js) is covered by packages/server/test/shs-proxy-fixture.test.js, part of the normal npm run test:server suite. It loads a real event log from the spark-event-corpus-data git submodule at dev/log-corpus/ and asserts the route streams it back as a valid ZIP. No Docker, no live Spark process, and no live History Server are needed for this.

To verify the full Fetch-from-SHS UI flow by hand, including its unreachable-upstream and application-not-found recovery states, point npm run local-server at a real Spark History Server you have access to and use its Fetch from Spark History Server disclosure. Automated coverage of /shs-proxy uses the spark-event-corpus-data logs, so no Docker image or live Spark process is needed.

Running tests

bash
npm test              # single runnpm run test:watch    # watch modenpm test -- tests/finding-filter.test.js  # single filenpm run test:core     # packages/core: detectors, analyzer, parser, MCP toolsnpm run test:cli      # packages/clinpm run test:mcp      # packages/mcpnpm run test:server   # packages/server

Command-line reference

Beyond the plain budget check in Get started, the same sparkforensics-analyze CLI covers a few other jobs.

Write a self-contained HTML dashboard for the run instead of a JSON/Markdown report, viewable offline over file:// with no server:

bash
npx -p sparkforensics-cli sparkforensics-analyze path/to/eventlog --export-html path/to/output-dir

Fetch the run straight from a Spark History Server instead of a local file (mutually exclusive with the positional path):

bash
npx -p sparkforensics-cli sparkforensics-analyze --shs-base-url http://history-server:18080 --app-id application_1234_0001 --max-skew 3

Compare a candidate run against a baseline (A/B) and fail the build on a regression or a newly introduced critical finding:

bash
npx -p sparkforensics-cli sparkforensics-analyze path/to/candidate --baseline path/to/baseline --max-regression-pct 10 --fail-on-introduced critical

Several regression budgets in one call, and several candidates against one baseline (NDJSON, one line per candidate; the baseline is parsed once):

bash
npx -p sparkforensics-cli sparkforensics-analyze cand-1 cand-2 cand-3 --baseline base --regression-budget wallClock:10 --regression-budget gcTime:25

Compare against a baseline that lives on a Spark History Server, from a local candidate or a History Server one, with --baseline-shs-base-url, --baseline-app-id and --baseline-attempt-id (the baseline can be on a different server):

bash
npx -p sparkforensics-cli sparkforensics-analyze --shs-base-url http://history-server:18080 --app-id application_1234_0002 --baseline-shs-base-url http://history-server:18080 --baseline-app-id application_1234_0001 --max-regression-pct 10

Several candidates from one History Server take repeated --app-id values (--app-id <id>:<attempt> names an attempt) and print NDJSON, one line each.

See Several budgets and several candidates for the --budgets file, the NDJSON line fields and the exit code rules.

List every finding type the detectors can report, without reading a log (the MCP list_detectors tool returns the same records):

bash
npx -p sparkforensics-cli sparkforensics-analyze detectors --format md

Redact the app id, the app name, host names, IP addresses and user names in URLs and paths before sharing the output outside the environment that produced it. Other paths, table names and SQL text stay as written; the CI guide lists what --redact covers and what it does not:

bash
npx -p sparkforensics-cli sparkforensics-analyze path/to/eventlog --redact

Narrow the output's findings array to certain impact bands, types, or a stage (recommendations/cleanChecks/notRunChecks and the summary counts stay on the full, unfiltered set):

bash
npx -p sparkforensics-cli sparkforensics-analyze path/to/eventlog --impact critical,warning --type stageSlowness --stage 12

Other budget flags round out the checks: --max-spill <gb>, --max-failed-task-rate <pct>, and --min-efficiency <pct> (busy core time: the share of executor core time that ran tasks, 100 minus the dashboard's Unused core time, not its Efficiency tile). --attempt-id pairs with --shs-base-url/--app-id for a non-default attempt; --regression-metric picks which metric --max-regression-pct checks (default wallClock); --conf-keys and --conf-redact-regex shape the JSON output's effectiveConf block, next to its metrics block (both in Getting started); --format md switches output to Markdown (default json); --out <path> writes it to a file instead of stdout (its folder must exist, or the command exits 2). Exit codes: 0 pass, 1 a budget was violated, 2 usage error (bad flags, arguments or a --thresholds/--budgets file), 3 a budget was inconclusive (e.g. missing evidence for a regression check), 4 the candidate log can't be read or parsed, 5 the baseline log can't be read or parsed, 6 internal error. When several apply, the worst wins in the order 6, 5, 4, 1, 3, 0; with several candidates that means the worst line, and a candidate that can't be read or parsed gives its own line 4.

Node version: the published sparkforensics-cli, sparkforensics-mcp, and sparkforensics-server packages all pre-strip their vendored TypeScript to plain JS at publish time, so npx-installed use only needs Node >=18 (see each package's engines field). A checkout running any of the three straight off packages/*/bin/ against packages/core/src/*.ts (the monorepo dev-mode fallback) needs a Node version with native (unflagged) TypeScript type-stripping instead: >=22.18.0 on the Node 22 LTS line, or >=23.6.0 on Node 23+.

Learn more

The full documentation is published at shuffle-works.github.io/sparkforensics/docs.

Contributing

See CONTRIBUTING.md.

License

MIT

來源:README.md,提交 1b91a8a

工具

0
SourceWeft 尚未在沙箱中啟動過該軟體包,因此其工具未知。

版本歷史

1
  1. v0.1.0最新Sep 16, 2026

評分

已滿足適用檢查項的 50%

該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。

  • 近 30 天內可連通25 分

    請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。

  • 已宣告認證方式10 分

    請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。

  • 已列出工具15 分

    請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。

  • 描述必需15 分
  • 圖示10 分
  • 文件15 分
  • 授權條款10 分