Skip to content

Commit c77b0ef

Browse files
committed
Add pagination for list_fme_feature_flags
1 parent 29f6fd4 commit c77b0ef

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,7 @@ Toolset Name: `fme`
303303

304304
- `list_fme_workspaces`: List all FME workspaces
305305
- `list_fme_environments`: List environments for a specific workspace
306-
- `list_fme_feature_flags`: List feature flags for a specific workspace
306+
- `list_fme_feature_flags`: List feature flags for a specific workspace (supports pagination via `offset` and `count`; default count: 20, max count: 100)
307307
- `get_fme_feature_flag_definition`: Get the definition of a specific feature flag in an environment
308308

309309
#### SEI Toolset

common/client/fme.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package client
33
import (
44
"context"
55
"fmt"
6+
"strconv"
67

78
"github.com/harness/mcp-server/common/client/dto"
89
)
@@ -39,13 +40,19 @@ func (f *FMEService) ListEnvironments(ctx context.Context, wsID string) (*dto.FM
3940
return &response, nil
4041
}
4142

42-
// ListFeatureFlags retrieves all feature flags for a specific workspace
43+
// ListFeatureFlags retrieves feature flags for a specific workspace with pagination support.
4344
// GET https://api.split.io/internal/api/v2/splits/ws/{wsId}
44-
func (f *FMEService) ListFeatureFlags(ctx context.Context, wsID string) (*dto.FMEFeatureFlagsResponse, error) {
45+
// offset specifies the number of items to skip; limit controls how many items to return (max 100).
46+
func (f *FMEService) ListFeatureFlags(ctx context.Context, wsID string, offset, limit int) (*dto.FMEFeatureFlagsResponse, error) {
4547
var response dto.FMEFeatureFlagsResponse
4648

49+
params := map[string]string{
50+
"offset": strconv.Itoa(offset),
51+
"limit": strconv.Itoa(limit),
52+
}
53+
4754
path := fmt.Sprintf("internal/api/v2/splits/ws/%s", wsID)
48-
err := f.Client.Get(ctx, path, nil, nil, &response)
55+
err := f.Client.Get(ctx, path, params, nil, &response)
4956
if err != nil {
5057
return nil, fmt.Errorf("failed to list feature flags: %w", err)
5158
}

common/pkg/tools/fme.go

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ func ListFMEEnvironmentsTool(config *config.McpServerConfig, fmeService *client.
6060
}
6161
}
6262

63+
const (
64+
fmeFeatureFlagsDefaultCount = 20
65+
fmeFeatureFlagsMaxCount = 100
66+
)
67+
6368
// ListFMEFeatureFlagsTool creates a tool for listing FME feature flags for a specific workspace
6469
func ListFMEFeatureFlagsTool(config *config.McpServerConfig, fmeService *client.FMEService) (mcp.Tool, server.ToolHandlerFunc) {
6570
return mcp.NewTool("list_fme_feature_flags",
@@ -68,14 +73,33 @@ func ListFMEFeatureFlagsTool(config *config.McpServerConfig, fmeService *client.
6873
mcp.Required(),
6974
mcp.Description("The workspace ID to list feature flags for"),
7075
),
76+
mcp.WithNumber("offset",
77+
mcp.Description("The number of feature flags to skip for pagination (default: 0)"),
78+
),
79+
mcp.WithNumber("count",
80+
mcp.Description(fmt.Sprintf("The number of feature flags to return (default: %d, max: %d)", fmeFeatureFlagsDefaultCount, fmeFeatureFlagsMaxCount)),
81+
),
7182
),
7283
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
7384
wsID, err := RequiredParam[string](request, "ws_id")
7485
if err != nil {
7586
return mcp.NewToolResultError(err.Error()), nil
7687
}
7788

78-
featureFlags, err := fmeService.ListFeatureFlags(ctx, wsID)
89+
offset, err := OptionalIntParam(request, "offset")
90+
if err != nil {
91+
return mcp.NewToolResultError(err.Error()), nil
92+
}
93+
94+
count, err := OptionalIntParamWithDefault(request, "count", fmeFeatureFlagsDefaultCount)
95+
if err != nil {
96+
return mcp.NewToolResultError(err.Error()), nil
97+
}
98+
if count > fmeFeatureFlagsMaxCount {
99+
count = fmeFeatureFlagsMaxCount
100+
}
101+
102+
featureFlags, err := fmeService.ListFeatureFlags(ctx, wsID, offset, count)
79103
if err != nil {
80104
return mcp.NewToolResultError(fmt.Sprintf("failed to list FME feature flags: %v", err)), nil
81105
}

0 commit comments

Comments
 (0)