Skip to content

fix(mcp): redirect stdio click echo without recursion#40814

Open
fallintoplace wants to merge 1 commit into
apache:masterfrom
fallintoplace:fix/mcp-stdio-click-echo-recursion
Open

fix(mcp): redirect stdio click echo without recursion#40814
fallintoplace wants to merge 1 commit into
apache:masterfrom
fallintoplace:fix/mcp-stdio-click-echo-recursion

Conversation

@fallintoplace
Copy link
Copy Markdown

Summary

Fix the MCP stdio entry point so the click.echo monkey-patch calls the saved original function instead of calling the patched attribute again.

Root cause

In stdio mode, superset.mcp_service.__main__ replaced click.echo with a lambda that called click.echo again. After assignment, that name points back to the lambda itself, so normal Click output can fail instead of being redirected to stderr.

Changes

  • Save click.echo before patching it, matching the existing click.secho pattern.
  • Add a focused regression test that loads the stdio entry point with lightweight stubs and verifies click.echo and click.secho write to stderr without writing to stdout.

Checks

  • uv run --no-project --with ruff ruff check --config pyproject.toml superset/mcp_service/__main__.py tests/unit_tests/test_mcp_stdio_entrypoint.py
  • Standalone stdio redirection check with click and stubbed MCP imports

@fallintoplace fallintoplace marked this pull request as ready for review June 5, 2026 20:46
@bito-code-review
Copy link
Copy Markdown
Contributor

bito-code-review Bot commented Jun 5, 2026

Code Review Agent Run #e13cb8

Actionable Suggestions - 0
Filtered by Review Rules

Bito filtered these suggestions based on rules created automatically for your feedback. Manage rules.

  • superset/mcp_service/__main__.py - 1
    • Self-referential click.echo causes recursion · Line 42-43
Review Details
  • Files reviewed - 2 · Commit Range: f39b1ee..f39b1ee
    • superset/mcp_service/__main__.py
    • tests/unit_tests/test_mcp_stdio_entrypoint.py
  • Files skipped - 0
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful
    • MyPy (Static Code Analysis) - ✔︎ Successful
    • Astral Ruff (Static Code Analysis) - ✔︎ Successful

Bito Usage Guide

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 documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant