@@ -36,15 +36,15 @@ type graphCommInfo struct {
3636type listFlowsResponse struct {
3737 Flows []graphFlowInfo `json:"flows"`
3838 DerivedState map [string ]any `json:"derived_state"`
39- Pagination map [ string ] any `json:"pagination"`
39+ Pagination paging. Page `json:"pagination"`
4040}
4141
4242// listCommunitiesResponse holds the listCommunities wire payload.
4343// @intent preserve the legacy listCommunities response shape with typed fields.
4444type listCommunitiesResponse struct {
4545 Communities []graphCommInfo `json:"communities"`
4646 DerivedState map [string ]any `json:"derived_state"`
47- Pagination map [ string ] any `json:"pagination"`
47+ Pagination paging. Page `json:"pagination"`
4848}
4949
5050// communityMemberSummary is a typed member entry for getCommunity.
@@ -60,7 +60,7 @@ type getCommunityResponse struct {
6060 DerivedState map [string ]any `json:"derived_state"`
6161 Coverage * float64 `json:"coverage,omitempty"`
6262 Members []communityMemberSummary `json:"members,omitempty"`
63- MembersPagination map [ string ] any `json:"members_pagination,omitempty"`
63+ MembersPagination * paging. Page `json:"members_pagination,omitempty"`
6464}
6565
6666// archCommCount is a helper struct for counting community nodes in architecture overview.
@@ -92,9 +92,9 @@ type architectureOverviewCoupling struct {
9292// @intent preserve the legacy architecture overview response shape with typed fields.
9393type architectureOverviewResponse struct {
9494 Communities []architectureOverviewCommunity `json:"communities"`
95- CommunitiesPagination map [ string ] any `json:"communities_pagination"`
95+ CommunitiesPagination paging. Page `json:"communities_pagination"`
9696 Coupling []architectureOverviewCoupling `json:"coupling"`
97- CouplingPagination map [ string ] any `json:"coupling_pagination"`
97+ CouplingPagination paging. Page `json:"coupling_pagination"`
9898 Warnings []string `json:"warnings"`
9999 DerivedState map [string ]any `json:"derived_state"`
100100}
@@ -182,7 +182,7 @@ func (h *handlers) listFlows(ctx context.Context, request mcp.CallToolRequest) (
182182 result , err := marshalJSON (listFlowsResponse {
183183 Flows : infos ,
184184 DerivedState : derivedStateFlows (),
185- Pagination : buildPaginationMetadata ( limit , offset , len (infos ), hasMore ),
185+ Pagination : paging . BuildPage (paging. Request { Limit : limit , Offset : offset } , len (infos ), hasMore ),
186186 })
187187 if err != nil {
188188 return "" , trace .Wrap (err , "marshal result" )
@@ -255,7 +255,7 @@ func (h *handlers) listCommunities(ctx context.Context, request mcp.CallToolRequ
255255 result , err := marshalJSON (listCommunitiesResponse {
256256 Communities : infos ,
257257 DerivedState : derivedStateCommunities (),
258- Pagination : buildPaginationMetadata ( limit , offset , len (infos ), hasMore ),
258+ Pagination : paging . BuildPage (paging. Request { Limit : limit , Offset : offset } , len (infos ), hasMore ),
259259 })
260260 if err != nil {
261261 return "" , trace .Wrap (err , "marshal result" )
@@ -350,7 +350,8 @@ func (h *handlers) getCommunity(ctx context.Context, request mcp.CallToolRequest
350350 members [i ] = nodeToSummary (n )
351351 }
352352 gcData .Members = members
353- gcData .MembersPagination = buildPaginationMetadata (memberLimit , memberOffset , len (members ), hasMore )
353+ page := paging .BuildPage (paging.Request {Limit : memberLimit , Offset : memberOffset }, len (members ), hasMore )
354+ gcData .MembersPagination = & page
354355 }
355356
356357 result , err := marshalJSON (gcData )
@@ -443,9 +444,9 @@ func (h *handlers) getArchitectureOverview(ctx context.Context, request mcp.Call
443444
444445 result , err := marshalJSON (architectureOverviewResponse {
445446 Communities : commInfos ,
446- CommunitiesPagination : buildPaginationMetadata ( communityLimit , communityOffset , len (commInfos ), communityHasMore ),
447+ CommunitiesPagination : paging . BuildPage (paging. Request { Limit : communityLimit , Offset : communityOffset } , len (commInfos ), communityHasMore ),
447448 Coupling : couplingPairs ,
448- CouplingPagination : buildPaginationMetadata ( couplingLimit , couplingOffset , len (couplingPairs ), couplingHasMore ),
449+ CouplingPagination : paging . BuildPage (paging. Request { Limit : couplingLimit , Offset : couplingOffset } , len (couplingPairs ), couplingHasMore ),
449450 Warnings : warnings ,
450451 DerivedState : derivedStateSummary (),
451452 })
0 commit comments