Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 1, 2026

The audit command now extracts MCP tool call statistics from gateway.jsonl files, providing both aggregated metrics and individual call records.

Changes

  • Data structures (audit_report.go): Added MCPToolUsageData with server/tool summaries and individual call records
  • Gateway parsing (gateway_logs.go): extractMCPToolUsageData() parses gateway.jsonl for tool call metadata (sizes, durations, timestamps)
  • Console output (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) statistics
  • JSON export: New mcp_tool_usage field includes complete call history with per-call metadata

Output

Console:

MCP Tool Usage
==============

Server Statistics:
Server  | Requests | Tool Calls | Total Input | Total Output | Avg Duration
github  |       15 |         15 |      10.2KB |       45.8KB |       150ms

Tool Statistics:
Server | Tool             | Calls | Total In | Total Out | Max In | Max Out
github | search_issues    |     5 |   5.1KB  |   30.2KB  | 1.5KB  |  8.9KB

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.jsonl exists; gracefully skipped otherwise.

Original prompt

Make sure that the "audit" command generate table MCP tool calls usage and response size statistics (total, max size)

The JSON should also have every tool call request and response message attached for each tool


💡 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.

Copilot AI and others added 2 commits February 1, 2026 10:42
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
@pelikhan pelikhan marked this pull request as ready for review February 1, 2026 10:48
Copilot AI changed the title [WIP] Add audit command for tool calls usage and response size Add MCP tool usage statistics to audit command Feb 1, 2026
Copilot AI requested a review from pelikhan February 1, 2026 10:49
@pelikhan pelikhan merged commit 6e75585 into main Feb 1, 2026
158 checks passed
@pelikhan pelikhan deleted the copilot/add-audit-command-statistics branch February 1, 2026 11:14
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