Enable comprehensive MCP server logging for Copilot CLI workflows#1491
Closed
Enable comprehensive MCP server logging for Copilot CLI workflows#1491
Conversation
- Add XDG_STATE_HOME environment variable for MCP state/logs - Add DEBUG="*" environment variable to enable verbose logging - Create /tmp/gh-aw/mcp-logs directory for MCP server logs - These changes enable maximum logging for MCP servers in Copilot CLI Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
- Test DEBUG environment variable presence - Test XDG_STATE_HOME environment variable presence - Test XDG_CONFIG_HOME environment variable presence - Test MCP logs directory creation in config rendering Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Investigate MCP server loading issue in run 18418361861
Enable comprehensive MCP server logging for Copilot CLI workflows
Oct 10, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Workflow runs using the Copilot CLI engine were experiencing MCP server loading issues with insufficient diagnostic information to determine the root cause. When MCP servers failed to load or initialize, there was no way to see detailed connection attempts, server spawn logs, or communication errors.
Solution
This PR enables maximum logging for MCP servers in Copilot CLI workflows by adding debug environment variables and creating dedicated log directories. These changes provide comprehensive diagnostic capabilities without affecting workflow behavior.
Changes Made
1. Added Debug Environment Variables
Two new environment variables are now automatically set for all Copilot engine workflows:
DEBUG="*"- Enables verbose debug logging for all Node.js-based MCP servers, showing connection attempts, server spawning, and inter-process communicationXDG_STATE_HOME=/tmp/gh-aw/.copilot/state- Provides a dedicated directory for MCP server state and log files2. Created MCP Logs Directory
Modified the MCP configuration rendering to create
/tmp/gh-aw/mcp-logsdirectory, providing a centralized location for MCP server-specific logs.3. Verified Output Paths
Confirmed that Copilot CLI output correctly flows to
agent-stdio.logvia theteecommand, while detailed debug logs go to/tmp/gh-aw/.copilot/logs/via the--log-level allflag (already configured).Logging Output Locations
With these changes, MCP-related logs are now available in multiple locations for comprehensive debugging:
/tmp/gh-aw/agent-stdio.log- Main stdout/stderr from Copilot CLI (via tee)/tmp/gh-aw/.copilot/logs/- Copilot CLI debug logs (via --log-dir flag)/tmp/gh-aw/.copilot/state/- MCP server state and logs (via XDG_STATE_HOME)/tmp/gh-aw/mcp-logs/- Additional MCP server logs (via mkdir)All these directories are collected as workflow artifacts and can be downloaded for analysis when investigating MCP server issues.
Example Impact
Before this change, a workflow with MCP servers would have minimal logging:
After this change, comprehensive logging is enabled:
Testing
Benefits
When investigating MCP server issues like the one in run 18418361861, developers can now:
This comprehensive logging enables faster diagnosis and resolution of MCP-related workflow failures.
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.