Skip to content

fix(mcp): support network log pagination - #356

Merged
meAmitPatil merged 3 commits into
superserve-ai:mainfrom
Prajwal2246:fix/mcp-network-log-pagination
Oct 5, 2026
Merged

meAmitPatil merged 3 commits into
superserve-ai:mainfrom
Prajwal2246:fix/mcp-network-log-pagination

Conversation

@Prajwal2246

@Prajwal2246 Prajwal2246 commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Related Issues

Fixes #355

Description

sandbox_network_log returns next_cursor but cannot accept it, so callers cannot retrieve older pages beyond the tool's 200-event cap.

Add an optional string before input, document how to reuse next_cursor, and forward it unchanged to the network-log endpoint. The input supports opaque pagination tokens and RFC3339 time bounds; the backend validates the format. Requests remain control-plane-only and do not resume the sandbox.

Additional Context

Regression tests exercise the real MCP transport, handler, and API client with mocked HTTP responses. They cover the backend's base64url-encoded {t, k, i} cursor, RFC3339 timestamp support, schema discovery, and rejection of non-string inputs. The opaque-cursor case was confirmed to fail with timestamp-only validation and pass after its removal.

Testing

  • Tested locally

  • Added/updated tests

  • All tests passing (with the locale noted below)

  • bun run lint

  • bun run format:check

  • bun run typecheck

  • bun run docs:check-nav

  • LC_ALL=en_US.UTF-8 LANG=en_US.UTF-8 bun run test

  • bun run build

The initial test run under this Mac's default locale failed two existing console hourly-label assertions (1 Jun, 5 am versus Jun 1, 5 AM). The affected console files are unchanged from upstream; the tests pass with the US locale they expect.

MCP: 96 tests passed; 2 credential-dependent E2E tests skipped. No live sandbox/API pagination was tested.

Screenshots/Demo

No UI changes. To run the focused regression:

cd packages/mcp
bun run test tests/networkLog.test.ts --reporter=verbose

@vercel

vercel Bot commented Sep 30, 2026

Copy link
Copy Markdown

@Prajwal2246 is attempting to deploy a commit to the superserve Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps

greptile-apps Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

RetriggerConfidence Score: 5/5

[Medium risk] Adds pagination support to network log queries.

The PR appears safe to merge; no actionable issues were identified.

Summary

The PR makes sandbox_network_log accept a pagination cursor and forwards it to the control-plane network-log endpoint.

  • Documents how to use next_cursor to retrieve the next page.
  • Adds a transport-level regression test for cursor forwarding and invalid-input rejection.

Reviews (1) · Last reviewed commit: "fix(mcp): support network log pagination"

@onepatch-agent onepatch-agent Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

sandbox_network_log gains an optional before input so a caller can page past the tool's 200-event cap, forwarded unchanged to the control plane's GET /sandboxes/{id}/network.

Watching

  • The control plane's DB pool — the share of connection acquisitions that wait for a free connection, since each page costs two audit queries (ListNetFlowEvents + ListProxyAuditEvents) on the pool that also serves sandbox lifecycle work, and the loop's length is decided by a model.
  • Sandbox create/pause/resume/delete failure rate, where pool pressure stops being internal and becomes a failed operation.
  • Resumes per pause — the change promises paging stays control-plane-only and never wakes a paused sandbox, and this is the one part of that promise production can falsify.

Would fail it

  • Waiting acquisitions rise by 5+ points and at least double against the 24h pre-deploy baseline.
  • Lifecycle failures rise 2+ points and 1.5× against baseline.
  • Resumes per pause rise 1.5× and by 0.2 against baseline.

One note, since it affects whether the fix works rather than whether it's safe: before is validated as z.string().datetime({ offset: true }), but the server's next_cursor is base64url JSON from encodeNetworkCursor (sandbox:internal/api/handlers_network.go), not a timestamp. The API accepts either form; the new zod constraint accepts only the timestamp, so the loop the tool description advertises looks likely to be refused at the MCP boundary. The test passes because its mock returns an RFC3339 next_cursor.

Note also that neither the MCP server nor that endpoint emits any telemetry today, so whether a second page is ever fetched is not observable from here — the checks above cover the cost of paging, not its success.

changes/superserve-ai--superserve--pr-356 · awaiting merge

@Prajwal2246

Copy link
Copy Markdown
Contributor Author

Thanks for catching this. I checked encodeNetworkCursor in sandbox/internal/api/handlers_network.go; you're right that next_cursor is a base64url-encoded token, and the original timestamp-only mock missed that contract.

Fixed in fde8e6e: before now accepts a string and is forwarded unchanged, with format validation left to the backend. The tool description covers both opaque cursors and RFC3339 time bounds.

The regression now uses the backend's encoded {t, k, i} cursor format. It failed with the previous validation and passes with this correction. Timestamp support and non-string input rejection are also covered. All local contribution checks pass; MCP has 96 passing tests and 2 credential-dependent tests skipped. Live API pagination has not been tested.

@vercel

vercel Bot commented Oct 5, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
console Ready Ready Preview Oct 5, 2026 5:50pm UTC
superserve-mcp Ready Ready Preview Oct 5, 2026 5:50pm UTC
ui Ready Ready Preview Oct 5, 2026 5:50pm UTC

Request Review

@meAmitPatil meAmitPatil left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM !!

@meAmitPatil
meAmitPatil merged commit 5ed4ab1 into superserve-ai:main Oct 5, 2026
5 checks passed
@Prajwal2246
Prajwal2246 deleted the fix/mcp-network-log-pagination branch October 5, 2026 18:27

This branch was successfully deployed

3 active deployments
Preview – console — debe2f69 Deployed Oct 5, 2026 by vercel[bot]
Preview – superserve-mcp — debe2f69 Deployed Oct 5, 2026 by vercel[bot]
Preview – ui — debe2f69 Deployed Oct 5, 2026 by vercel[bot]
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.

MCP network logs return a cursor but cannot fetch the next page

2 participants