Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Feb 1, 2026

Extends gh aw logs to display aggregated MCP tool call statistics from gateway.jsonl files, reusing the data structures introduced in #13067 for the audit command.

Changes

Data structures

  • Added MCPToolUsageSummary to LogsData for aggregating tool usage across runs
  • Extended ProcessedRun, RunSummary, and DownloadResult with MCPToolUsage field

Data extraction and aggregation

  • Calls extractMCPToolUsageData() for each run in logs_orchestrator.go
  • Implemented buildMCPToolUsageSummary() to merge statistics across runs:
    • Weighted averaging for duration metrics
    • Max tracking for I/O sizes
    • Aggregates server stats and per-tool summaries

Output

  • Console renders two tables: server statistics (requests, tool calls, I/O, duration, errors) and tool statistics (calls, I/O sizes)
  • JSON includes complete tool call history
  • Individual tool calls excluded from console display

Example

gh aw logs my-workflow --json

Returns aggregated MCP tool usage in mcp_tool_usage field with server stats, tool summaries, and individual call records for analysis.

Original prompt

Reuse the data structures for MCP tool analysis in #13067 and apply it in "logs" so that user can see summarized tool call information.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 4 commits February 1, 2026 11:22
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add summarized tool call information to logs Add MCP tool usage statistics to logs command Feb 1, 2026
Copilot AI requested a review from pelikhan February 1, 2026 11:30
@pelikhan
Copy link
Contributor

pelikhan commented Feb 1, 2026

@copilot runs logs command and show output

Copy link
Contributor Author

Copilot AI commented Feb 1, 2026

@copilot runs logs command and show output

The gh aw logs command now displays MCP tool usage statistics in both console and JSON formats.

Console Output:

The command shows two new tables when MCP servers are detected in workflow runs:

  1. Server Statistics - Aggregated metrics per MCP server:

    • Request count and tool call count
    • Total input/output sizes
    • Average duration across all calls
  2. Tool Statistics - Detailed per-tool breakdown:

    • Call count per tool
    • Total and max I/O sizes
    • Performance metrics

Example Console Output:

━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
                            🔧 MCP Tool Usage
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

                            Server Statistics
────────────────────────────────────────────────────────────────────────────────────────

Server       Requests  Tool Calls  Total Input  Total Output  Avg Duration
github       8         8           4.5 KB       18.2 KB       145ms
playwright   4         4           1.8 KB       3.5 KB        165ms

                             Tool Statistics
────────────────────────────────────────────────────────────────────────────────────────

Server      Tool             Calls  Total Input  Total Output  Max Input  Max Output
github      search_issues    5      3.2 KB       15.1 KB       1.5 KB     6.0 KB
github      get_repository   3      1.3 KB       3.1 KB        512 B      2.0 KB
playwright  navigate         2      1.0 KB       2.0 KB        512 B      1.0 KB
playwright  click            2      800 B        1.5 KB        400 B      800 B

JSON Output:

With --json flag, the output includes mcp_tool_usage field with:

  • summary: Aggregated per-tool statistics
  • servers: Server-level statistics
  • tool_calls: Complete history of individual tool calls with timestamps

The data is aggregated across all downloaded workflow runs, with weighted averaging for duration metrics and max tracking for I/O sizes.

See full demo output: /tmp/demo_output.md

@pelikhan pelikhan marked this pull request as ready for review February 1, 2026 11:41
@pelikhan pelikhan merged commit ae6bab1 into main Feb 1, 2026
2 checks passed
@pelikhan pelikhan deleted the copilot/reuse-mcp-tool-data-structures branch February 1, 2026 11:41
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