Skip to content

Fix ServeCommand output interfering with stdio JSON-RPC communication #34

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

Merged
merged 1 commit into from
Jul 13, 2025

Conversation

CodeWithKyrian
Copy link
Contributor

This PR fixes an issue where the ServeCommand startup messages were being written to STDOUT, causing JSON parsing errors in MCP clients using stdio transport.

Problem:
Laravel's console output methods (info(), line(), etc.) sometimes write to STDOUT. In stdio MCP transport, STDOUT is reserved for JSON-RPC communication, so any extra output breaks the protocol.

Solution:

  • Check if output supports error streams (ConsoleOutputInterface)
  • Redirect startup messages to STDERR when available
  • Fall back to no output if error stream unavailable

Fixes #33

Console output methods sometimes write to STDOUT, which interferes with JSON-RPC communication in stdio mode. This redirects startup messages to STDERR when available.
@CodeWithKyrian CodeWithKyrian linked an issue Jul 13, 2025 that may be closed by this pull request
@CodeWithKyrian CodeWithKyrian merged commit 6380d27 into main Jul 13, 2025
8 checks passed
@CodeWithKyrian CodeWithKyrian deleted the 33-stdio-mode-has-logging-info-in-stdio branch July 13, 2025 00:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

STDIO mode has logging info in STDIO
1 participant