You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "aminghadersohi (via GitHub)" <gi...@apache.org> on 2025/11/11 00:16:24 UTC
[PR] fix(mcp): add request parameter to health_check and refactor system utils [superset]
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(mcp): add request parameter to health_check and refactor system utils [superset]
Posted by "korbit-ai[bot] (via GitHub)" <gi...@apache.org>.
korbit-ai[bot] commented on code in PR #36063:
URL: https://github.com/apache/superset/pull/36063#discussion_r2512396444
##########
superset/mcp_service/system/schemas.py:
##########
@@ -28,6 +28,20 @@
from pydantic import BaseModel, ConfigDict, Field
+class GetHealthCheckRequest(BaseModel):
+ """
+ Request schema for health_check tool.
+
+ Currently has no parameters but provides consistent API for future extensibility.
+ This prevents validation errors when MCP clients call the tool with an empty object.
+ """
+
+ model_config = ConfigDict(
+ extra="forbid",
+ str_strip_whitespace=True,
+ )
Review Comment:
### Unnecessary str_strip_whitespace configuration <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
The GetHealthCheckRequest class has no fields but uses str_strip_whitespace=True configuration, which is unnecessary and potentially misleading since there are no string fields to strip whitespace from.
###### Why this matters
This configuration option serves no purpose in a model with no fields and could confuse developers about the model's intended behavior. It may also cause unnecessary processing overhead during validation.
###### Suggested change β *Feature Preview*
Remove the str_strip_whitespace=True configuration since there are no string fields in this model:
```python
model_config = ConfigDict(
extra="forbid",
)
```
###### Provide feedback to improve future suggestions
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/543dff10-c34f-486b-8498-517968d6dfd3/upvote) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/543dff10-c34f-486b-8498-517968d6dfd3?what_not_true=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/543dff10-c34f-486b-8498-517968d6dfd3?what_out_of_scope=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/543dff10-c34f-486b-8498-517968d6dfd3?what_not_in_standard=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/543dff10-c34f-486b-8498-517968d6dfd3)
</details>
<sub>
π¬ Looking for more details? Reply to this comment to chat with Korbit.
</sub>
<!--- korbi internal id:509a636b-679e-47e2-a5cb-aa377c07db86 -->
[](509a636b-679e-47e2-a5cb-aa377c07db86)
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(mcp): add request parameter to health_check and refactor system utils [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #36063:
URL: https://github.com/apache/superset/pull/36063#issuecomment-3514461102
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/36063?dropdown=coverage&src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) Report
:x: Patch coverage is `0%` with `52 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 48.23%. Comparing base ([`21d585d`](https://app.codecov.io/gh/apache/superset/commit/21d585d58602a55a044235098ecd89022c6c7a68?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`564c7af`](https://app.codecov.io/gh/apache/superset/commit/564c7af874881ebbc4933bb457df377a06b9a538?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)).
| [Files with missing lines](https://app.codecov.io/gh/apache/superset/pull/36063?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [superset/mcp\_service/system/system\_utils.py](https://app.codecov.io/gh/apache/superset/pull/36063?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fsystem%2Fsystem_utils.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2Uvc3lzdGVtL3N5c3RlbV91dGlscy5weQ==) | 0.00% | [47 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/36063?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/mcp\_service/system/schemas.py](https://app.codecov.io/gh/apache/superset/pull/36063?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fsystem%2Fschemas.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2Uvc3lzdGVtL3NjaGVtYXMucHk=) | 0.00% | [2 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/36063?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/mcp\_service/system/tool/health\_check.py](https://app.codecov.io/gh/apache/superset/pull/36063?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fsystem%2Ftool%2Fhealth_check.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2Uvc3lzdGVtL3Rvb2wvaGVhbHRoX2NoZWNrLnB5) | 0.00% | [2 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/36063?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [...erset/mcp\_service/system/tool/get\_instance\_info.py](https://app.codecov.io/gh/apache/superset/pull/36063?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fsystem%2Ftool%2Fget_instance_info.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2Uvc3lzdGVtL3Rvb2wvZ2V0X2luc3RhbmNlX2luZm8ucHk=) | 0.00% | [1 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/36063?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
<details><summary>Additional details and impacted files</summary>
```diff
@@ Coverage Diff @@
## master #36063 +/- ##
===========================================
+ Coverage 0 48.23% +48.23%
===========================================
Files 0 631 +631
Lines 0 45961 +45961
Branches 0 4981 +4981
===========================================
+ Hits 0 22167 +22167
- Misses 0 23169 +23169
- Partials 0 625 +625
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/36063/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Coverage Ξ | |
|---|---|---|
| [hive](https://app.codecov.io/gh/apache/superset/pull/36063/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `43.97% <0.00%> (?)` | |
| [presto](https://app.codecov.io/gh/apache/superset/pull/36063/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `47.51% <0.00%> (?)` | |
| [python](https://app.codecov.io/gh/apache/superset/pull/36063/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `48.22% <0.00%> (?)` | |
| [unit](https://app.codecov.io/gh/apache/superset/pull/36063/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `100.00% <ΓΈ> (?)` | |
Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#carryforward-flags-in-the-pull-request-comment) to find out more.
</details>
[:umbrella: View full report in Codecov by Sentry](https://app.codecov.io/gh/apache/superset/pull/36063?dropdown=coverage&src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
:loudspeaker: Have feedback on the report? [Share it here](https://about.codecov.io/codecov-pr-comment-feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache).
<details><summary> :rocket: New features to boost your workflow: </summary>
- :snowflake: [Test Analytics](https://docs.codecov.com/docs/test-analytics): Detect flaky tests, report on failures, and find test suite problems.
- :package: [JS Bundle Analysis](https://docs.codecov.com/docs/javascript-bundle-analysis): Save yourself from yourself by tracking and limiting bundle sizes in JS merges.
</details>
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(mcp): add request parameter to health_check and refactor system utils [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on code in PR #36063:
URL: https://github.com/apache/superset/pull/36063#discussion_r2512406382
##########
superset/mcp_service/system/tool/get_instance_info.py:
##########
@@ -21,189 +21,27 @@
"""
import logging
-from typing import Any, Dict
from fastmcp import Context
from superset.mcp_service.app import mcp
from superset.mcp_service.auth import mcp_auth_hook
from superset.mcp_service.mcp_core import InstanceInfoCore
from superset.mcp_service.system.schemas import (
- DashboardBreakdown,
- DatabaseBreakdown,
GetSupersetInstanceInfoRequest,
InstanceInfo,
- InstanceSummary,
- PopularContent,
- RecentActivity,
+)
+from superset.mcp_service.system.system_utils import (
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Import path not updated after function move</b></div>
<div id="fix">
The calculate functions have been moved to `system_utils`, but the import in `instance_metadata.py` still references the old location in `get_instance_info`, which will cause an ImportError when the instance metadata resource is accessed. This breaks production functionality for users trying to retrieve instance metadata. The fix updates the import path in `instance_metadata.py` to point to the new `system_utils` module.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
```
- from superset.mcp_service.system.tool.get_instance_info import (
- calculate_dashboard_breakdown,
- calculate_database_breakdown,
- calculate_instance_summary,
- calculate_popular_content,
- calculate_recent_activity,
- )
+ from superset.mcp_service.system.system_utils import (
+ calculate_dashboard_breakdown,
+ calculate_database_breakdown,
+ calculate_instance_summary,
+ calculate_popular_content,
+ calculate_recent_activity,
+ )
```
</div>
</details>
</div>
<small><i>Code Review Run <a href=https://github.com/apache/superset/pull/36063#issuecomment-3514443151>#1cb20f</a></i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
##########
tests/unit_tests/mcp_service/system/tool/test_health_check.py:
##########
@@ -0,0 +1,81 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+"""Tests for health_check MCP tool."""
+
+import pytest
+from pydantic import ValidationError
+
+from superset.mcp_service.system.schemas import (
+ GetHealthCheckRequest,
+ HealthCheckResponse,
+)
+
+
+def test_health_check_request_schema():
+ """Test that GetHealthCheckRequest schema allows empty object."""
+ # This should not raise validation errors
+ request = GetHealthCheckRequest()
+
+ # Verify it's a valid schema with no required fields
+ assert request is not None
+
+ # Verify it can be created from empty dict (simulating MCP client)
+ request_from_dict = GetHealthCheckRequest.model_validate({})
+ assert request_from_dict is not None
+
+
+def test_health_check_request_forbids_extra_fields():
+ """Test that GetHealthCheckRequest forbids unexpected fields."""
+ # Should raise validation error when extra fields are provided
+ with pytest.raises(ValidationError, match="extra.*forbidden|unexpected"):
Review Comment:
<div>
<div id="suggestion">
<div id="issue"><b>Fix incorrect ValidationError match pattern</b></div>
<div id="fix">
The pytest.raises match pattern 'extra.*forbidden|unexpected' does not match the actual Pydantic v2 ValidationError message 'Extra inputs are not permitted' for extra forbidden fields. This causes the test to fail to properly validate that GetHealthCheckRequest forbids unexpected fields, potentially allowing incorrect behavior to pass unnoticed. Update the match to 'Extra inputs are not permitted' to correctly catch the validation error.
</div>
<details>
<summary>
<b>Code suggestion</b>
</summary>
<blockquote>Check the AI-generated fix before applying</blockquote>
<div id="code">
````suggestion
with pytest.raises(ValidationError, match="Extra inputs are not permitted"):
````
</div>
</details>
</div>
<small><i>Code Review Run <a href=https://github.com/apache/superset/pull/36063#issuecomment-3514443151>#1cb20f</a></i></small>
</div>
---
Should Bito avoid suggestions like this for future reviews? (<a href=https://alpha.bito.ai/home/ai-agents/review-rules>Manage Rules</a>)
- [ ] Yes, avoid them
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(mcp): add request parameter to health_check and refactor system utils [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #36063:
URL: https://github.com/apache/superset/pull/36063#issuecomment-3514443151
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(mcp): simplify health_check tool and refactor system utils [superset]
Posted by "sadpandajoe (via GitHub)" <gi...@apache.org>.
sadpandajoe merged PR #36063:
URL: https://github.com/apache/superset/pull/36063
--
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: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org