Skip to content

Expose identifiable MCP tool calls in logs JSON - #59579

Merged
pelikhan merged 1 commit into
mainfrom
copilot/log-mcp-tool-calls
Sep 9, 2026
Merged

Expose identifiable MCP tool calls in logs JSON#59579
pelikhan merged 1 commit into
mainfrom
copilot/log-mcp-tool-calls

Conversation

Copilot AI commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Compact usage artifacts omitted MCP call identity, leaving gh aw logs --json consumers unable to determine which server and tool produced each call.

  • Usage capture

    • Record timestamp, server name, and tool name for each MCP call.
    • Retain synthetic call IDs without exposing arguments, results, or gateway identifiers.
  • Logs output

    • Map the new fields into mcp_tool_usage.tool_calls.
{
  "timestamp": "2026-09-09T00:00:00Z",
  "server_name": "github",
  "tool_name": "issue_read",
  "status": "success"
}
  • Coverage and documentation
    • Cover artifact generation, Go mapping, and JSON serialization.
    • Document the expanded usage artifact schema.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • github.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "github.com"

See Network Configuration for more information.

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 · 43.5 AIC · ⌖ 8.68 AIC · ⊞ 9.2K ·
Comment /souschef to run again

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title Log identifiable MCP tool calls in logs JSON Expose identifiable MCP tool calls in logs JSON Sep 9, 2026
Copilot AI requested a review from pelikhan September 9, 2026 00:44
@pelikhan
pelikhan marked this pull request as ready for review September 9, 2026 00:45
Copilot AI balanced review requested due to automatic review settings September 9, 2026 00:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The implementation consistently propagates the new fields with appropriate coverage and preserves sensitive payload exclusions.

Pull request overview

Extends compact usage artifacts so gh aw logs --json exposes identifiable MCP tool calls without payload data.

Changes:

  • Captures timestamps and server/tool names for MCP calls.
  • Maps and serializes the new fields in logs JSON.
  • Adds generation, mapping, serialization tests, and schema documentation.
File summaries
File Description
pkg/cli/logs_usage_activity.go Maps MCP call identity fields into logs data.
pkg/cli/logs_usage_activity_test.go Tests usage artifact parsing and mapping.
pkg/cli/logs_json_test.go Tests MCP identities in JSON output.
docs/src/content/docs/reference/artifacts.md Documents expanded tool-call records.
actions/setup/js/generate_usage_activity_summary.test.cjs Tests identity capture and payload exclusion.
actions/setup/js/generate_usage_activity_summary.cjs Records timestamp, server, and tool per call.
Review details
  • Files reviewed: 6/6 changed files
  • Comments generated: 0
  • Review effort level: Balanced

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🎉 Thanks for this contribution, Copilot! This PR looks ready for review.

The changes cleanly expose MCP tool call identity (timestamp, server name, tool name) in the logs JSON output, which directly addresses the gap in gh aw logs --json consumers' ability to determine which server and tool produced each call. The implementation is focused:

✅ Compact artifact generation — Records timestamp, server name, and tool name per MCP call
✅ Go mapping — Updated usageActivityGatewayCall struct with the three new fields
✅ JSON serialization — Properly exported fields in test fixtures and documented schema
✅ Comprehensive tests — Added coverage across JavaScript, Go unit tests, and documentation

The PR preserves opaque synthetic call IDs without exposing arguments, results, or gateway identifiers—exactly the right balance for observability and safety.

Generated by ✅ Contribution Check · copilot · auto · 50.5 AIC · ⌖ 7.02 AIC · ⊞ 9.3K ·

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

PR Code Quality Reviewer completed the code quality review.

🔎 Code quality review by PR Code Quality Reviewer

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Ponytail Reviewer completed successfully!

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • ab.chatgpt.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "ab.chatgpt.com"

See Network Configuration for more information.

Generated by Ponytail Reviewer for #59579

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Test Quality Sentinel completed test quality analysis.

Test Quality Sentinel skipped because pre-fetch PR data was unavailable: unable to fetch test file diff

🧪 Test quality analysis by Test Quality Sentinel

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🧠 Matt Pocock Skills Reviewer has completed the skills-based review. ✅

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Design Decision Gate 🏗️ completed the design decision gate check. See the comment below for the result and any generated ADR draft.

No ADR enforcement needed: PR does not have the 'implementation' label and has ≤100 new lines of code in business logic directories.

🏗️ ADR gate enforced by Design Decision Gate 🏗️

@gh-aw-bot

Copy link
Copy Markdown
Collaborator
pr-sous-chef

@copilot Please take the next forward-progress pass on PR #59579.

  • Re-check current HEAD for any remaining review, CI, or branch-state follow-up.
  • Refresh the branch if GitHub allows it.
  • Run the pr-finisher skill and push the smallest needed fixup, or provide a concise maintainer-facing handoff if no code change is needed.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • github.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "github.com"

See Network Configuration for more information.

Generated by 👨‍🍳 PR Sous Chef · pi · gpt54 · 43.5 AIC · ⌖ 8.68 AIC · ⊞ 9.2K ·
Comment /souschef to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ponytail pass focused on deletion/shrink only. Two opportunities to reduce plumbing and assertion duplication while keeping behavior unchanged.

net: -14 lines possible.

Warning

Firewall blocked 1 domain

The following domain was blocked by the firewall during workflow execution:

  • ab.chatgpt.com

To allow these domains, add them to the network.allowed list in your workflow frontmatter:

network:
  allowed:
    - defaults
    - "ab.chatgpt.com"

See Network Configuration for more information.

Generated by ✂️ Ponytail Reviewer for #59579 · codex · gpt53codex · 4.14 AIC · ⌖ 3.15 AIC · ⊞ 13.9K
Comment /ponytail to run again

timestamp,
server_name: serverName,
tool_name: toolName,
request_size: inputSize,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

actions/setup/js/generate_usage_activity_summary.cjs:L429: shrink: pass full gatewayCall object instead of threading timestamp as a new positional arg. Derive timestamp inside recordGatewayToolCall from the object.

assert.Equal(t, 5, summary.Gateway.TotalCalls, "gateway total_calls should be parsed from JSON")
require.Len(t, summary.Gateway.ToolCalls, 1, "gateway tool_calls should be parsed from JSON")
assert.Equal(t, usageActivityGatewayCall{ToolCallID: "call-1", RequestSize: 100, ResponseSize: 200, DurationMS: 25, Outcome: "success"}, summary.Gateway.ToolCalls[0])
assert.Equal(t, usageActivityGatewayCall{ToolCallID: "call-1", Timestamp: "2026-09-09T00:00:00Z", ServerName: "github", ToolName: "issue_read", RequestSize: 100, ResponseSize: 200, DurationMS: 25, Outcome: "success"}, summary.Gateway.ToolCalls[0])

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pkg/cli/logs_usage_activity_test.go:L54: shrink: full-struct equality duplicates every field in multiple tests. Assert only newly added Timestamp/ServerName/ToolName fields and reuse existing size/outcome checks.

@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

Comment Memory

reviewed_at: 2026-09-09T02:01:20Z
review_event: COMMENT
top_themes:
  - no blocking issues found
files_reviewed:
  - actions/setup/js/generate_usage_activity_summary.cjs
  - actions/setup/js/generate_usage_activity_summary.test.cjs
  - docs/src/content/docs/reference/artifacts.md
  - pkg/cli/logs_json_test.go
  - pkg/cli/logs_usage_activity.go
  - pkg/cli/logs_usage_activity_test.go
comment_count: 0

Note

This comment is managed by comment memory.

It stores persistent context for this thread in the code block at the top of this comment.
Edit only the text inside the backtick fences; workflow metadata and the footer are regenerated automatically.

Learn more about comment memory

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt54 · 47.1 AIC · ⌖ 7.32 AIC · ⊞ 21.8K ·
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Verdict

No blocking issues in the changed lines.

Reviewed themes

I checked the new MCP tool-call identity fields across summary generation, Go backfill/mapping, JSON serialization, tests, and docs. The only candidate concern was backward-compatibility for older summaries missing these fields, but the added fields already deserialize to zero values in Go and the code path tolerates empty strings, so that is not an actionable defect.

🔎 Code quality review by PR Code Quality Reviewer · copilot · gpt54 · 47.1 AIC · ⌖ 7.32 AIC · ⊞ 21.8K
Comment /review to run again

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Skills-Based Review 🧠

Small, well-scoped plumbing change: threads timestamp, server_name, and tool_name through the JS gateway/RPC parsers into the existing MCPToolCall struct (which already had these JSON fields defined but unpopulated for gateway-sourced calls). Tests were updated at both the JS (generate_usage_activity_summary.test.cjs) and Go (logs_usage_activity_test.go, logs_json_test.go) layers to assert the new fields round-trip correctly, and docs (artifacts.md) were updated to match the new schema example.

📋 Notes (non-blocking)
  • String(entry.timestamp || "") defaults to an empty string when missing, which is consistent with how serverName/toolName already handle absent fields elsewhere in the file — no new class of bug introduced.
  • No PII/secret redaction concerns: server_name/tool_name are tool identifiers, not arguments/results, matching the PR description's intent ("Retain synthetic call IDs without exposing arguments, results, or gateway identifiers"). Existing secret-redaction tests (not.toContain("secret-tool-id")) still pass per the diff.
  • Test coverage follows TDD principles reasonably well: assertions cover both the gateway JSONL and RPC-message JSONL code paths, and verify the empty-timestamp fallback case.

No actionable issues found. Approving.

🧠 Reviewed using Matt Pocock's skills by Matt Pocock Skills Reviewer · copilot · sonnet50 · 31.1 AIC · ⌖ 14.6 AIC · ⊞ 10.3K
Comment /matt to run again

@pelikhan
pelikhan merged commit bce650c into main Sep 9, 2026
142 of 143 checks passed
@pelikhan
pelikhan deleted the copilot/log-mcp-tool-calls branch September 9, 2026 02:14
Copilot stopped work on behalf of gh-aw-bot due to an error September 9, 2026 02:14
Copilot AI requested a review from gh-aw-bot September 9, 2026 02:14
@github-actions

github-actions Bot commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

🎉 This pull request is included in a new release.

Release: v0.89.0

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.

4 participants