Skip to content

Conversation

@ineersa
Copy link

@ineersa ineersa commented Aug 19, 2025

Q A
Bug fix? yes
New feature? no
Docs? no
Issues Fix #306
License MIT

Added monolog as dev dependency.
Swapped ConsoleLogger to Monolog -> STDERR with JsonFormatter.
Added commentary with explanation

@ineersa ineersa marked this pull request as ready for review August 19, 2025 22:38
@carsonbot carsonbot added Bug Something isn't working MCP SDK Issues & PRs about the MCP SDK Status: Needs Review labels Aug 19, 2025
@OskarStark OskarStark requested a review from Copilot August 21, 2025 19:45
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the MCP SDK example to use proper Monolog logging instead of Symfony's ConsoleLogger. The change addresses issue #306 by implementing structured JSON logging to STDERR as required by the MCP protocol.

Key changes:

  • Replace Symfony ConsoleLogger with Monolog logger configured for JSON output to STDERR
  • Add Monolog as a development dependency
  • Include detailed comments explaining the logging requirements and limitations

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/mcp-sdk/examples/cli/index.php Replace ConsoleLogger with Monolog using StreamHandler and JsonFormatter for STDERR output
src/mcp-sdk/composer.json Add monolog/monolog as development dependency

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

$logger = new SymfonyConsole\Logger\ConsoleLogger($output);

// Setup *Monolog* logger, logger must output JSON to stream to STDERR
// **WARNING** this will work only on the development stage with @modelcontextprotocol/inspector, but not in a real client
Copy link

Copilot AI Aug 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] The comment uses Markdown formatting (Monolog and WARNING) which is not appropriate for PHP code comments. Consider using plain text formatting for better readability in the source code.

Suggested change
// **WARNING** this will work only on the development stage with @modelcontextprotocol/inspector, but not in a real client
// Setup Monolog logger, logger must output JSON to stream to STDERR
// WARNING: this will work only on the development stage with @modelcontextprotocol/inspector, but not in a real client

Copilot uses AI. Check for mistakes.
@chr-hertel
Copy link
Member

Closed due to moving this MCP SDK to https://github.com/modelcontextprotocol/php-sdk.

@chr-hertel chr-hertel closed this Sep 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working MCP SDK Issues & PRs about the MCP SDK Status: Needs Review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[MCP SDK] Logging

3 participants