mirror of
https://gitea.com/gitea/gitea-mcp.git
synced 2026-02-27 17:15:13 +00:00
feat: accept string values for all numeric input parameters (#138)
## Summary - MCP clients may send numbers as strings. This adds `ToInt64` and `GetOptionalInt` helpers to `pkg/params` and replaces all raw `.(float64)` type assertions across operation handlers to accept both `float64` and string inputs. ## Test plan - [x] Verify `go test ./...` passes - [x] Test with an MCP client that sends numeric parameters as strings *Created by Claude on behalf of @silverwind* Reviewed-on: https://gitea.com/gitea/gitea-mcp/pulls/138 Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: silverwind <me@silverwind.io> Co-committed-by: silverwind <me@silverwind.io>
This commit is contained in:
@@ -9,6 +9,7 @@ import (
|
||||
|
||||
"gitea.com/gitea/gitea-mcp/pkg/gitea"
|
||||
"gitea.com/gitea/gitea-mcp/pkg/log"
|
||||
"gitea.com/gitea/gitea-mcp/pkg/params"
|
||||
"gitea.com/gitea/gitea-mcp/pkg/to"
|
||||
|
||||
gitea_sdk "code.gitea.io/sdk/gitea"
|
||||
@@ -139,14 +140,8 @@ func ListRepoActionVariablesFn(ctx context.Context, req mcp.CallToolRequest) (*m
|
||||
if !ok || repo == "" {
|
||||
return to.ErrorResult(errors.New("repo is required"))
|
||||
}
|
||||
page, _ := req.GetArguments()["page"].(float64)
|
||||
if page <= 0 {
|
||||
page = 1
|
||||
}
|
||||
pageSize, _ := req.GetArguments()["pageSize"].(float64)
|
||||
if pageSize <= 0 {
|
||||
pageSize = 100
|
||||
}
|
||||
page := params.GetOptionalInt(req.GetArguments(), "page", 1)
|
||||
pageSize := params.GetOptionalInt(req.GetArguments(), "pageSize", 100)
|
||||
|
||||
query := url.Values{}
|
||||
query.Set("page", strconv.Itoa(int(page)))
|
||||
@@ -278,14 +273,8 @@ func ListOrgActionVariablesFn(ctx context.Context, req mcp.CallToolRequest) (*mc
|
||||
if !ok || org == "" {
|
||||
return to.ErrorResult(errors.New("org is required"))
|
||||
}
|
||||
page, _ := req.GetArguments()["page"].(float64)
|
||||
if page <= 0 {
|
||||
page = 1
|
||||
}
|
||||
pageSize, _ := req.GetArguments()["pageSize"].(float64)
|
||||
if pageSize <= 0 {
|
||||
pageSize = 100
|
||||
}
|
||||
page := params.GetOptionalInt(req.GetArguments(), "page", 1)
|
||||
pageSize := params.GetOptionalInt(req.GetArguments(), "pageSize", 100)
|
||||
|
||||
client, err := gitea.ClientFromContext(ctx)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user