list_tester_groups.go•1.82 kB
package releasemanagement
import (
"context"
"fmt"
"net/http"
"strconv"
"github.com/bitrise-io/bitrise-mcp/v2/internal/bitrise"
"github.com/mark3labs/mcp-go/mcp"
)
var ListTesterGroups = bitrise.Tool{
APIGroups: []string{"release-management", "read-only"},
Definition: mcp.NewTool("list_tester_groups",
mcp.WithDescription("Gives back a list of tester groups related to a specific Release Management connected app."),
mcp.WithString("connected_app_id",
mcp.Description("The uuidV4 identifier of the app the tester group is connected to. This field is mandatory."),
mcp.Required(),
),
mcp.WithNumber("items_per_page",
mcp.Description("Specifies the maximum number of tester groups to return related to a specific connected app. Default value is 10."),
mcp.DefaultNumber(10),
),
mcp.WithNumber("page",
mcp.Description("Specifies which page should be returned from the whole result set in a paginated scenario. Default value is 1."),
mcp.DefaultNumber(1),
),
),
Handler: func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
connectedAppID, err := request.RequireString("connected_app_id")
if err != nil {
return mcp.NewToolResultError(err.Error()), nil
}
params := map[string]string{}
if v := request.GetInt("items_per_page", 10); v != 10 {
params["items_per_page"] = strconv.Itoa(v)
}
if v := request.GetInt("page", 1); v != 1 {
params["page"] = strconv.Itoa(v)
}
res, err := bitrise.CallAPI(ctx, bitrise.CallAPIParams{
Method: http.MethodGet,
BaseURL: bitrise.APIRMBaseURL,
Path: fmt.Sprintf("/connected-apps/%s/tester-groups", connectedAppID),
Params: params,
})
if err != nil {
return mcp.NewToolResultErrorFromErr("call api", err), nil
}
return mcp.NewToolResultText(res), nil
},
}