Skip to content

feat(mcp): add typed Pydantic response schemas to generate_explore_link tool#39900

Open
gkneighb wants to merge 1 commit intoapache:masterfrom
gkneighb:feat/mcp-explore-link-pydantic-schemas
Open

feat(mcp): add typed Pydantic response schemas to generate_explore_link tool#39900
gkneighb wants to merge 1 commit intoapache:masterfrom
gkneighb:feat/mcp-explore-link-pydantic-schemas

Conversation

@gkneighb
Copy link
Copy Markdown

@gkneighb gkneighb commented May 6, 2026

SUMMARY

Replaces the untyped Dict[str, Any] return value of the MCP generate_explore_link tool with typed Pydantic response schemas, introducing two new models in superset/mcp_service/explore/schemas.py:

  • GenerateExploreLinkResponse — adds an explicit success field alongside url, form_data, form_data_key, and error, so callers no longer have to infer success from the absence of an error.
  • ExploreLinkError — structured error model with a machine-readable error_type discriminant (dataset_not_found, generation_failed, permission_denied), letting callers branch on failure mode without parsing free-text error messages.

The tool itself (generate_explore_link.py) now returns GenerateExploreLinkResponse. Tests were updated to use result.structured_content, which is the correct accessor when FastMCP tools return Pydantic models instead of plain dicts.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

N/A — backend/MCP-only change, no UI surface.

TESTING INSTRUCTIONS

  1. Run the unit tests for the tool:
    pytest superset/mcp_service/explore/tool/test_generate_explore_link.py -v
    
  2. Manually invoke the MCP generate_explore_link tool against a valid dataset and confirm the response is a structured object with success: true and a populated url.
  3. Invoke against an invalid dataset id and confirm the response includes success: false and an ExploreLinkError with error_type: "dataset_not_found".

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

…nk tool

Introduces `superset/mcp_service/explore/schemas.py` with two new schemas:
- `GenerateExploreLinkResponse` — replaces the raw `Dict[str, Any]` return,
  adding an explicit `success` field alongside `url`, `form_data`,
  `form_data_key`, and `error`.
- `ExploreLinkError` — structured error model with a machine-readable
  `error_type` discriminant (`dataset_not_found`, `generation_failed`,
  `permission_denied`) so callers can branch on failure mode without
  parsing free-text messages.

Updates `generate_explore_link.py` to return `GenerateExploreLinkResponse`
and updates tests to use `result.structured_content` (the correct accessor
when FastMCP tools return Pydantic models instead of plain dicts).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented May 6, 2026

Code Review Agent Run #c692a3

Actionable Suggestions - 0
Review Details
  • Files reviewed - 3 · Commit Range: c5152f1..c5152f1
    • superset/mcp_service/explore/schemas.py
    • superset/mcp_service/explore/tool/generate_explore_link.py
    • tests/unit_tests/mcp_service/explore/tool/test_generate_explore_link.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@dosubot dosubot Bot added the change:backend Requires changing the backend label May 6, 2026
@netlify
Copy link
Copy Markdown

netlify Bot commented May 6, 2026

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit c5152f1
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/69fabad2d4233f000828d2c6
😎 Deploy Preview https://deploy-preview-39900--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change:backend Requires changing the backend size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant