Problem
When a tool throws an exception, the middleware in databricks-mcp-server/databricks_mcp_server/middleware.py catches it and returns a ToolResult without structured_content. Because the tool has an outputSchema (auto-generated by FastMCP from return type annotations), the MCP SDK validation rejects the response with:
Output validation error: outputSchema defined but no structured output returned
This replaces the actual error message with a generic validation error, making debugging impossible. The user never sees the real exception.
Example
# execute_sql with a SQL syntax the Databricks API doesn't support
SELECT name FROM (LIST 's3://bucket/prefix/') WHERE name LIKE '%2026%'
Instead of seeing the actual SQL error, we get:
Output validation error: outputSchema defined but no structured output returned
Root Cause
PR #411 (beb7be5) attempted to fix this but hit a circular problem:
- Adding
structured_content to error responses → MCP SDK validates the error dict against the tool's outputSchema → fails because error shape doesn't match return type
- Omitting
structured_content from error responses → MCP SDK rejects because outputSchema exists but no structured output → generic error shown
The current code (v0.1.9) takes approach #2, which avoids crashes but swallows the real error.
Suggested Fix
Option A: Remove outputSchema from tool definitions entirely (tools can still return structured data without declaring a schema).
Option B: Define an error-aware outputSchema that accepts either the success type OR an error envelope via anyOf/oneOf.
Option C: Use isError=True on the ToolResult to signal the MCP SDK to skip outputSchema validation for error responses (if supported).
Impact
This affects every tool in the MCP server that has a return type annotation. Any exception is silently swallowed and replaced with the generic validation error. We've been debugging SQL queries, S3 operations, and job runs with zero visibility into actual failures.
Environment
- ai-dev-kit: v0.1.9
- fastmcp: 3.1.1 (also tested 3.2.3)
- mcp: 1.26.0 (also tested 1.27.0)
- Python: 3.11.14
- Claude Code (CLI)
Problem
When a tool throws an exception, the middleware in
databricks-mcp-server/databricks_mcp_server/middleware.pycatches it and returns aToolResultwithoutstructured_content. Because the tool has anoutputSchema(auto-generated by FastMCP from return type annotations), the MCP SDK validation rejects the response with:This replaces the actual error message with a generic validation error, making debugging impossible. The user never sees the real exception.
Example
Instead of seeing the actual SQL error, we get:
Root Cause
PR #411 (
beb7be5) attempted to fix this but hit a circular problem:structured_contentto error responses → MCP SDK validates the error dict against the tool's outputSchema → fails because error shape doesn't match return typestructured_contentfrom error responses → MCP SDK rejects because outputSchema exists but no structured output → generic error shownThe current code (v0.1.9) takes approach #2, which avoids crashes but swallows the real error.
Suggested Fix
Option A: Remove
outputSchemafrom tool definitions entirely (tools can still return structured data without declaring a schema).Option B: Define an error-aware outputSchema that accepts either the success type OR an error envelope via
anyOf/oneOf.Option C: Use
isError=Trueon theToolResultto signal the MCP SDK to skip outputSchema validation for error responses (if supported).Impact
This affects every tool in the MCP server that has a return type annotation. Any exception is silently swallowed and replaced with the generic validation error. We've been debugging SQL queries, S3 operations, and job runs with zero visibility into actual failures.
Environment