mcp icon indicating copy to clipboard operation
mcp copied to clipboard

Add detailed logs from the MCP Server

Open anannya03 opened this issue 2 months ago • 0 comments

What does this PR do?

Adds a unified, configurable logging system to help users and developers diagnose issues, inspect MCP protocol activity, and debug tool execution without requiring complex tools like PerfView or dotnet-trace. This enables clear, actionable visibility into MCP Server behavior through configurable console and file logging.

Key Changes

  • Enhanced ServiceStartCommand – Added ASP.NET Core–compliant logging configuration with CLI, environment, and appsettings hierarchy (CLI → Env → Config → Default).

  • Custom FileLoggerProvider – Added file logging with {timestamp} and {pid} placeholders and automatic directory creation.

  • New CLI options:

  1. --debug: Enables debug-level console logging.
  2. --log-level: Sets log verbosity (Trace, Debug, Information, etc.).
  3. --log-file: Writes logs to a specified file.
  • Environment variables:
  1. AZMCP_LOG_LEVEL, AZMCP_LOG_FILE (custom)
  2. LOGGING__LOGLEVEL__DEFAULT, LOGGING__FILE__PATH (ASP.NET Core standard).
  • Routes logs to STDERR to keep MCP protocol output clean.

  • Updated live-test.yml with environment variables for automated logging

GitHub issue number?

https://github.com/microsoft/mcp/issues/142

Pre-merge Checklist

  • [ ] Required for All PRs
    • [ ] Read contribution guidelines
    • [ ] PR title clearly describes the change
    • [ ] Commit history is clean with descriptive messages (cleanup guide)
    • [ ] Added comprehensive tests for new/modified functionality
    • [ ] Updated servers/Azure.Mcp.Server/CHANGELOG.md and/or servers/Fabric.Mcp.Server/CHANGELOG.md for product changes (features, bug fixes, UI/UX, updated dependencies)

anannya03 avatar Oct 13 '25 04:10 anannya03