77 "github.com/mark3labs/mcp-go/mcp"
88 "github.com/mark3labs/mcp-go/server"
99 "github.com/render-oss/render-mcp-server/pkg/client"
10+ "github.com/render-oss/render-mcp-server/pkg/pointers"
1011 "github.com/render-oss/render-mcp-server/pkg/validate"
1112)
1213
@@ -33,14 +34,41 @@ func listDeploys(deployRepo *Repo) server.ServerTool {
3334 mcp .Required (),
3435 mcp .Description ("The ID of the service to get deployments for" ),
3536 ),
37+ mcp .WithNumber ("limit" ,
38+ mcp .Description ("The maximum number of deploys to return in a single page. To fetch " +
39+ "additional pages of results, set the cursor to the last deploy in the previous page. " +
40+ "It should be rare to need to set this value greater than 20." ),
41+ mcp .DefaultNumber (10 ),
42+ mcp .Min (1 ),
43+ mcp .Max (100 ),
44+ ),
45+ mcp .WithString ("cursor" ,
46+ mcp .Description ("A unique string that corresponds to a position in the result list. " +
47+ "If provided, the endpoint returns results that appear after the corresponding position. " +
48+ "To fetch the first page of results, set to the empty string." ),
49+ mcp .DefaultString ("" ),
50+ ),
3651 ),
3752 Handler : func (ctx context.Context , request mcp.CallToolRequest ) (* mcp.CallToolResult , error ) {
3853 serviceId , err := validate .RequiredToolParam [string ](request , "serviceId" )
3954 if err != nil {
4055 return mcp .NewToolResultError (err .Error ()), nil
4156 }
4257
43- deploys , err := deployRepo .ListDeploys (ctx , serviceId , & client.ListDeploysParams {})
58+ params := & client.ListDeploysParams {}
59+ if limit , ok , err := validate .OptionalToolParam [float64 ](request , "limit" ); err != nil {
60+ return mcp .NewToolResultError (err .Error ()), nil
61+ } else if ok {
62+ params .Limit = pointers .From (int (limit ))
63+ }
64+
65+ if cursor , ok , err := validate .OptionalToolParam [string ](request , "cursor" ); err != nil {
66+ return mcp .NewToolResultError (err .Error ()), nil
67+ } else if ok {
68+ params .Cursor = & cursor
69+ }
70+
71+ deploys , cursor , err := deployRepo .ListDeploys (ctx , serviceId , params )
4472 if err != nil {
4573 return mcp .NewToolResultError (err .Error ()), nil
4674 }
@@ -49,8 +77,15 @@ func listDeploys(deployRepo *Repo) server.ServerTool {
4977 if err != nil {
5078 return mcp .NewToolResultError (err .Error ()), nil
5179 }
80+ respText := string (respJSON ) + "\n \n cursor: "
5281
53- return mcp .NewToolResultText (string (respJSON )), nil
82+ if cursor == nil {
83+ respText += `""`
84+ } else {
85+ respText += * cursor
86+ }
87+
88+ return mcp .NewToolResultText (respText ), nil
5489 },
5590 }
5691}
0 commit comments