Minimal PySpark MCP server inspired by LakeSail for querying and analyzing Spark SQL data
The PySpark MCP server provides 16 read-only tools with consistent naming patterns and basic parameter descriptions. However, critical gaps in output schema documentation, parameter descriptions, and error handling significantly limit production readiness. All tools follow verb_noun conventions (get_, run_, list_, check_) which is positive. However, output schemas are not explicitly documented anywhere in the source code, and parameter descriptions are minimal (many are bare one-liners). Error handling is absent, no guidance on what to do if a query fails, a table doesn't exist, or a file is unreadable. The server is functional for basic PySpark introspection but falls short of production-grade tool quality.
Check if the database with a given name exists in the current Catalog
Extracts an analyzed logical plan from the provided SQL query
Get the catalog that is the default one for the current SparkSession
Get the current default database from the default Catalog
Extracts an optimized logical plan from the provided SQL query
Get the output schema of a SQL query
Get the version number from the current PySpark Sessiion
Output schemas not documented. Tools return JSON strings, lists, tuples, and booleans, but LLMs cannot plan downstream calls without knowing the structure of returned data. For example, run_sql_query returns a JSON array, but the schema of each record is not documented. get_size_estimation returns tuple[float, str] but this is not visible in any tool definition the LLM can see.
Parameter descriptions are bare minimal (1-10 words). Examples: 'SQL query to execute', 'Database name to check', 'Table name to get schema for'. These do not explain WHEN to use the tool, WHAT happens, or HOW to format input. LLMs need 10-50 word descriptions to reliably choose tools and format parameters correctly.
Inferred effective spec: <=2025-11-25.
| Scored | Grade | Overall | Spec posture | Rubric |
|---|---|---|---|---|
| 2026-09-22 | D | 50 | <=2025-11-25 | v2 |
| 2026-03-09 | F | 0 | - | v1 |
Extracts a size and units from the query plan explain
Extract comment of the table or returns an empty string
Get the schema of a table
Extracts all the tables (relations) from the query plan explain
List all the catalogs available in the current SparkSession
List all the available databases from the current Catalog
List all the available tables in the current Spark Catalog
Read the first n lines of a text file
Run the provided SQL query and return results as JSON
No error handling or recovery guidance. Tools like run_sql_query, get_table_schema, and read_n_lines_of_text_file can fail (invalid SQL, table not found, file I/O error) but provide no guidance on what the LLM should do next. No distinction between retryable errors (transient) and user-fixable errors (malformed query). Required by pattern:recovery-guide.
No input validation or constraints. The 'query' parameter in run_sql_query, get_analyzed_plan, and similar tools accepts free-form strings with no format documentation, length limit, or SQL dialect hint. LLMs may pass invalid SQL. The 'num_lines' parameter in read_n_lines_of_text_file is unbounded, LLM could request millions of lines, causing memory exhaustion.
Tool descriptions are very brief (under 50 chars for most). Examples: 'Get the current default database from the default Catalog', 'Get the catalog that is the default one for the current SparkSession'. These lack context on WHEN the LLM should call them vs similar tools (get_current_database vs get_current_catalog are easily confused).
Pagination not supported. list_databases, list_catalogs, and list_tables return all results with no limit or offset. If a Spark instance has thousands of databases or tables, these tools blow the context window. No ability to page, filter, or limit results.
read_n_lines_of_text_file returns a bare list of strings with no metadata (file_path, total_lines, was_truncated). Downstream tools cannot reliably understand whether they got the complete file or a truncated view.