Skip to content

fix(mcp): remove stale stats from logs list response - #3583

Merged
akshaydeo merged 1 commit into
maximhq:devfrom
Vaibhav701161:fix/mcp-logs-remove-stale-list-stats
May 19, 2026
Merged

fix(mcp): remove stale stats from logs list response#3583
akshaydeo merged 1 commit into
maximhq:devfrom
Vaibhav701161:fix/mcp-logs-remove-stale-list-stats

Conversation

@Vaibhav701161

Copy link
Copy Markdown
Contributor

Summary

Removes the stale top-level stats object from the MCP logs list response.

While testing MCP logs end-to-end, /api/mcp-logs?limit=5 returned the correct log row with status: success and cost: 0.5, but the top-level stats object in the same response showed zero values for success_rate, average_latency, and total_cost.

The correct stats are already available from the dedicated /api/mcp-logs/stats endpoint, which is what the MCP Logs UI cards use.

Changes

  • Removed stats from the /api/mcp-logs list response.
  • Kept log rows, pagination, and has_logs unchanged.
  • Kept /api/mcp-logs/stats unchanged.
  • Updated frontend response types.
  • Updated MCP Logs pagination to use pagination.total_count.
  • Updated the OpenAPI schema for the MCP logs list response.

Type of change

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Chore/CI

Affected areas

  • Core (Go)
  • Transports (HTTP)
  • Providers/Integrations
  • Plugins
  • UI (React)
  • Docs

How to test

Backend:

go test ./framework/logstore/...

go test ./plugins/logging/...

go test ./transports/bifrost-http/handlers/...

UI:

cd ui

npm run build

Runtime verification:

curl -s "http://localhost:9090/api/mcp-logs?limit=5" | jq '{has_stats: has("stats"), log_preserved: (.logs[0] | {tool_name, server_label, status, cost})}'

curl -s "http://localhost:9090/api/mcp-logs/stats" | jq .

Verified that:

  • /api/mcp-logs returns has_stats: false
  • MCP log row is still present with tool_name, server_label, status, and cost
  • /api/mcp-logs/stats still returns correct stats
  • MCP Logs UI still loads and shows the stat cards, log row, and details drawer correctly

Screenshots/Recordings

Added screenshots for:

  • API response showing has_stats: false
  • Dedicated stats endpoint still returning correct values
Screenshot 2026-05-19 122713
  • MCP Logs UI showing correct cards and preserved log row
  • MCP log details drawer showing arguments and result
Screenshot 2026-05-19 122758

Breaking changes

  • Yes
  • No

This removes the top-level stats field from the /api/mcp-logs list response.

Any consumer using that field should use the dedicated /api/mcp-logs/stats endpoint instead.

Related issues

N/A

Security considerations

No security impact. This does not change auth, secrets handling, log storage, or MCP tool execution behavior.

Checklist

  • I read docs/contributing/README.md and followed the guidelines
  • I added/updated tests where appropriate
  • I updated documentation where needed
  • I verified builds succeed (Go and UI)
  • I verified the CI pipeline passes locally if applicable

The stats field in the MCP logs list response (/api/mcp-logs) was only
populated with TotalExecutions, leaving success_rate, average_latency,
and total_cost as zero values - stale and misleading. Remove it from
the list response struct and from the Go result assembly.

UI now reads total_count from pagination (already present in response)
for the paginator, and uses the dedicated /api/mcp-logs/stats endpoint
for the stat cards, which computes all fields correctly.

Preserves:
- log rows, pagination, has_logs
- /api/mcp-logs/stats endpoint
- UI stat cards (they use getMCPLogsStatsQuery)

Signed-off-by: Vaibhav mittal <vaibhavmittal929@gmail.com>
@coderabbitai

coderabbitai Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

Release Notes

  • Refactor
    • Updated the MCP logs search API response structure. The stats field has been removed, and pagination now includes the total count directly. Added a has_logs field to indicate the presence of MCP logs.

Walkthrough

This PR restructures the MCP tool logs search response contract. The stats field (containing total_executions) is removed and replaced with a boolean has_logs indicator, while total_count moves into the pagination object. Changes propagate from OpenAPI schema and TypeScript types through backend Go structs and queries to frontend API clients and consumers.

Changes

MCP Logs Response Refactoring

Layer / File(s) Summary
Response type contract definition
docs/openapi/schemas/management/logging.yaml, ui/lib/types/logs.ts
OpenAPI schema and TypeScript MCPToolLogsResponse both remove the stats field and add has_logs boolean. The pagination type is updated to explicitly include total_count as part of its contract.
Backend response struct and query implementation
framework/logstore/tables.go, framework/logstore/rdb.go
MCPToolLogSearchResult struct removes the Stats field, and SearchMCPToolLogs query no longer populates execution statistics, keeping only Logs, Pagination, and HasLogs in the returned result.
Frontend API types and log page consumer
ui/lib/store/apis/mcpLogsApi.ts, ui/app/workspace/mcp-logs/page.tsx
API response type updates to match the new pagination structure, and MCPLogsPage switches from stats.total_executions to pagination.total_count for pagination calculations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 Stats begone, log the simple way,
Pagination counts what users need to see,
has_logs speaks truth in a byte,
Backend, frontend, API in flight—
One refactor makes the response light! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title directly addresses the main change: removing stale stats from MCP logs list response, which aligns with the core problem and solution.
Description check ✅ Passed The description comprehensively covers all required sections: summary, changes, type of change, affected areas, testing instructions, screenshots, breaking changes, and a complete checklist.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

level=error msg="[linters_context] typechecking error: pattern ./...: directory prefix . does not contain main module or its selected dependencies"


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@greptile-apps

greptile-apps Bot commented May 19, 2026

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5

This PR is safe to merge. It removes a field that was already returning incorrect (all-zero) data and replaces the frontend dependency on it with a value that is correctly populated in the same response object.

The change is narrow and well-contained. pagination.TotalCount is set at every return path in SearchMCPToolLogs, so the frontend switch from stats.total_executions to pagination.total_count is backed by always-present data. The dedicated stats endpoint and all other log fields are untouched. Types, OpenAPI schema, and UI are updated consistently.

No files require special attention.

Important Files Changed

Filename Overview
framework/logstore/tables.go Removes the Stats MCPToolLogStats field from MCPToolLogSearchResult; no other fields are affected.
framework/logstore/rdb.go Drops Stats from both return sites in SearchMCPToolLogs; pagination.TotalCount is already set at both return paths so the frontend switch is sound.
ui/lib/types/logs.ts Updates MCPToolLogsResponse to use Pagination & { total_count: number } intersection type, consistent with the pattern used in LogSessionDetailResponse.
ui/lib/store/apis/mcpLogsApi.ts Removes stats from getMCPLogs return type; MCPToolLogStats import is still needed for getMCPLogsStats endpoint.
ui/app/workspace/mcp-logs/page.tsx Switches totalItems source from logsData?.stats?.total_executions to logsData?.pagination?.total_count, which is the correctly-populated value in the response.
docs/openapi/schemas/management/logging.yaml Removes the stats field from SearchMCPLogsResponse schema, keeping it in sync with the updated Go struct.

Reviews (1): Last reviewed commit: "fix(mcp): remove stale stats from logs l..." | Re-trigger Greptile

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (1)
ui/lib/store/apis/mcpLogsApi.ts (1)

46-51: ⚡ Quick win

Use the shared MCPToolLogsResponse type for getMCPLogs.

This endpoint re-declares a response shape already defined in shared types, which increases drift risk on future contract updates.

♻️ Proposed refactor
 import {
 	MCPToolLogEntry,
 	MCPToolLogFilters,
 	MCPToolLogStats,
+	MCPToolLogsResponse,
 	MCPToolLogFilterData,
 	MCPHistogramResponse,
 	MCPCostHistogramResponse,
 	MCPTopToolsResponse,
 	Pagination,
 } from "`@/lib/types/logs`";
@@
-		getMCPLogs: builder.query<
-			{
-				logs: MCPToolLogEntry[];
-				pagination: Pagination & { total_count: number };
-				has_logs: boolean;
-			},
+		getMCPLogs: builder.query<
+			MCPToolLogsResponse,
 			{
 				filters: MCPToolLogFilters;
 				pagination: Pagination;
 			}
 		>({

As per coding guidelines, "ui/lib/types/*.ts: Define reusable TypeScript types in shared locations (ui/lib/types/ for frontend)."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@ui/lib/store/apis/mcpLogsApi.ts` around lines 46 - 51, The getMCPLogs query
currently re-declares the response shape; update its generic type to use the
shared MCPToolLogsResponse type instead of the inline object shape, and add an
import for MCPToolLogsResponse from the shared types file; update any references
within the getMCPLogs builder.query signature to use MCPToolLogsResponse so the
endpoint consumes the single source-of-truth type.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@ui/lib/store/apis/mcpLogsApi.ts`:
- Around line 46-51: The getMCPLogs query currently re-declares the response
shape; update its generic type to use the shared MCPToolLogsResponse type
instead of the inline object shape, and add an import for MCPToolLogsResponse
from the shared types file; update any references within the getMCPLogs
builder.query signature to use MCPToolLogsResponse so the endpoint consumes the
single source-of-truth type.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e7fd8d24-c6b3-4544-8e70-044641d7b52a

📥 Commits

Reviewing files that changed from the base of the PR and between 30ed554 and cb0e08d.

📒 Files selected for processing (6)
  • docs/openapi/schemas/management/logging.yaml
  • framework/logstore/rdb.go
  • framework/logstore/tables.go
  • ui/app/workspace/mcp-logs/page.tsx
  • ui/lib/store/apis/mcpLogsApi.ts
  • ui/lib/types/logs.ts
💤 Files with no reviewable changes (2)
  • docs/openapi/schemas/management/logging.yaml
  • framework/logstore/tables.go

@akshaydeo
akshaydeo merged commit 4e004af into maximhq:dev May 19, 2026
7 of 9 checks passed
@Vaibhav701161
Vaibhav701161 deleted the fix/mcp-logs-remove-stale-list-stats branch May 19, 2026 07:17
akshaydeo pushed a commit that referenced this pull request May 20, 2026
The stats field in the MCP logs list response (/api/mcp-logs) was only
populated with TotalExecutions, leaving success_rate, average_latency,
and total_cost as zero values - stale and misleading. Remove it from
the list response struct and from the Go result assembly.

UI now reads total_count from pagination (already present in response)
for the paginator, and uses the dedicated /api/mcp-logs/stats endpoint
for the stat cards, which computes all fields correctly.

Preserves:
- log rows, pagination, has_logs
- /api/mcp-logs/stats endpoint
- UI stat cards (they use getMCPLogsStatsQuery)

Signed-off-by: Vaibhav mittal <vaibhavmittal929@gmail.com>
@akshaydeo akshaydeo mentioned this pull request May 20, 2026
akhsaul pushed a commit to akhsaul/bifrost that referenced this pull request Aug 27, 2026
The stats field in the MCP logs list response (/api/mcp-logs) was only
populated with TotalExecutions, leaving success_rate, average_latency,
and total_cost as zero values - stale and misleading. Remove it from
the list response struct and from the Go result assembly.

UI now reads total_count from pagination (already present in response)
for the paginator, and uses the dedicated /api/mcp-logs/stats endpoint
for the stat cards, which computes all fields correctly.

Preserves:
- log rows, pagination, has_logs
- /api/mcp-logs/stats endpoint
- UI stat cards (they use getMCPLogsStatsQuery)

Signed-off-by: Vaibhav mittal <vaibhavmittal929@gmail.com>
occcat pushed a commit to occcat/bifrost that referenced this pull request Sep 2, 2026
The stats field in the MCP logs list response (/api/mcp-logs) was only
populated with TotalExecutions, leaving success_rate, average_latency,
and total_cost as zero values - stale and misleading. Remove it from
the list response struct and from the Go result assembly.

UI now reads total_count from pagination (already present in response)
for the paginator, and uses the dedicated /api/mcp-logs/stats endpoint
for the stat cards, which computes all fields correctly.

Preserves:
- log rows, pagination, has_logs
- /api/mcp-logs/stats endpoint
- UI stat cards (they use getMCPLogsStatsQuery)

Signed-off-by: Vaibhav mittal <vaibhavmittal929@gmail.com>
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