aminghadersohi opened a new pull request, #36933:
URL: https://github.com/apache/superset/pull/36933
### SUMMARY
Add a new MCP tool `get_embeddable_chart` that enables AI agents to create
ephemeral chart visualizations with guest token authentication. This allows
charts to be embedded in external applications (Claude Desktop, ChatGPT, remote
AI sessions) without persisting them to the database.
**Key Features:**
- **MCP Tool**: `get_embeddable_chart` creates chart iframes with guest
tokens
- **Ephemeral Charts**: Uses the permalink system with TTL (no database
persistence)
- **Guest Token Support**: New `CHART_PERMALINK` resource type for secure
embedding
- **StatefulChart Rendering**: Lightweight frontend component that handles
data fetching internally
**Architecture:**
```
MCP Client (AI Agent) → get_embeddable_chart tool
├── Creates permalink (KeyValue store + TTL)
├── Issues guest token (chart_permalink resource)
└── Returns iframe_url + guest_token + iframe_html
User opens iframe → /embedded/chart/?permalink_key=xxx
├── Validates guest token via Switchboard
├── Fetches formData from /api/v1/embedded_chart/<key>
└── Renders StatefulChart with formData
```
**Files Changed:**
- `superset/security/guest_token.py` - Add CHART_PERMALINK enum
- `superset/security/manager.py` - Add validation logic
- `superset/config.py` - Add EMBEDDABLE_CHARTS_MCP feature flag
- `superset/embedded_chart/` - New backend module (api, view, exceptions)
- `superset/mcp_service/embedded_chart/` - New MCP tool with schemas
- `superset-frontend/src/embeddedChart/` - New frontend entry point
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A - New feature, no UI changes to existing functionality
### TESTING INSTRUCTIONS
1. Enable the feature flag in `superset_config.py`:
```python
FEATURE_FLAGS = {
"EMBEDDABLE_CHARTS_MCP": True,
}
```
2. Use the MCP tool to create an embeddable chart:
```json
{
"datasource_id": 1,
"viz_type": "echarts_timeseries_line",
"form_data": {
"metrics": ["count"],
"groupby": ["category"],
"time_range": "Last 7 days"
},
"ttl_minutes": 60,
"height": 500
}
```
3. The tool returns `iframe_url`, `guest_token`, and `iframe_html`
4. The `iframe_html` can be embedded in external applications
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [x] Required feature flags: `EMBEDDABLE_CHARTS_MCP`
- [x] Changes UI
- [ ] Includes DB Migration (follow approval process in
[SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [x] Introduces new feature or API
- [ ] Removes existing feature or API
🤖 Generated with [Claude Code](https://claude.com/claude-code)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]