You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "alexandrusoare (via GitHub)" <gi...@apache.org> on 2026/04/30 10:00:28 UTC
[PR] feat(mcp): generate bug report tool [superset]
alexandrusoare opened a new pull request, #39776:
URL: https://github.com/apache/superset/pull/39776
### SUMMARY
MCP tool responses are ephemeral — when something goes wrong, the LLM reconstructs what happened from memory, but there's no way to correlate its account with what the server actually recorded. `LoggingMiddleware.on_call_tool()` already captures exceptions, parameters, and timing in `curated_payload`, but nothing ties a user's bug report to the right log entry.
This PR introduces `mcp_call_id`, a short unique identifier (`uuid4().hex[:12]`) generated per tool call that bridges client-visible responses and server-side logs:
- **Server-side logging** — `mcp_call_id` is added to the `curated_payload` dict and structured log line in `LoggingMiddleware`, so every tool call is tagged in the event log.
- **Client-side surfacing** — `mcp_call_id` is injected into `ToolResult.meta` (a standard MCP field for out-of-band metadata already used by `ResponseSizeGuardMiddleware` and `StructuredContentStripperMiddleware`). The LLM can read it from any prior tool response in its context window.
- **Bug report integration** — A new `generate_bug_report` tool accepts an optional `mcp_call_id` field. When provided, the formatted report includes it so support can look up the exact server log entry.
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
<!--- Skip this if not applicable -->
### TESTING INSTRUCTIONS
<!--- Required! What steps can be taken to manually verify the changes? -->
### ADDITIONAL INFORMATION
<!--- Check any relevant boxes with "x" -->
<!--- HINT: Include "Fixes #nnn" if you are fixing an existing issue -->
- [ ] 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
- [ ] 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: 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] feat(mcp): generate bug report tool [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #39776:
URL: https://github.com/apache/superset/pull/39776#discussion_r3167178954
##########
superset/mcp_service/middleware.py:
##########
@@ -239,11 +240,19 @@ async def on_call_tool(
)
tool_name = getattr(context.message, "name", None)
+ mcp_call_id = uuid.uuid4().hex[:12]
start_time = time.time()
success = False
try:
result = await call_next(context)
success = not self._is_error_response(result)
+ if isinstance(result, ToolResult):
+ existing_meta = result.meta or {}
+ result = ToolResult(
+ content=result.content,
+ meta={**existing_meta, "mcp_call_id": mcp_call_id},
+ structured_content=result.structured_content,
+ )
return result
Review Comment:
**Suggestion:** `mcp_call_id` is only injected when `call_next` returns a `ToolResult` successfully, but not when the tool call fails via exception (which is then converted into a `ToolResult` by outer middleware). This means failed responses—the most important ones for bug reporting—won't carry the call ID in response metadata, breaking log correlation for error cases. Ensure the same call ID is propagated into the error response path as well. [logic error]
<details>
<summary><b>Severity Level:</b> Critical 🚨</summary>
```mdx
- ❌ MCP tools/call error responses lack mcp_call_id metadata.
- ⚠️ Bug reports for failed MCP tools can't match logs.
- ⚠️ Support must manually correlate failing calls to events.
```
</details>
<details>
<summary><b>Steps of Reproduction ✅ </b></summary>
```mdx
1. Build the real MCP middleware chain using `build_middleware_list()` from
`superset/mcp_service/server.py:706-722`, as done in
`TestMiddlewareChainOrder.test_real_middleware_chain_logs_exception_as_failure` in
`superset/tests/unit_tests/mcp_service/test_middleware_logging.py:112-169`. This produces
the chain `[StructuredContentStripperMiddleware, LoggingMiddleware,
GlobalErrorHandlerMiddleware]` (plus optional innermost middlewares).
2. Define a failing tool handler as in `test_middleware_logging.py:136-138` that raises an
exception (e.g. `ValueError("chart not found")`), and wrap it with the middleware chain
using the loop at `test_middleware_logging.py:139-142`, so that the outermost callable is
StructuredContentStripper, then LoggingMiddleware, then GlobalErrorHandler, then the
failing tool.
3. Create a `MiddlewareContext` for a tool call using `_make_context()` from
`superset/tests/unit_tests/mcp_service/test_middleware_logging.py:35-53`, for example with
`name="get_chart_info"` and `method="tools/call"`; then invoke the composed chain with
this context. The failing tool raises, so inside `LoggingMiddleware.on_call_tool` at
`superset/mcp_service/middleware.py:232-259`, `call_next(context)` (line 247) raises an
exception, the `except` block at lines 257-259 sets `success = False` and re-raises, and
the `if isinstance(result, ToolResult): ...` block at lines 249-255 is never executed,
meaning no `mcp_call_id` is injected into any `ToolResult.meta` for this failing call.
4. The re-raised exception is then caught by
`StructuredContentStripperMiddleware.on_call_tool` at
`superset/mcp_service/middleware.py:383-399`, whose `except Exception as e:` block (lines
390-399) returns a new `ToolResult` constructed on line 399 with only
`content=[mt.TextContent(type="text", text=f"Error: {e}")]` and no `meta` argument, so
`result.meta` is `None` and there is no `"mcp_call_id"` key. Meanwhile,
`LoggingMiddleware` has logged the call with `curated_payload["mcp_call_id"]` and
`logger.info` including `mcp_call_id` (lines 270-296), but the error `ToolResult`
delivered back to the MCP client has no `mcp_call_id` in its `meta`, breaking correlation
between the client-visible error response and the logged `mcp_call_id` for failed tool
calls.
```
</details>
[Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20superset%2Fmcp_service%2Fmiddleware.py%0A%2A%2ALine%3A%2A%2A%20249%3A256%0A%2A%2AComment%3A%2A%2A%0A%09%2ALogic%20Error%3A%20%60mcp_call_id%60%20is%20only%20injected%20when%20%60call_next%60%20returns%20a%20%60ToolResult%60%20successfully%2C%20but%20not%20when%20the%20tool%20call%20fails%20via%20exception%20%28which%20is%20then%20converted%20into%20a%20%60ToolResult%60%20by%20outer%20middleware%29.%20This%20means%20failed%20responses%E2%80%94the%20most%20important%20ones%20for%20bug%20reporting%E2%80%94won%27t%20carry%20the%20call%20ID%20in%20response%20metadata%2C%20breaking%20log%20correlation%20for%20error%20cases.%20Ensure%20the%20same%20call%20ID%20is%20propagated%20into%20the%20error%20response%20path%20as%20well.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%
20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20superset%2Fmcp_service%2Fmiddleware.py%0A%2A%2ALine%3A%2A%2A%20249%3A256%0A%2A%2AComment%3A%2A%2A%0A%09%2ALogic%20Error%3A%20%60mcp_call_id%60%20is%20only%20injected%20when%20%60call_next%60%20returns%20a%20%60ToolResult%60%20successfully%2C%20but%20not%20when%20the%20tool%20call%20fails%20via%20exception%20%28which%20is%20then%20converted%20into%20a%20%60ToolResult%60%20by%20outer%20middlew
are%29.%20This%20means%20failed%20responses%E2%80%94the%20most%20important%20ones%20for%20bug%20reporting%E2%80%94won%27t%20carry%20the%20call%20ID%20in%20response%20metadata%2C%20breaking%20log%20correlation%20for%20error%20cases.%20Ensure%20the%20same%20call%20ID%20is%20propagated%20into%20the%20error%20response%20path%20as%20well.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** superset/mcp_service/middleware.py
**Line:** 249:256
**Comment:**
*Logic Error: `mcp_call_id` is only injected when `call_next` returns a `ToolResult` successfully, but not when the tool call fails via exception (which is then converted into a `ToolResult` by outer middleware). This means failed responses—the most important ones for bug reporting—won't carry the call ID in response metadata, breaking log correlation for error cases. Ensure the same call ID is propagated into the error response path as well.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39776&comment_hash=61ecefd20a691344438647ece2210cf69550a7be6fbb5e41c359dde7472aa033&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39776&comment_hash=61ecefd20a691344438647ece2210cf69550a7be6fbb5e41c359dde7472aa033&reaction=dislike'>👎</a>
--
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] feat(mcp): Add mcp_call_id to tool responses for server log correlation [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #39776:
URL: https://github.com/apache/superset/pull/39776#issuecomment-4370369360
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**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 <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</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] feat(mcp): generate bug report tool [superset]
Posted by "codecov[bot] (via GitHub)" <gi...@apache.org>.
codecov[bot] commented on PR #39776:
URL: https://github.com/apache/superset/pull/39776#issuecomment-4351580373
## [Codecov](https://app.codecov.io/gh/apache/superset/pull/39776?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 `59.45946%` with `15 lines` in your changes missing coverage. Please review.
:white_check_mark: Project coverage is 64.19%. Comparing base ([`ae4c765`](https://app.codecov.io/gh/apache/superset/commit/ae4c765d7d6e851778823d55bb1500348abab514?dropdown=coverage&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache)) to head ([`2a6e735`](https://app.codecov.io/gh/apache/superset/commit/2a6e73593d882bbd0c1229978a412cc79d625dd2?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/39776?dropdown=coverage&src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | Patch % | Lines |
|---|---|---|
| [...set/mcp\_service/system/tool/generate\_bug\_report.py](https://app.codecov.io/gh/apache/superset/pull/39776?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fsystem%2Ftool%2Fgenerate_bug_report.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2Uvc3lzdGVtL3Rvb2wvZ2VuZXJhdGVfYnVnX3JlcG9ydC5weQ==) | 52.38% | [10 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/39776?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) |
| [superset/mcp\_service/middleware.py](https://app.codecov.io/gh/apache/superset/pull/39776?src=pr&el=tree&filepath=superset%2Fmcp_service%2Fmiddleware.py&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache#diff-c3VwZXJzZXQvbWNwX3NlcnZpY2UvbWlkZGxld2FyZS5weQ==) | 0.00% | [5 Missing :warning: ](https://app.codecov.io/gh/apache/superset/pull/39776?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 #39776 +/- ##
==========================================
- Coverage 64.41% 64.19% -0.23%
==========================================
Files 2566 2567 +1
Lines 134284 134321 +37
Branches 31194 31196 +2
==========================================
- Hits 86503 86227 -276
- Misses 46283 46589 +306
- Partials 1498 1505 +7
```
| [Flag](https://app.codecov.io/gh/apache/superset/pull/39776/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/39776/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `39.71% <59.45%> (+0.01%)` | :arrow_up: |
| [mysql](https://app.codecov.io/gh/apache/superset/pull/39776/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [postgres](https://app.codecov.io/gh/apache/superset/pull/39776/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `?` | |
| [presto](https://app.codecov.io/gh/apache/superset/pull/39776/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `41.47% <59.45%> (+0.01%)` | :arrow_up: |
| [python](https://app.codecov.io/gh/apache/superset/pull/39776/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `61.19% <59.45%> (-0.49%)` | :arrow_down: |
| [sqlite](https://app.codecov.io/gh/apache/superset/pull/39776/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=apache) | `59.76% <59.45%> (-0.01%)` | :arrow_down: |
| [unit](https://app.codecov.io/gh/apache/superset/pull/39776/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/39776?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] feat(mcp): generate bug report tool [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #39776:
URL: https://github.com/apache/superset/pull/39776#discussion_r3167135485
##########
tests/unit_tests/mcp_service/system/tool/test_generate_bug_report.py:
##########
@@ -0,0 +1,128 @@
+# 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.
+
+"""Unit tests for generate_bug_report tool."""
+
+from unittest.mock import Mock, patch
+
+import pytest
+from fastmcp import Client
+from pydantic import ValidationError
+
+from superset.mcp_service.app import mcp
+from superset.mcp_service.system.schemas import GenerateBugReportRequest
+from superset.utils import json
+
+
+@pytest.fixture
+def mcp_server():
+ return mcp
+
+
+@pytest.fixture(autouse=True)
+def mock_auth():
Review Comment:
**Suggestion:** Add parameter and return type annotations to `mock_auth` so the fixture has explicit typing. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
The fixture lacks both parameter annotations and a return type annotation. This matches the stated typing rule violation for newly introduced fixtures.
</details>
[Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20tests%2Funit_tests%2Fmcp_service%2Fsystem%2Ftool%2Ftest_generate_bug_report.py%0A%2A%2ALine%3A%2A%2A%2036%3A37%0A%2A%2AComment%3A%2A%2A%0A%09%2ACustom%20Rule%3A%20Add%20parameter%20and%20return%20type%20annotations%20to%20%60mock_auth%60%20so%20the%20fixture%20has%20explicit%20typing.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A) | [Fix in VSCo
de Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20tests%2Funit_tests%2Fmcp_service%2Fsystem%2Ftool%2Ftest_generate_bug_report.py%0A%2A%2ALine%3A%2A%2A%2036%3A37%0A%2A%2AComment%3A%2A%2A%0A%09%2ACustom%20Rule%3A%20Add%20parameter%20and%20return%20type%20annotations%20to%20%60mock_auth%60%20so%20the%20fixture%20has%20explicit%20typing.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** tests/unit_tests/mcp_service/system/tool/test_generate_bug_report.py
**Line:** 36:37
**Comment:**
*Custom Rule: Add parameter and return type annotations to `mock_auth` so the fixture has explicit typing.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39776&comment_hash=cabff9f35a5beb6835eab3ddf89540e1a79227d99f6692b950e325ff299c8a61&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39776&comment_hash=cabff9f35a5beb6835eab3ddf89540e1a79227d99f6692b950e325ff299c8a61&reaction=dislike'>👎</a>
##########
tests/unit_tests/mcp_service/system/tool/test_generate_bug_report.py:
##########
@@ -0,0 +1,128 @@
+# 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.
+
+"""Unit tests for generate_bug_report tool."""
+
+from unittest.mock import Mock, patch
+
+import pytest
+from fastmcp import Client
+from pydantic import ValidationError
+
+from superset.mcp_service.app import mcp
+from superset.mcp_service.system.schemas import GenerateBugReportRequest
+from superset.utils import json
+
+
+@pytest.fixture
+def mcp_server():
Review Comment:
**Suggestion:** Add explicit type hints to `mcp_server`, including a concrete return type for the fixture value. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
The fixture is defined without any type annotation or explicit return type. If the custom rule requires explicit typing for new fixtures, this is a real violation in the existing code.
</details>
[Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20tests%2Funit_tests%2Fmcp_service%2Fsystem%2Ftool%2Ftest_generate_bug_report.py%0A%2A%2ALine%3A%2A%2A%2031%3A32%0A%2A%2AComment%3A%2A%2A%0A%09%2ACustom%20Rule%3A%20Add%20explicit%20type%20hints%20to%20%60mcp_server%60%2C%20including%20a%20concrete%20return%20type%20for%20the%20fixture%20value.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A) | [Fix
in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20tests%2Funit_tests%2Fmcp_service%2Fsystem%2Ftool%2Ftest_generate_bug_report.py%0A%2A%2ALine%3A%2A%2A%2031%3A32%0A%2A%2AComment%3A%2A%2A%0A%09%2ACustom%20Rule%3A%20Add%20explicit%20type%20hints%20to%20%60mcp_server%60%2C%20including%20a%20concrete%20return%20type%20for%20the%20fixture%20value.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A
)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** tests/unit_tests/mcp_service/system/tool/test_generate_bug_report.py
**Line:** 31:32
**Comment:**
*Custom Rule: Add explicit type hints to `mcp_server`, including a concrete return type for the fixture value.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39776&comment_hash=059efc9d832701667ee23b64dcd95cfcb27c64fddf0f2c008520dccc717338c0&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39776&comment_hash=059efc9d832701667ee23b64dcd95cfcb27c64fddf0f2c008520dccc717338c0&reaction=dislike'>👎</a>
##########
tests/unit_tests/mcp_service/system/tool/test_generate_bug_report.py:
##########
@@ -0,0 +1,128 @@
+# 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.
+
+"""Unit tests for generate_bug_report tool."""
+
+from unittest.mock import Mock, patch
+
+import pytest
+from fastmcp import Client
+from pydantic import ValidationError
+
+from superset.mcp_service.app import mcp
+from superset.mcp_service.system.schemas import GenerateBugReportRequest
+from superset.utils import json
+
+
+@pytest.fixture
+def mcp_server():
+ return mcp
+
+
+@pytest.fixture(autouse=True)
+def mock_auth():
+ """Mock authentication for client-based tool tests."""
+ with patch("superset.mcp_service.auth.get_user_from_request") as mock_get_user:
+ mock_user = Mock()
+ mock_user.id = 1
+ mock_user.username = "admin"
+ mock_get_user.return_value = mock_user
+ yield mock_get_user
+
+
+_BASE_REQUEST = {
+ "summary": "Test bug",
+ "steps_to_reproduce": "1. Do X",
+ "expected_behavior": "Y should happen",
+ "actual_behavior": "Z happened",
+}
+
+
+@pytest.mark.asyncio
+async def test_generates_report_with_mcp_call_id(mcp_server):
+ """Bug report includes mcp_call_id when provided."""
+ async with Client(mcp_server) as client:
+ result = await client.call_tool(
+ "generate_bug_report",
+ {
+ "request": {
+ **_BASE_REQUEST,
+ "mcp_call_id": "abc123def456",
+ }
+ },
+ )
+ data = json.loads(result.content[0].text)
+
+ assert "abc123def456" in data["report"]
+ assert "MCP Call ID" in data["report"]
+ assert data["mcp_call_id"] == "abc123def456"
+
+
+@pytest.mark.asyncio
+async def test_generates_report_without_mcp_call_id(mcp_server):
+ """Bug report omits MCP Call ID line when not provided."""
+ async with Client(mcp_server) as client:
+ result = await client.call_tool(
+ "generate_bug_report",
+ {"request": _BASE_REQUEST},
+ )
+ data = json.loads(result.content[0].text)
+
+ assert "MCP Call ID" not in data["report"]
+ assert data["mcp_call_id"] is None
+
+
+@pytest.mark.asyncio
+async def test_report_contains_system_info(mcp_server):
+ """Bug report includes system metadata."""
+ async with Client(mcp_server) as client:
+ result = await client.call_tool(
+ "generate_bug_report",
+ {"request": _BASE_REQUEST},
+ )
+ data = json.loads(result.content[0].text)
+
+ report = data["report"]
+ assert "## Bug Report" in report
+ assert "Superset Version" in report
+ assert "Python Version" in report
+ assert "Platform" in report
+ assert "### Summary" in report
+ assert "Test bug" in report
+
+
+def test_schema_rejects_extra_fields():
Review Comment:
**Suggestion:** Add an explicit return type annotation (`-> None`) to `test_schema_rejects_extra_fields`. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
The function has no explicit return type annotation. Under a rule requiring `-> None` for newly added test functions, this is a real violation.
</details>
[Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20tests%2Funit_tests%2Fmcp_service%2Fsystem%2Ftool%2Ftest_generate_bug_report.py%0A%2A%2ALine%3A%2A%2A%20108%3A108%0A%2A%2AComment%3A%2A%2A%0A%09%2ACustom%20Rule%3A%20Add%20an%20explicit%20return%20type%20annotation%20%28%60-%3E%20None%60%29%20to%20%60test_schema_rejects_extra_fields%60.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A) | [Fix in VSC
ode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20tests%2Funit_tests%2Fmcp_service%2Fsystem%2Ftool%2Ftest_generate_bug_report.py%0A%2A%2ALine%3A%2A%2A%20108%3A108%0A%2A%2AComment%3A%2A%2A%0A%09%2ACustom%20Rule%3A%20Add%20an%20explicit%20return%20type%20annotation%20%28%60-%3E%20None%60%29%20to%20%60test_schema_rejects_extra_fields%60.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** tests/unit_tests/mcp_service/system/tool/test_generate_bug_report.py
**Line:** 108:108
**Comment:**
*Custom Rule: Add an explicit return type annotation (`-> None`) to `test_schema_rejects_extra_fields`.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39776&comment_hash=9a1a19d7e4ea37d0de2754c1a1e259b6649673ef09a02fc45b7f3034f7d87f30&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39776&comment_hash=9a1a19d7e4ea37d0de2754c1a1e259b6649673ef09a02fc45b7f3034f7d87f30&reaction=dislike'>👎</a>
##########
tests/unit_tests/mcp_service/system/tool/test_generate_bug_report.py:
##########
@@ -0,0 +1,128 @@
+# 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.
+
+"""Unit tests for generate_bug_report tool."""
+
+from unittest.mock import Mock, patch
+
+import pytest
+from fastmcp import Client
+from pydantic import ValidationError
+
+from superset.mcp_service.app import mcp
+from superset.mcp_service.system.schemas import GenerateBugReportRequest
+from superset.utils import json
+
+
+@pytest.fixture
+def mcp_server():
+ return mcp
+
+
+@pytest.fixture(autouse=True)
+def mock_auth():
+ """Mock authentication for client-based tool tests."""
+ with patch("superset.mcp_service.auth.get_user_from_request") as mock_get_user:
+ mock_user = Mock()
+ mock_user.id = 1
+ mock_user.username = "admin"
+ mock_get_user.return_value = mock_user
+ yield mock_get_user
+
+
+_BASE_REQUEST = {
+ "summary": "Test bug",
+ "steps_to_reproduce": "1. Do X",
+ "expected_behavior": "Y should happen",
+ "actual_behavior": "Z happened",
+}
+
+
+@pytest.mark.asyncio
+async def test_generates_report_with_mcp_call_id(mcp_server):
Review Comment:
**Suggestion:** Add explicit type hints to `test_generates_report_with_mcp_call_id`, including the `mcp_server` parameter type and `-> None` return type. [custom_rule]
**Severity Level:** Minor ⚠️
<details>
<summary><b>Why it matters? 🤔 </b></summary>
The async test function has an untyped parameter and no explicit `-> None` return annotation. If the custom rule requires annotations for new functions, this is a genuine violation.
</details>
[Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20tests%2Funit_tests%2Fmcp_service%2Fsystem%2Ftool%2Ftest_generate_bug_report.py%0A%2A%2ALine%3A%2A%2A%2055%3A56%0A%2A%2AComment%3A%2A%2A%0A%09%2ACustom%20Rule%3A%20Add%20explicit%20type%20hints%20to%20%60test_generates_report_with_mcp_call_id%60%2C%20including%20the%20%60mcp_server%60%20parameter%20type%20and%20%60-%3E%20None%60%20return%20type.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correct
ness%20and%20implement%20a%20minimal%20fix%0A) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt=This%20is%20a%20comment%20left%20during%20a%20code%20review.%0A%0A%2A%2APath%3A%2A%2A%20tests%2Funit_tests%2Fmcp_service%2Fsystem%2Ftool%2Ftest_generate_bug_report.py%0A%2A%2ALine%3A%2A%2A%2055%3A56%0A%2A%2AComment%3A%2A%2A%0A%09%2ACustom%20Rule%3A%20Add%20explicit%20type%20hints%20to%20%60test_generates_report_with_mcp_call_id%60%2C%20including%20the%20%60mcp_server%60%20parameter%20type%20and%20%60-%3E%20None%60%20return%20type.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20t
hen%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is a comment left during a code review.
**Path:** tests/unit_tests/mcp_service/system/tool/test_generate_bug_report.py
**Line:** 55:56
**Comment:**
*Custom Rule: Add explicit type hints to `test_generates_report_with_mcp_call_id`, including the `mcp_server` parameter type and `-> None` return type.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
```
</details>
<a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39776&comment_hash=b920ae43196d18d630822ad964f5af395850ca25c9b6a81c3815d45b14d0ff9a&reaction=like'>👍</a> | <a href='https://app.codeant.ai/feedback?pr_url=https%3A%2F%2Fgithub.com%2Fapache%2Fsuperset%2Fpull%2F39776&comment_hash=b920ae43196d18d630822ad964f5af395850ca25c9b6a81c3815d45b14d0ff9a&reaction=dislike'>👎</a>
--
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] feat(mcp): generate bug report tool [superset]
Posted by "codeant-ai-for-open-source[bot] (via GitHub)" <gi...@apache.org>.
codeant-ai-for-open-source[bot] commented on code in PR #39776:
URL: https://github.com/apache/superset/pull/39776#discussion_r3167161689
##########
superset/mcp_service/middleware.py:
##########
@@ -239,11 +240,19 @@ async def on_call_tool(
)
tool_name = getattr(context.message, "name", None)
+ mcp_call_id = uuid.uuid4().hex[:12]
start_time = time.time()
success = False
try:
result = await call_next(context)
Review Comment:
**🟠 Architect Review — HIGH**
When a tool call raises an exception, LoggingMiddleware re-raises it and StructuredContentStripperMiddleware wraps it into a new ToolResult without meta, so the generated mcp_call_id is never injected into ToolResult.meta for these error responses. As a result, common "tool failed" error responses lack mcp_call_id and cannot be correlated to the corresponding log entries, unlike success and error-schema responses.
**Suggestion:** Ensure mcp_call_id is propagated into ToolResult.meta for exception-based failures as well, e.g. by attaching it to the exception (ToolError) and having the outer StructuredContentStripperMiddleware include it when constructing the error ToolResult, or by having LoggingMiddleware itself convert failures into a ToolResult that carries the meta consistently.
[Fix in Cursor](https://app.codeant.ai/fix-in-ide?tool=cursor&prompt=This%20is%20an%20%2A%2AArchitect%20%2F%20Logical%20Review%2A%2A%20comment%20left%20during%20a%20code%20review.%20These%20reviews%20are%20first-class%2C%20important%20findings%20%E2%80%94%20not%20optional%20suggestions.%20Do%20NOT%20dismiss%20this%20as%20a%20%27big%20architectural%20change%27%20just%20because%20the%20title%20says%20architect%20review%3B%20most%20of%20these%20can%20be%20resolved%20with%20a%20small%2C%20localized%20fix%20once%20the%20intent%20is%20understood.%0A%0A%2A%2APath%3A%2A%2A%20superset%2Fmcp_service%2Fmiddleware.py%0A%2A%2ALine%3A%2A%2A%20247%3A259%0A%2A%2AComment%3A%2A%2A%0A%09%2AHIGH%3A%20When%20a%20tool%20call%20raises%20an%20exception%2C%20LoggingMiddleware%20re-raises%20it%20and%20StructuredContentStripperMiddleware%20wraps%20it%20into%20a%20new%20ToolResult%20without%20meta%2C%20so%20the%20generated%20mcp_call_id%20is%20never%20injected%20into%20ToolResult.meta%20for%20these%20error%2
0responses.%20As%20a%20result%2C%20common%20%22tool%20failed%22%20error%20responses%20lack%20mcp_call_id%20and%20cannot%20be%20correlated%20to%20the%20corresponding%20log%20entries%2C%20unlike%20success%20and%20error-schema%20responses.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AIf%20a%20suggested%20approach%20is%20provided%20above%2C%20use%20it%20as%20the%20authoritative%20instruction.%20If%20no%20explicit%20code%20suggestion%20is%20given%2C%20you%20MUST%20still%20draft%20and%20apply%20your%20own%20minimal%2C%20localized%20fix%20%E2%80%94%20do%20not%20punt%20back%20with%20%27no%20suggestion%20provided%2C%20review%20manually%27.%20Keep%20the%20change%20as%20small%20as%20possible%3A%20add%20a%20guard%20clause%2C%20gate%20on%20a%20loading%20state%2C%20reorder%20an%20await%2C%20wrap%20in%20a%20conditional%2C%20etc.%20Do%20
not%20refactor%20surrounding%20code%20or%20expand%20scope%20beyond%20the%20finding.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A) | [Fix in VSCode Claude](https://app.codeant.ai/fix-in-ide?tool=vscode-claude&prompt=This%20is%20an%20%2A%2AArchitect%20%2F%20Logical%20Review%2A%2A%20comment%20left%20during%20a%20code%20review.%20These%20reviews%20are%20first-class%2C%20important%20findings%20%E2%80%94%20not%20optional%20suggestions.%20Do%20NOT%20dismiss%20this%20as%20a%20%27big%20architectural%20change%27%20just%20because%20the%20title%20says%20architect%20review%3B%20most%20of%20these%20can%20be%20resolved%20with%20a%20small%2C%20localized%20fix%20once%20the%20intent%20is%20understood.%0A%0A%2A%2APath%3A%
2A%2A%20superset%2Fmcp_service%2Fmiddleware.py%0A%2A%2ALine%3A%2A%2A%20247%3A259%0A%2A%2AComment%3A%2A%2A%0A%09%2AHIGH%3A%20When%20a%20tool%20call%20raises%20an%20exception%2C%20LoggingMiddleware%20re-raises%20it%20and%20StructuredContentStripperMiddleware%20wraps%20it%20into%20a%20new%20ToolResult%20without%20meta%2C%20so%20the%20generated%20mcp_call_id%20is%20never%20injected%20into%20ToolResult.meta%20for%20these%20error%20responses.%20As%20a%20result%2C%20common%20%22tool%20failed%22%20error%20responses%20lack%20mcp_call_id%20and%20cannot%20be%20correlated%20to%20the%20corresponding%20log%20entries%2C%20unlike%20success%20and%20error-schema%20responses.%0A%0AValidate%20the%20correctness%20of%20the%20flagged%20issue.%20If%20correct%2C%20How%20can%20I%20resolve%20this%3F%20If%20you%20propose%20a%20fix%2C%20implement%20it%20and%20please%20make%20it%20concise.%0AIf%20a%20suggested%20approach%20is%20provided%20above%2C%20use%20it%20as%20the%20authoritative%20instruction.%20If%20no%20
explicit%20code%20suggestion%20is%20given%2C%20you%20MUST%20still%20draft%20and%20apply%20your%20own%20minimal%2C%20localized%20fix%20%E2%80%94%20do%20not%20punt%20back%20with%20%27no%20suggestion%20provided%2C%20review%20manually%27.%20Keep%20the%20change%20as%20small%20as%20possible%3A%20add%20a%20guard%20clause%2C%20gate%20on%20a%20loading%20state%2C%20reorder%20an%20await%2C%20wrap%20in%20a%20conditional%2C%20etc.%20Do%20not%20refactor%20surrounding%20code%20or%20expand%20scope%20beyond%20the%20finding.%0AOnce%20fix%20is%20implemented%2C%20also%20check%20other%20comments%20on%20the%20same%20PR%2C%20and%20ask%20user%20if%20the%20user%20wants%20to%20fix%20the%20rest%20of%20the%20comments%20as%20well.%20if%20said%20yes%2C%20then%20fetch%20all%20the%20comments%20validate%20the%20correctness%20and%20implement%20a%20minimal%20fix%0A)
*(Use Cmd/Ctrl + Click for best experience)*
<details>
<summary><b>Prompt for AI Agent 🤖 </b></summary>
```mdx
This is an **Architect / Logical Review** comment left during a code review. These reviews are first-class, important findings — not optional suggestions. Do NOT dismiss this as a 'big architectural change' just because the title says architect review; most of these can be resolved with a small, localized fix once the intent is understood.
**Path:** superset/mcp_service/middleware.py
**Line:** 247:259
**Comment:**
*HIGH: When a tool call raises an exception, LoggingMiddleware re-raises it and StructuredContentStripperMiddleware wraps it into a new ToolResult without meta, so the generated mcp_call_id is never injected into ToolResult.meta for these error responses. As a result, common "tool failed" error responses lack mcp_call_id and cannot be correlated to the corresponding log entries, unlike success and error-schema responses.
Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
If a suggested approach is provided above, use it as the authoritative instruction. If no explicit code suggestion is given, you MUST still draft and apply your own minimal, localized fix — do not punt back with 'no suggestion provided, review manually'. Keep the change as small as possible: add a guard clause, gate on a loading state, reorder an await, wrap in a conditional, etc. Do not refactor surrounding code or expand scope beyond the finding.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
```
</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] feat(mcp): Add mcp_call_id to tool responses for server log correlation [superset]
Posted by "msyavuz (via GitHub)" <gi...@apache.org>.
msyavuz commented on code in PR #39776:
URL: https://github.com/apache/superset/pull/39776#discussion_r3168716137
##########
superset/mcp_service/middleware.py:
##########
@@ -239,11 +240,20 @@ async def on_call_tool(
)
tool_name = getattr(context.message, "name", None)
+ mcp_call_id = uuid.uuid4().hex[:12]
Review Comment:
I don't think this is unique not sure how it affects but here:
`collision probability hits ~50% around
2^24 ≈ 16M IDs, and ~1% around ~2.4M`
Also the suggestion is: `secrets.token_hex(16)`
##########
tests/unit_tests/mcp_service/test_middleware_logging.py:
##########
@@ -130,6 +130,68 @@ async def test_on_call_tool_logs_failure_on_tool_error(
assert call_kwargs["curated_payload"]["tool"] == "get_chart_info"
assert call_kwargs["duration_ms"] >= 0
+ @patch("superset.mcp_service.middleware.event_logger")
+ @patch("superset.mcp_service.middleware.get_user_id", return_value=42)
+ @pytest.mark.asyncio
+ async def test_on_call_tool_includes_mcp_call_id_in_curated_payload(
+ self, mock_get_user_id, mock_event_logger
+ ):
+ """on_call_tool adds mcp_call_id to curated_payload."""
+ middleware = LoggingMiddleware()
+ ctx = _make_context(name="list_charts")
+ call_next = AsyncMock(return_value="tool_result")
+
+ await middleware.on_call_tool(ctx, call_next)
+
+ call_kwargs = mock_event_logger.log.call_args[1]
+ mcp_call_id = call_kwargs["curated_payload"]["mcp_call_id"]
+ assert isinstance(mcp_call_id, str)
+ assert len(mcp_call_id) == 12
+
+ @patch("superset.mcp_service.middleware.event_logger")
+ @patch("superset.mcp_service.middleware.get_user_id", return_value=42)
+ @pytest.mark.asyncio
+ async def test_on_call_tool_injects_mcp_call_id_into_tool_result_meta(
+ self, mock_get_user_id, mock_event_logger
+ ):
+ """on_call_tool injects mcp_call_id into ToolResult.meta."""
+ from fastmcp.tools.tool import ToolResult
+ from mcp import types as mt
Review Comment:
Should this and the other imports be module level?
--
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] feat(mcp): Add mcp_call_id to tool responses for server log correlation [superset]
Posted by "alexandrusoare (via GitHub)" <gi...@apache.org>.
alexandrusoare commented on code in PR #39776:
URL: https://github.com/apache/superset/pull/39776#discussion_r3167881589
##########
superset/mcp_service/middleware.py:
##########
@@ -239,11 +240,19 @@ async def on_call_tool(
)
tool_name = getattr(context.message, "name", None)
+ mcp_call_id = uuid.uuid4().hex[:12]
start_time = time.time()
success = False
try:
result = await call_next(context)
success = not self._is_error_response(result)
+ if isinstance(result, ToolResult):
+ existing_meta = result.meta or {}
+ result = ToolResult(
+ content=result.content,
+ meta={**existing_meta, "mcp_call_id": mcp_call_id},
+ structured_content=result.structured_content,
+ )
return result
Review Comment:
Taken care of with commit #5e3ca00
--
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] feat(mcp): Add mcp_call_id to tool responses for server log correlation [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #39776:
URL: https://github.com/apache/superset/pull/39776#issuecomment-4357701750
AI Code Review is in progress (usually takes 3 to 15 minutes unless it's a very large PR).
<details>
<summary>
Bito Usage Guide
</summary>
**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 <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/available-commands" target="_blank" rel="noopener noreferrer">documentation</a> for additional commands.
**Configuration**
This repository uses `Superset` You can customize the agent settings <a href="https://alpha.bito.ai/home/ai-agents/code-review-agent" target="_blank" rel="noopener noreferrer">here</a> or contact your Bito workspace admin at evan@preset.io.
**Documentation & Help**
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/getting-started/install-run-using-bito-cloud/create-or-customize-an-agent-instance" target="_blank" rel="noopener noreferrer">Customize agent settings</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/implementing-custom-code-review-rules" target="_blank" rel="noopener noreferrer">Review rules</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent" target="_blank" rel="noopener noreferrer">General documentation</a>
- <a href="https://docs.bito.ai/bito-dev-agents/ai-code-review-agent/faqs" target="_blank" rel="noopener noreferrer">FAQ</a>
</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] feat(mcp): Add mcp_call_id to tool responses for server log correlation [superset]
Posted by "alexandrusoare (via GitHub)" <gi...@apache.org>.
alexandrusoare merged PR #39776:
URL: https://github.com/apache/superset/pull/39776
--
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] feat(mcp): generate bug report tool [superset]
Posted by "bito-code-review[bot] (via GitHub)" <gi...@apache.org>.
bito-code-review[bot] commented on PR #39776:
URL: https://github.com/apache/superset/pull/39776#issuecomment-4351499395
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] feat(mcp): Add mcp_call_id to tool responses for server log correlation [superset]
Posted by "alexandrusoare (via GitHub)" <gi...@apache.org>.
alexandrusoare commented on code in PR #39776:
URL: https://github.com/apache/superset/pull/39776#discussion_r3167883471
##########
superset/mcp_service/middleware.py:
##########
@@ -239,11 +240,19 @@ async def on_call_tool(
)
tool_name = getattr(context.message, "name", None)
+ mcp_call_id = uuid.uuid4().hex[:12]
start_time = time.time()
success = False
try:
result = await call_next(context)
Review Comment:
Taken care of with commit #5e3ca00
--
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] feat(mcp): Add mcp_call_id to tool responses for server log correlation [superset]
Posted by "netlify[bot] (via GitHub)" <gi...@apache.org>.
netlify[bot] commented on PR #39776:
URL: https://github.com/apache/superset/pull/39776#issuecomment-4369923922
### <span aria-hidden="true">✅</span> Deploy Preview for *superset-docs-preview* ready!
| Name | Link |
|:-:|------------------------|
|<span aria-hidden="true">🔨</span> Latest commit | ede52bd6b2e4339a3284ae2fcd62d76a3b987010 |
|<span aria-hidden="true">🔍</span> Latest deploy log | https://app.netlify.com/projects/superset-docs-preview/deploys/69f868990c45bf00088dcdff |
|<span aria-hidden="true">😎</span> Deploy Preview | [https://deploy-preview-39776--superset-docs-preview.netlify.app](https://deploy-preview-39776--superset-docs-preview.netlify.app) |
|<span aria-hidden="true">📱</span> Preview on mobile | <details><summary> Toggle QR Code... </summary><br /><br /><br /><br />_Use your smartphone camera to open QR code link._</details> |
|<span aria-hidden="true">🤖</span> Make changes | [Run an agent on this branch](https://app.netlify.com/projects/superset-docs-preview/agent-runs#DcsxDoAgDADAv3Q2kUEN-ANfYQptcVAgFRON8e-y3XIvFM1HqTADdOAVU9iacecbE-l1ZlTuhbH2kRMrVl79FVflkrW2Qlz2_CzU0uTETtY5E4bRizHGWgokAt8P) |
---
<!-- [superset-docs-preview Preview](https://deploy-preview-39776--superset-docs-preview.netlify.app) -->
_To edit notification comments on pull requests, go to your [Netlify project configuration](https://app.netlify.com/projects/superset-docs-preview/configuration/notifications#deploy-notifications)._
--
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