Skip to content

Add mcp server for eventlog analysis - #13059

Open
FelixYBW wants to merge 1 commit into
apache:mainfrom
FelixYBW:analysis_mcp
Open

FelixYBW wants to merge 1 commit into
apache:mainfrom
FelixYBW:analysis_mcp

Conversation

@FelixYBW

Copy link
Copy Markdown
Contributor

Enhance the benchmark analysis by introducing mcp_server. The mcp server uses a spark connect client to load data from event logs, then generate performance summary and query plan comparisons

Copilot AI lite review requested due to automatic review settings September 18, 2026 22:23
@github-actions github-actions Bot added the TOOLS label Sep 18, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🔵 Needs a closer look

It adds a network-facing command-executing service and report-serving pipeline with unresolved security and correctness issues.

Review effort: Lite
Findings: 7 High severity · 9 Medium severity · 2 Low severity

Open (18)
What changed in this PR

Adds an MCP-based Spark event-log analysis service under tools/mcp, providing metrics, query-plan visualization, and run comparisons.

Changes:

  • Adds FastMCP tools for event-log loading and performance analysis.
  • Adds PlantUML generators and HTML/Markdown comparison reports.
  • Adds usage documentation, dependencies, indexing, and file serving.
File Description
tools/​mcp/​server.py MCP server and analysis tool implementations
tools/​mcp/​script/​usage.md Tool usage documentation
tools/​mcp/​script/​requires.txt Python dependencies
tools/​mcp/​script/​plan_text_uml_generator.py Text-plan PlantUML generation
tools/​mcp/​script/​plan_rest_uml_generator.py REST-plan PlantUML generation
tools/​mcp/​script/​generate_operator_comparison.py Operator comparison reports
tools/​mcp/​script/​generate_index.py Report index generation
tools/​mcp/​script/​compare_query_plans_html.py Query-plan HTML comparisons
tools/​mcp/​script/​compare_hottest_stages.py Hottest-stage reports
tools/​mcp/​bin/​pretty_server.py Generated-file HTTP server

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

duckdb
itables
mysql-connector-python

Comment thread tools/mcp/server.py
Comment on lines +124 to +133
get_container_cmd = f'ssh centos@{driver_ip} "docker ps --format \'{{{{.Names}}}}\' | head -1"'
container_name = _sub.check_output(get_container_cmd, shell=True).decode().strip()
ssh_cmd = (
f'ssh centos@{driver_ip} '
f'"docker cp {container_name}:/opt/spark/events/{appid} /tmp/"'
)
_sub.run(ssh_cmd, shell=True, check=True)
# pull the file to local output/<appid>/<appid>
scp_cmd = f"scp centos@{driver_ip}:/tmp/{appid} {local_log}"
_sub.run(scp_cmd, shell=True, check=True)
Comment thread tools/mcp/server.py
Comment on lines +213 to +214
comparison_folder = appname1 + "-" + appname2
folder_name = _os.path.join(DEFAULT_OUTPUT_ROOT, comparison_folder)
Comment thread tools/mcp/server.py
Comment on lines +815 to +817
out_folder = os.path.join(_FILE_SERVER_ROOT, appid)
os.makedirs(out_folder, exist_ok=True)
puml_path = os.path.join(out_folder, f"{queryid}.puml")
Comment thread tools/mcp/server.py
Comment on lines +975 to +977
out_dir = os.path.join(_FILE_SERVER_ROOT, app_id)
os.makedirs(out_dir, exist_ok=True)
plan_file = os.path.join(out_dir, f"{query_id}.plan")
Comment thread tools/mcp/server.py
Comment on lines +280 to +282
base_url = f"http://127.0.0.1:6020/{run1_desc}-{run2_desc}"
comparison_url = f"{base_url}/comparison_{run1_id}_vs_{run2_id}.md#1-run-information"
operator_url = f"{base_url}/operator_comparison.md#runtime-summary"
Comment thread tools/mcp/server.py
Comment on lines +528 to +529
if stageid:
kwargs["stageid"] = stageid
Comment thread tools/mcp/server.py
Comment on lines +772 to +775
os.system(
f'java -Xmx1024m -DPLANTUML_LIMIT_SIZE=8192 '
f'-jar {_PLANTUML_JAR} "{puml_path}"'
)
Comment on lines +119 to +127
SKIP_PATTERNS = [
r'^InputAdapter$',
r'^InputIteratorTransformer$',
r'^AdaptiveSparkPlan$',
r'^WholeStageCodegenTransformer\s*\(\d+\)',
r'^AQEShuffleRead$',
r'^VeloxResizeBatches$',
r'^ReusedExchange$',
]
Comment thread tools/mcp/script/usage.md
| `run1_desc` | no | `""` | Short label for run 1 (no spaces). If omitted, call `get_comment_by_appid(run1_id)` first, derive a short description (replace spaces with underscores), and pass it here |
| `run2_desc` | no | `""` | Short label for run 2 (no spaces). If omitted, call `get_comment_by_appid(run2_id)` first, derive a short description (replace spaces with underscores), and pass it here |

**Returns:** URL to the generated comparison report, e.g. `http://127.0.0.1:5010/<run1_desc>-<run2_desc>/`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants