-
Notifications
You must be signed in to change notification settings - Fork 58
fix: wrap MCP server output as JSON when structured logging enabled #713
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
devin-ai-integration
wants to merge
4
commits into
main
from
devin/1751671971-fix-mcp-server-json-output
Closed
fix: wrap MCP server output as JSON when structured logging enabled #713
devin-ai-integration
wants to merge
4
commits into
main
from
devin/1751671971-fix-mcp-server-json-output
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Add get_mcp_logger() and log_mcp_message() functions to airbyte/mcp/_util.py - Replace all print() calls in MCP server with structured logging calls - Add NO_LIVE_PROGRESS constant to airbyte/constants.py following _str_to_bool() pattern - Set NO_LIVE_PROGRESS=1 programmatically to prevent Rich progress interference - Support both JSON and plain text output based on AIRBYTE_STRUCTURED_LOGGING setting - Maintain backward compatibility when structured logging is disabled Co-Authored-By: AJ Steers <[email protected]>
Original prompt from AJ Steers:
|
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
- Update **kwargs type annotation from Any to str | float | bool | None - Split function signature across multiple lines to fix line length limit - Remove redundant int type as suggested by PYI041 rule Co-Authored-By: AJ Steers <[email protected]>
aaronsteers
reviewed
Jul 5, 2025
…OL_CALL and session flagging - Add EventType.MCP_TOOL_CALL to telemetry enum for specific MCP tool tracking - Create log_mcp_tool_call() function for MCP tool telemetry - Update log_mcp_message() to send telemetry for MCP tool calls with proper state mapping - Keep MCP session flag in get_env_flags() to tag all operations when called from MCP - Fix type compatibility issue between kwargs and log_mcp_tool_call parameters - Address GitHub comments from @aaronsteers about combined telemetry approach This implements the dual telemetry strategy: 1. MCP session flagging: All telemetry events (sync, install, check) get MCP flag via get_env_flags() 2. Specific tool tracking: Individual MCP tool calls tracked via EventType.MCP_TOOL_CALL Co-Authored-By: AJ Steers <[email protected]>
- Update Python version markers for dependencies - Side effect of running poetry commands during development Co-Authored-By: AJ Steers <[email protected]>
Closing due to inactivity for more than 7 days. Configure here. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix MCP server JSON output and integrate telemetry tracking
Summary
This PR addresses the issue where PyAirbyte's MCP server was printing non-JSON output to STDOUT, confusing MCP clients. The changes implement structured logging throughout the MCP server code and integrate comprehensive telemetry tracking as requested in the GitHub comments.
Key changes:
print()
statements in MCP server withlog_mcp_message()
calls that respectAIRBYTE_STRUCTURED_LOGGING
settingNO_LIVE_PROGRESS
toairbyte.constants
withAIRBYTE_NO_LIVE_PROGRESS
prefix and backward compatibility fallbackget_env_flags()
) and specific tool tracking (viaEventType.MCP_TOOL_CALL
)The solution ensures that when
AIRBYTE_STRUCTURED_LOGGING=true
, all MCP server output on STDOUT is valid JSON, while stderr can contain non-JSON messages.Review & Testing Checklist for Human
AIRBYTE_STRUCTURED_LOGGING=true
AIRBYTE_NO_LIVE_PROGRESS
takes precedence,NO_LIVE_PROGRESS
is used as fallback, and default is"false"
NO_LIVE_PROGRESS=1
actually prevents Rich live progress displays during MCP operationsRecommended test plan:
Diagram
Notes
NO_LIVE_PROGRESS
usageLink to Devin session: https://app.devin.ai/sessions/84e33c5b00244873b05e4bd73a4f2504
Requested by: @aaronsteers