fix: infer MCP tool-call status from level/error when status field is absent#34061
Merged
Conversation
Co-authored-by: pelikhan <[email protected]>
… absent Co-authored-by: pelikhan <[email protected]>
…for status assert Co-authored-by: pelikhan <[email protected]>
Copilot
AI
changed the title
[WIP] Fix MCP tool-call
fix: infer MCP tool-call status from level/error when status field is absent
May 22, 2026
status=unknown in workflow audit telemetry capture
Contributor
There was a problem hiding this comment.
Pull request overview
This PR updates the MCP gateway log parser to handle post-OTel format drift where gateway.jsonl tool-call entries may omit the "status" field, ensuring tool-call status and error metrics are still computed correctly.
Changes:
- Infer
MCPToolCall.Statusas"error"whenlevel:"error"orerroris present, otherwise default to"success"whenstatusis absent. - Count log entries as errors when
level:"error"is present (to avoid under-counting errors with missingstatus/errorfields). - Add unit tests covering status inference and level-based error counting.
- Update GitHub Actions lock/workflow files (includes a schedule change for the developer-docs consolidator workflow).
Show a summary per file
| File | Description |
|---|---|
| pkg/cli/gateway_logs_mcp.go | Infer per-tool-call status when status is missing. |
| pkg/cli/gateway_logs_parsing.go | Treat level:"error" entries as errors for metrics counting. |
| pkg/cli/gateway_logs_test.go | Add tests for status inference and level-based error counting. |
| .github/workflows/release.lock.yml | Update pinned docker/setup-buildx-action reference. |
| .github/workflows/developer-docs-consolidator.lock.yml | Change schedule to weekly and update lock content. |
| .github/aw/actions-lock.json | Add lock entry for docker/setup-buildx-action@v4. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 6/6 changed files
- Comments generated: 2
Comment on lines
+166
to
169
| if entry.Status == "error" || entry.Error != "" || entry.Level == "error" { | ||
| metrics.TotalErrors++ | ||
| if entry.ServerName != "" { | ||
| server := getOrCreateServer(metrics, entry.ServerName) |
Comment on lines
69
to
+71
| schedule: | ||
| - cron: "19 13 * * *" | ||
| # Friendly format: daily (scattered) | ||
| - cron: "19 13 * * 6" | ||
| # Friendly format: weekly (scattered) |
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.
Post-OTel-collector migration,
gateway.jsonlentries stopped emitting an explicit"status"string field. The parser blindly copiedentry.Status(empty"") intoMCPToolCall.Status, which downstream aggregators rendered as"unknown"— breaking error-rate, cost-per-tool, and retry analytics for all 165+ tool calls in the audit.Changes
pkg/cli/gateway_logs_mcp.go—extractToolCallsFromGatewayLogentry.Status == "", infer"error"ifentry.Error != ""orentry.Level == "error", otherwise default to"success":pkg/cli/gateway_logs_parsing.go—processGatewayLogEntryentry.Level == "error"soTotalErrors/ErrorCountfields aren't under-counted for the new log format:Tests
TestExtractToolCallsStatusInference: 5 sub-cases — explicit status pass-through,level:"error"inference,errorfield inference, andlevel:"info"→ success default.TestProcessGatewayLogEntryLevelErrorCounting: verifies error counters increment when onlylevel:"error"is present.