
PySpark MCP
io.github.AnnasMazhar由 GitHub 帳號 AnnasMazhar 發布v0.1.0更新於 Oct 24, 2026
SQL migration, AWS Glue job generation, and PySpark optimization as an MCP server.
概覽
本機 MCP 伺服器,把 SQL 轉成 PySpark 與 AWS Glue 原始碼文字,並審查既有 PySpark 程式碼,不執行 Spark。
- 可以做什麼
- 在 PostgreSQL、Oracle、Redshift、MySQL、Snowflake 與 Spark SQL 之間轉換 SQL,並產生 PySpark DataFrame API 原始碼文字
- 產生 AWS Glue 作業範本字串、DynamicFrame 轉換與 Data Catalog 定義
- 批次走訪 SQL 檔案或目錄並輸出轉換後的模組
- 審查 PySpark 原始碼中的反模式、重複片段並提供最佳化建議
- 注意:它不會啟動 SparkSession、提交 Glue 作業或執行 SQL,最佳化僅回傳建議
- 適用情境
- 適合在把 SQL 工作負載遷移到 Spark 或 Glue 時,讓助理草擬轉換程式碼、Glue 樣板程式碼與審查意見。若需要即時 Spark 工作階段內省、查詢執行或直接用 sqlglot 轉譯,則不必安裝。
- 執行需求
- 以 PyPI 套件 pyspark-tools 透過 stdio 在本機執行(uvx pyspark-tools 或 pip install pyspark-tools),需要 Python 3.11+。未宣告驗證、環境變數或標頭。選用附加套件提供 boto3 的 S3/Glue 輔助與 pyspark(僅用於產生程式碼)。
安裝
在 SourceWeft 中
- 開啟 儀表板中的 PySpark MCP,將其新增到工作區。
- 為需要使用其工具的對話啟用該服務。
Desktop only,透過 STDIO。 STDIO 服務會啟動本機處理程序,因此需要 SourceWeft 桌面主機。
其他 MCP 客戶端
參照 儲存庫 中的啟動說明。
README
PySpark MCP Server
SQL migration assistance, AWS Glue job template generation, and Spark code optimization — as an MCP server.
Not the live-Spark
pyspark-mcppackage. This project is SQL → PySpark / Glue source generation, published aspyspark-tools. SemyonSinchenko/pyspark-mcp introspects a running SparkSession. A deprecatedpyspark-mcpconsole script remains here so old configs keep working; it prints a warning, then starts this server.
[CI Pipeline] [Python 3.11+] [License: MIT]
What It Does
- SQL Dialect Transpilation — Convert between PostgreSQL, Oracle, Redshift, MySQL, Snowflake, and Spark SQL using SQLGlot
- PySpark DataFrame API Generation — Generate DataFrame API source text from SQL, with optimization hints
- AWS Glue templates — Job script strings, DynamicFrame conversions, Data Catalog definitions, S3 layout advice
- Batch Processing — Walk SQL files/directories and emit converted modules
- Code Review & Optimization — Pattern-based review of existing PySpark source
- Pattern Detection — Find duplicated snippets and suggest utilities
What It Doesn't Do
- Recursive CTEs → provides Spark SQL equivalent + guidance (PySpark has no native recursive CTE support)
- MERGE/PIVOT/CONNECT BY → transpiles to Spark SQL, provides DataFrame API guidance
- Perfect 1:1 DataFrame API transpilation for all SQL — complex queries get Spark SQL + recommendations
- It does not start a SparkSession, submit Glue jobs, or execute SQL
optimize(mode="code")returns suggestions; it does not rewrite your codeglue_s3is a path heuristic (no AWS call, no measured speedups)- It does not replace SemyonSinchenko/pyspark-mcp for live catalog/plans
Why this vs calling sqlglot yourself
SQLGlot already transpiles dialects. This MCP adds three things around that kernel: DataFrame-API pretty-printing with join/window/cast mappings that the conversion tests lock, Glue job boilerplate strings (bookmarks, DynamicFrames, catalog tables) so an agent can emit a file instead of assembling one, and a 14-tool FastMCP surface so an LLM picks convert / mode=sql instead of wiring sqlglot itself. If you only need sqlglot.transpile(...), use sqlglot.
Quick Start
Zero-clone alternative: uvx pyspark-tools. run_server.py is a development convenience that inserts sys.path and prints startup banners. Prefer pyspark-tools in configs and production.
Try it
Writes the same files as examples/out/. MCP stdio CLI: pyspark-tools.
Example: SQL → PySpark
Call convert with mode=sql. Captured converter output (dialect=spark):
Exact output depends on dialect detection and fallbacks; conversion tests in tests/test_sql_conversion_fixes.py pin the important constructs. Notebook-style import * / show() is opt-in via style="notebook" on the converter.
MCP Configuration
Claude Desktop
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Linux: ~/.config/Claude/claude_desktop_config.json
Hermes Agent
Add to ~/.hermes/config.yaml:
Docker
The image is stdio only (FastMCP over stdin/stdout). There is no HTTP server
on port 8000. docker compose up is for local tests, not a health-checkable
web service.
Tools
Three primary tools. The other eleven routers stay registered this minor
version but are deprecated — prefer convert, glue_job, and review.
convert — SQL → PySpark (including mode=batch_dir)
glue_job — Glue 5.0 job template strings
review — code review, patterns, duplicates
Legacy / deprecated: analyze, optimize, glue_schema, glue_s3,
glue_data, refactor, search, context, batch_status, s3_source,
analytics. Still callable; do not advertise to new agents.
Security
This MCP can read local files (SQL, TXT, PDF) and, if the [aws] extra is installed, list/read S3 with the host's default AWS credentials. File tools only allow paths under the process working directory (or an explicit base_path / FileHandler(base_directory=...)). That is not a sandbox.
Run the server under a restricted OS account. Do not point it at secrets directories. Do not attach AWS credentials with write access unless you intend S3 reads via s3_source / glue_s3. Optional extras:
Development
Requires Python 3.11+ (matches the CI matrix).
Architecture
License
MIT — see LICENSE.
mcp-name: io.github.AnnasMazhar/pyspark-mcp
來源:README.md,提交 a5694cd
工具
0版本歷史
2- v0.1.0最新Oct 18, 2026
- v0.0.4Sep 16, 2026
評分
已滿足適用檢查項的 50%
該評分衡量此收錄條目的完整程度,依據註冊中心條目、端點與公開來源計算得出。它不是對伺服器本身的評價,也不表示伺服器安全或目前可用:可連通性是帶日期的檢查結果,評分也不包含安裝量或使用者評價。
- 近 30 天內可連通25 分
請保持端點能夠回應 MCP 握手;SourceWeft 每 30 天探測一次。
- 已宣告認證方式10 分
請在註冊中心條目中宣告憑證請求標頭,或保持端點能夠回應探測,以便判定其認證方式。
- 已列出工具15 分
請讓伺服器在無憑證時回應 tools/list,或發布可在沙箱中無憑證啟動的軟體包。
- 描述必需15 分
- 圖示10 分
- 文件15 分
- 授權條款10 分