Skip to content

Conversation

@yashx007
Copy link

@yashx007 yashx007 commented Nov 8, 2025

Summary

Fixes the Amazon Neptune MCP server so the stderr Loguru handler respects the FASTMCP_LOG_LEVEL environment variable.
Normalizes common aliases (case-insensitive) so user-friendly short names work as expected:

  • WARNWARNING
  • ERRERROR
  • FATALCRITICAL

Unknown/invalid values fall back to INFO.

What changed

  • Added get_fastmcp_log_level() helper which:
    • Reads FASTMCP_LOG_LEVEL (defaults to INFO)
    • Normalizes common aliases and uppercases the value
    • Validates against supported Loguru levels and falls back to INFO if unknown
  • Updated logger setup to use the helper:
logger.add(sys.stderr, level=get_fastmcp_log_level())

Files changed

  • server.py (only)

How tested (local)

Ran unit checks and a small runtime inspection locally to confirm behavior.
Manual checks performed (PowerShell):

# WARN -> WARNING
$env:FASTMCP_LOG_LEVEL='WARN'
python scripts\check_neptune_log_level.py

# ERROR -> ERROR
$env:FASTMCP_LOG_LEVEL='ERROR'
python scripts\check_neptune_log_level.py

# DEBUG -> DEBUG
$env:FASTMCP_LOG_LEVEL='DEBUG'
python scripts\check_neptune_log_level.py

(These confirm the configured handler level matches the normalized value.)
image

Related issue

Resolves: #1581 (amazon-neptune-mcp-server: StdErr logging forced at INFO level)

Notes for reviewers

The change is intentionally scoped to the Neptune server only.
If maintainers prefer a shared helper across MCP servers, get_fastmcp_log_level() can be extracted into a common utility in a follow-up PR.
Tests used during development were run locally; per request they are not included in this PR to keep it minimal.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of the project license.

Copilot AI review requested due to automatic review settings November 8, 2025 06:23
@yashx007 yashx007 changed the title Fix: Neptune MCP server respects FASTMCP_LOG_LEVEL (accept common aliases) fix: Neptune MCP server respects FASTMCP_LOG_LEVEL (accept common aliases) Nov 8, 2025
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 adds dynamic log level configuration through the FASTMCP_LOG_LEVEL environment variable, enabling users to control logging verbosity at runtime instead of using a hardcoded 'INFO' level.

  • Introduces a get_fastmcp_log_level() helper function that reads, validates, and normalizes the log level from environment variables
  • Maps common log level aliases (WARN, ERR, FATAL) to Loguru's canonical level names
  • Falls back to 'INFO' when an invalid level is provided

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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

Labels

None yet

Projects

Status: To triage

Development

Successfully merging this pull request may close these issues.

amazon-neptune-mcp-server: StdErr logging forced at INFO level

1 participant