Skip to content

Conversation

@abrookins
Copy link
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings July 10, 2025 17:23
Copy link
Contributor

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 prevents MCP servers running in stdio mode from logging to stdout, which would interfere with the MCP protocol communication. The changes ensure all logging is redirected to stderr when using stdio mode, while maintaining normal logging behavior for other modes.

  • Introduces a dedicated configure_mcp_logging() function for stdio mode that forces all logging to stderr
  • Updates CLI commands to configure logging per-command rather than at module level
  • Replaces noisy logging statements with comments in the vectorstore factory

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
agent_memory_server/logging.py Adds new configure_mcp_logging() function and updates existing logging to use stderr
agent_memory_server/cli.py Moves logging configuration from module level to per-command and uses MCP-specific logging for stdio mode
agent_memory_server/vectorstore_factory.py Replaces logging statements with comments to avoid stdout contamination
tests/test_cli.py Updates test mocks to use the new configure_mcp_logging function

Comment on lines +47 to +48
root_logger.handlers.clear()

Copy link

Copilot AI Jul 10, 2025

Choose a reason for hiding this comment

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

Clearing all handlers globally could affect other parts of the application that may have configured their own handlers. Consider being more selective about which handlers to remove or document this behavior clearly.

Suggested change
root_logger.handlers.clear()
# Remove only handlers added by this module
for handler in root_logger.handlers[:]:
if isinstance(handler, logging.StreamHandler) and handler.stream == sys.stderr:
root_logger.removeHandler(handler)

Copilot uses AI. Check for mistakes.
@abrookins abrookins merged commit 09ce62a into main Jul 11, 2025
9 checks passed
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.

2 participants