Skip to content

fix: serialize dict fields as JSON strings in Superset API payloads - #2

Open
alionar wants to merge 1 commit into
herryg91:mainfrom
alionar:fix-json-string-payload-encoding
Open

fix: serialize dict fields as JSON strings in Superset API payloads#2
alionar wants to merge 1 commit into
herryg91:mainfrom
alionar:fix-json-string-payload-encoding

Conversation

@alionar

@alionar alionar commented Apr 22, 2026

Copy link
Copy Markdown

Summary

mcp_superset/client.py sends params, json_metadata, and position_json to Superset as Python dicts. Those fields require JSON-encoded strings, so every chart and dashboard create/update returns HTTP 400 "Not a valid string.".

Fixes

  • create_chart / update_chart: json.dumps(params) before sending. The reported bug.
  • create_dashboard / update_dashboard: same for json_metadata and position_json.
  • add_chart_to_dashboard: Superset returns position_json as a string. The old isinstance(x, dict) check fails for every real dashboard and resets the layout to {}, which would wipe the dashboard on the next add. New code parses, mutates, re-serializes.
  • update_dashboard_filters: /api/v1/dashboard/{id}/filters does not exist on 4.x and uses a different shape on 6.x ({deleted, modified, reordered}). I rewrote this through json_metadata via the main dashboard PUT, which works on every version.

Test plan

  • Line chart via superset_create_chart. Before: 400. After: new chart id.
  • superset_add_chart_to_dashboard twice: second call leaves the first chart in place.
  • superset_update_dashboard_filters with one filter_select: filter appears in the UI.

Public MCP signatures unchanged. Serialization sites accept dict, list, or pre-stringified JSON.

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