fix: Add required 'type' field to MCP tool responses and remove unsupported version argument#8
Open
ddonghi wants to merge 1 commit into
Open
Conversation
…ported version argument
This commit fixes two critical bugs in the Databricks MCP server:
1. **Missing 'type' field in TextContent responses**: All tool responses were
returning `{"text": "..."}` but the MCP specification requires
`{"type": "text", "text": "..."}`. This caused validation errors when
MCP clients tried to process tool responses.
2. **Unsupported version argument**: The FastMCP.__init__() call included
a `version` argument that is not supported in the current version of
the mcp library, causing a TypeError on server initialization.
Changes:
- Added `"type": "text"` to all tool response dictionaries (11 tools fixed)
- Removed `version="1.0.0"` and `instructions` arguments from FastMCP init
- All tools now properly conform to the MCP TextContent specification
Fixes all tool execution errors including:
- list_clusters, create_cluster, terminate_cluster, get_cluster, start_cluster
- list_jobs, run_job
- list_notebooks, export_notebook
- list_files
- execute_sql
Tested with Claude Code and confirmed all tools now work correctly.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes two critical bugs that prevented all tools from working correctly:
typefield inTextContentresponses - All tool responses were missing the requiredtypefield, causing Pydantic validation errorsversionargument -FastMCP.__init__()was called with aversionargument that doesn't exist in the current MCP libraryBug #1: Missing 'type' field in TextContent responses
Error Message
Root Cause
All tools returned
[{"text": json.dumps(result)}]but the MCPTextContentspecification requires[{"type": "text", "text": json.dumps(result)}].Affected Tools (All 11 tools)
list_clusterscreate_clusterterminate_clusterget_clusterstart_clusterlist_jobsrun_joblist_notebooksexport_notebooklist_filesexecute_sqlBug #2: Unsupported version argument
Error Message
Root Cause
Line 37 in
src/server/databricks_mcp_server.pypassedversion="1.0.0"andinstructionstoFastMCP.__init__(), but these arguments are not supported in the current version of themcplibrary.Changes Made
versionandinstructionsarguments fromFastMCP.__init__()"type": "text"to all response dictionariesExample Fix
Testing
After applying these fixes, all tools work correctly:
list_clusters- Returns cluster informationlist_notebooks- Returns workspace notebookslist_files- Returns DBFS file listingsTested with:
mcplibrary version: 1.27.0Additional Context
The MCP specification requires all
TextContentobjects to have atypefield. See: https://modelcontextprotocol.io/The
FastMCPclass in the currentmcplibrary doesn't supportversionorinstructionsarguments in its__init__()method.