aminghadersohi opened a new pull request, #36458:
URL: https://github.com/apache/superset/pull/36458
### SUMMARY
Consolidates three separate schema discovery tools
(`get_chart_available_filters`, `get_dataset_available_filters`,
`get_dashboard_available_filters`) into a single unified `get_schema` tool that
returns comprehensive metadata for any model type.
#### Token Usage Improvement
**Tool Definition Overhead (loaded into LLM context each session):**
| Metric | Before | After | Savings |
|--------|--------|-------|---------|
| Number of tools | 3 | 1 | 67% fewer tools |
| Schema tokens | ~750 tokens | ~400 tokens | **~47% reduction** |
**Response Value (per API call):**
| Data Returned | Before | After |
|---------------|--------|-------|
| Filter columns | Yes | Yes |
| Select columns with metadata | No | Yes |
| Sortable columns | No | Yes |
| Default columns | No | Yes |
| Search columns | No | Yes |
| Column descriptions & types | No | Yes |
**Net Benefits:**
- **~350 fewer tokens** loaded per MCP session
- **5x richer** metadata per response
- LLMs can now discover valid `select_columns`, `order_column`, and `search`
parameters
- Eliminates trial-and-error for column names
#### Changes
**Added:**
- `get_schema` tool in `superset/mcp_service/system/tool/get_schema.py`
- `ModelGetSchemaCore` in `mcp_core.py` for reusable schema discovery logic
- `schema_discovery.py` with column metadata definitions for all model types
- Comprehensive unit tests (6 new tests) with edge case coverage
**Removed:**
- `get_chart_available_filters.py` (deprecated)
- `get_dataset_available_filters.py` (deprecated)
- `get_dashboard_available_filters.py` (deprecated)
- Associated filter-only schemas from each module
**Updated:**
- `app.py` instructions to reference new `get_schema` tool
- MCP service CLAUDE.md documentation
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
**Before (3 separate tools, limited info):**
```json
// get_chart_available_filters response
{"filter_columns": {"slice_name": ["eq", "sw"], "viz_type": ["eq", "in"]}}
```
**After (1 unified tool, comprehensive info):**
```json
// get_schema response for model_type="chart"
{
"schema_info": {
"model_type": "chart",
"select_columns": [
{"name": "id", "description": "Chart ID", "type": "int", "is_default":
true},
{"name": "slice_name", "description": "Chart name", "type": "str",
"is_default": true}
],
"filter_columns": {"slice_name": ["eq", "sw"], "viz_type": ["eq", "in"]},
"sortable_columns": ["id", "slice_name", "viz_type", "changed_on",
"created_on"],
"default_select": ["id", "slice_name", "viz_type", "uuid"],
"default_sort": "changed_on",
"default_sort_direction": "desc",
"search_columns": ["slice_name", "description"]
}
}
```
### TESTING INSTRUCTIONS
1. Start MCP server: `python -m superset.mcp_service.server`
2. Test via MCP client:
```python
# Get chart schema
result = await client.call_tool("get_schema", {"request": {"model_type":
"chart"}})
# Get dataset schema
result = await client.call_tool("get_schema", {"request": {"model_type":
"dataset"}})
# Get dashboard schema
result = await client.call_tool("get_schema", {"request": {"model_type":
"dashboard"}})
```
3. Run tests: `pytest tests/unit_tests/mcp_service/ -v`
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] 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
- [x] Removes existing feature or API
--
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]