Add MCP tool usage statistics to audit command #13067
Merged
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.
The audit command now extracts MCP tool call statistics from
gateway.jsonlfiles, providing both aggregated metrics and individual call records.Changes
audit_report.go): AddedMCPToolUsageDatawith server/tool summaries and individual call recordsgateway_logs.go):extractMCPToolUsageData()parses gateway.jsonl for tool call metadata (sizes, durations, timestamps)audit_report_render.go): Two tables showing server-level (requests, total I/O, avg duration) and tool-level (call count, total/max input/output sizes) statisticsmcp_tool_usagefield includes complete call history with per-call metadataOutput
Console:
JSON:
{ "mcp_tool_usage": { "summary": [{ "server_name": "github", "tool_name": "search_issues", "call_count": 5, "total_input_size": 5230, "total_output_size": 30924, "max_input_size": 1536, "max_output_size": 9112 }], "tool_calls": [{ "timestamp": "2024-01-12T10:00:00Z", "server_name": "github", "tool_name": "search_issues", "input_size": 1024, "output_size": 5120, "duration": "145ms", "status": "success" }] } }Gateway logs contain call metadata (sizes, timestamps, durations) but not request/response payloads. Statistics are extracted when
gateway.jsonlexists; gracefully skipped otherwise.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.