aminghadersohi opened a new pull request, #36063:
URL: https://github.com/apache/superset/pull/36063
### SUMMARY
This PR addresses two improvements to the MCP (Model Context Protocol)
service:
1. **Fixes MCP client validation errors for `health_check` tool**
- Added `GetHealthCheckRequest` parameter to `health_check` tool
- Prevents validation errors when MCP clients (like Claude Desktop) call
the tool with empty objects: `1 validation error for call[health_check] request
Unexpected keyword argument`
- Follows same pattern as `get_instance_info` tool which already has this
fix
2. **Refactors system utils for better code organization**
- Created `superset/mcp_service/system/system_utils.py` module
- Moved helper functions from `get_instance_info.py` to the new utils
module:
- `calculate_dashboard_breakdown`
- `calculate_database_breakdown`
- `calculate_instance_summary`
- `calculate_recent_activity`
- `calculate_popular_content`
- Updated `get_instance_info.py` to import from `system_utils`
- Follows established pattern used in `chart/`, `dashboard/`, and
`sql_lab/` modules
3. **Added comprehensive unit tests**
- Tests for `GetHealthCheckRequest` schema validation
- Tests for `HealthCheckResponse` schema
- Tests verify MCP client compatibility (empty object acceptance)
- All tests passing
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
N/A - Backend changes only
### TESTING INSTRUCTIONS
**Prerequisites:**
- Set up Superset development environment
- Activate Python virtual environment
**Running the tests:**
```bash
# Run health_check unit tests
PYTHONPATH=. pytest
tests/unit_tests/mcp_service/system/tool/test_health_check.py -v
# Run all MCP system tests
PYTHONPATH=. pytest tests/unit_tests/mcp_service/system/ -v
# Verify pre-commit hooks pass
git add .
pre-commit run --files superset/mcp_service/system/tool/health_check.py
superset/mcp_service/system/schemas.py
superset/mcp_service/system/system_utils.py
superset/mcp_service/system/tool/get_instance_info.py
tests/unit_tests/mcp_service/system/tool/test_health_check.py
superset/mcp_service/system/__init__.py
```
**Expected results:**
- All unit tests pass
- Pre-commit hooks pass (mypy, ruff, pylint)
- No validation errors when MCP clients call `health_check` with empty
request objects
**Testing with MCP client (optional):**
If you have an MCP client like Claude Desktop configured:
1. Start Superset MCP service: `superset mcp run`
2. Call `health_check` tool from the MCP client
3. Verify no validation errors occur
4. Response should include: status, timestamp, service, version,
python_version, platform
### ADDITIONAL INFORMATION
- [ ] Has associated issue: N/A (proactive fix based on observed MCP client
behavior)
- [ ] Required feature flags: None
- [ ] Changes UI: No
- [ ] Includes DB Migration: No
- [ ] Introduces new feature or API: No (refactoring only)
- [ ] Removes existing feature or API: No
**Files changed:**
- `superset/mcp_service/system/__init__.py` - New module init file
- `superset/mcp_service/system/schemas.py` - Added `GetHealthCheckRequest`
schema
- `superset/mcp_service/system/system_utils.py` - New utility module with
helper functions
- `superset/mcp_service/system/tool/get_instance_info.py` - Updated to use
`system_utils`
- `superset/mcp_service/system/tool/health_check.py` - Added request
parameter
- `tests/unit_tests/mcp_service/system/tool/test_health_check.py` - New
comprehensive tests
--
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]