Skip to content

fix: Add required 'type' field to MCP tool responses and remove unsupported version argument#8

Open
ddonghi wants to merge 1 commit into
JustTryAI:masterfrom
ddonghi:fix/mcp-output-schema-and-version-arg
Open

fix: Add required 'type' field to MCP tool responses and remove unsupported version argument#8
ddonghi wants to merge 1 commit into
JustTryAI:masterfrom
ddonghi:fix/mcp-output-schema-and-version-arg

Conversation

@ddonghi
Copy link
Copy Markdown

@ddonghi ddonghi commented May 5, 2026

Summary

This PR fixes two critical bugs that prevented all tools from working correctly:

  1. Missing type field in TextContent responses - All tool responses were missing the required type field, causing Pydantic validation errors
  2. Unsupported version argument - FastMCP.__init__() was called with a version argument that doesn't exist in the current MCP library

Bug #1: Missing 'type' field in TextContent responses

Error Message

Error executing tool list_clusters: 1 validation error for list_clustersOutput
result.0.type
  Field required [type=missing, input_value={'text': '{"clusters": [...'}, input_type=dict]

Root Cause

All tools returned [{"text": json.dumps(result)}] but the MCP TextContent specification requires [{"type": "text", "text": json.dumps(result)}].

Affected Tools (All 11 tools)

  • list_clusters
  • create_cluster
  • terminate_cluster
  • get_cluster
  • start_cluster
  • list_jobs
  • run_job
  • list_notebooks
  • export_notebook
  • list_files
  • execute_sql

Bug #2: Unsupported version argument

Error Message

TypeError: FastMCP.__init__() got an unexpected keyword argument 'version'

Root Cause

Line 37 in src/server/databricks_mcp_server.py passed version="1.0.0" and instructions to FastMCP.__init__(), but these arguments are not supported in the current version of the mcp library.

Changes Made

  1. Line 37-39: Removed version and instructions arguments from FastMCP.__init__()
  2. All return statements (22 occurrences): Added "type": "text" to all response dictionaries

Example Fix

- return [{"text": json.dumps(result)}]
+ return [{"type": "text", "text": json.dumps(result)}]

Testing

After applying these fixes, all tools work correctly:

  • list_clusters - Returns cluster information
  • list_notebooks - Returns workspace notebooks
  • list_files - Returns DBFS file listings
  • ✅ All other tools function as expected

Tested with:

  • mcp library version: 1.27.0
  • Python: 3.13.2
  • MCP Client: Claude Code

Additional Context

The MCP specification requires all TextContent objects to have a type field. See: https://modelcontextprotocol.io/

The FastMCP class in the current mcp library doesn't support version or instructions arguments in its __init__() method.

…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant