Skip to content

refactor(mcp): unify workbench pagination defaults and ID formatting - #1186

Merged
kyasbal merged 5 commits into
GoogleCloudPlatform:mainfrom
Ackberry:mcp/unify-workbench-tools
Oct 28, 2026
Merged

kyasbal merged 5 commits into
GoogleCloudPlatform:mainfrom
Ackberry:mcp/unify-workbench-tools

Conversation

@Ackberry

Copy link
Copy Markdown
Contributor

This refactors the MCP workbench tools to share page-size handling and ID formatting without changing their output.

  • Added NormalizePageSize and used it in Paginate and handleGetResourceRevisions. Nonpositive sizes use the default, and positive maximums cap the result. A nonpositive maximum means no cap.
  • Reused formatID for log and timeline IDs in workbench search responses.
  • Kept pagination at its existing layers and added comments explaining why:
    • Timeline logs are paginated after retrieval because linked-timeline information is aggregated across all matches.
    • Resource revisions are paginated in the workbench to limit manifest reads and change calculations to the requested page and the preceding revision needed for comparison.

Added table-driven tests covering defaulting, limits, and uncapped sizes.

Validation:

  • TestNormalizePageSize and TestPaginate pass.
  • Full MCP tests and lint were blocked locally by missing frontend assets (dist/browser).

Fixes #1125

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request refactors page size normalization by extracting the logic into a reusable NormalizePageSize function in pkg/server/mcp/mdtemplate/template.go and adding comprehensive unit tests for it. It updates the call sites in workbench_detail.go to use this new function. Additionally, it simplifies ID formatting in workbench_search.go by replacing strconv.FormatUint calls with a helper function formatID and removing the unused strconv import. There are no review comments to address.

Comment thread pkg/server/mcp/mdtemplate/template.go Resolved
Comment thread pkg/server/mcp/workbench_detail.go Resolved
@kyasbal

kyasbal commented Oct 27, 2026

Copy link
Copy Markdown
Member

/gcbrun

@kyasbal
kyasbal enabled auto-merge October 28, 2026 01:16
@kyasbal
kyasbal added this pull request to the merge queue Oct 28, 2026
Merged via the queue into GoogleCloudPlatform:main with commit 0fb67fb Oct 28, 2026
17 checks passed
@Ackberry
Ackberry deleted the mcp/unify-workbench-tools branch October 28, 2026 01:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants