
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 分