Skip to content

Commit aa62d0f

Browse files
Stop requesting all deploys for a service (#6)
GitOrigin-RevId: fd75437
1 parent aa6d2b3 commit aa62d0f

4 files changed

Lines changed: 40 additions & 21 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,8 +283,8 @@ feedback or would like to report a bug or feature request, please create a GitHu
283283
- Verify Render.com API status
284284

285285
2. **Authorization Errors**
286-
- Ensure your API key has the necessary permissions
287286
- Check if your API key has expired
287+
- Ensure your API key is still valid and has not been revoked
288288

289289
3. **Service Creation Failures**
290290
- Verify repository URLs are accessible

pkg/deploy/repo.go

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -16,21 +16,8 @@ func NewRepo(c *client.ClientWithResponses) *Repo {
1616
}
1717
}
1818

19-
type ListDeploysParams struct {
20-
*client.ListDeploysParams
21-
serviceId string
22-
}
23-
24-
func (r *Repo) ListDeploys(ctx context.Context, serviceId string, params *client.ListDeploysParams) ([]*client.Deploy, error) {
25-
listDeploysParams := &ListDeploysParams{
26-
ListDeploysParams: params,
27-
serviceId: serviceId,
28-
}
29-
return client.ListAll(ctx, listDeploysParams, r.listDeploysPage)
30-
}
31-
32-
func (r *Repo) listDeploysPage(ctx context.Context, params *ListDeploysParams) ([]*client.Deploy, *client.Cursor, error) {
33-
resp, err := r.client.ListDeploysWithResponse(ctx, params.serviceId, params.ListDeploysParams)
19+
func (r *Repo) ListDeploys(ctx context.Context, serviceId string, params *client.ListDeploysParams) ([]*client.Deploy, *client.Cursor, error) {
20+
resp, err := r.client.ListDeploysWithResponse(ctx, serviceId, params)
3421
if err != nil {
3522
return nil, nil, err
3623
}

pkg/deploy/tools.go

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
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
}

pkg/logs/tools.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,6 @@ func listLogLabelValues(logRepo *LogRepo) server.ServerTool {
233233
Tool: mcp.NewTool("list_log_label_values",
234234
mcp.WithDescription("List all values for a given log label in the logs matching the provided filters. "+
235235
"This can be used to discover what values are available for filtering logs using the list_logs tool. "+
236-
"Logs are paginated by start and end timestamps. "+
237-
"There are more logs to fetch if hasMore is true in the response. "+
238-
"Provide the nextStartTime and nextEndTime timestamps as the startTime and endTime query parameters to fetch the next page of logs. "+
239236
"You can query for logs across multiple resources, but all resources must be in the same region and belong to the same owner.",
240237
),
241238
mcp.WithToolAnnotation(mcp.ToolAnnotation{

0 commit comments

Comments
 (0)