From e851f542f50f08c8a3196dfc705f0a54a026ed32 Mon Sep 17 00:00:00 2001 From: runixer Date: Thu, 1 Jan 2026 14:29:06 +0000 Subject: [PATCH] fix(actions): change workflow_id parameter type from number to string (#114) The Gitea API expects workflow_id as a string (filename like 'my-workflow.yml' or numeric ID as string), not as a number. This was causing 404 errors when trying to get or dispatch workflows. Affected tools: - get_repo_action_workflow - dispatch_repo_action_workflow Co-authored-by: runixer Co-authored-by: hiifong Reviewed-on: https://gitea.com/gitea/gitea-mcp/pulls/114 Reviewed-by: Lunny Xiao Co-authored-by: runixer Co-committed-by: runixer --- operation/actions/runs.go | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/operation/actions/runs.go b/operation/actions/runs.go index a1d9ab6..3a397c8 100644 --- a/operation/actions/runs.go +++ b/operation/actions/runs.go @@ -43,7 +43,7 @@ var ( mcp.WithDescription("Get a repository Actions workflow by ID"), mcp.WithString("owner", mcp.Required(), mcp.Description("repository owner")), mcp.WithString("repo", mcp.Required(), mcp.Description("repository name")), - mcp.WithNumber("workflow_id", mcp.Required(), mcp.Description("workflow ID")), + mcp.WithString("workflow_id", mcp.Required(), mcp.Description("workflow ID or filename (e.g. 'my-workflow.yml')")), ) DispatchRepoActionWorkflowTool = mcp.NewTool( @@ -51,7 +51,7 @@ var ( mcp.WithDescription("Trigger (dispatch) a repository Actions workflow"), mcp.WithString("owner", mcp.Required(), mcp.Description("repository owner")), mcp.WithString("repo", mcp.Required(), mcp.Description("repository name")), - mcp.WithNumber("workflow_id", mcp.Required(), mcp.Description("workflow ID")), + mcp.WithString("workflow_id", mcp.Required(), mcp.Description("workflow ID or filename (e.g. 'my-workflow.yml')")), mcp.WithString("ref", mcp.Required(), mcp.Description("git ref (branch or tag)")), mcp.WithObject("inputs", mcp.Description("workflow inputs object")), ) @@ -187,15 +187,15 @@ func GetRepoActionWorkflowFn(ctx context.Context, req mcp.CallToolRequest) (*mcp if !ok || repo == "" { return to.ErrorResult(fmt.Errorf("repo is required")) } - workflowID, ok := req.GetArguments()["workflow_id"].(float64) - if !ok || workflowID <= 0 { + workflowID, ok := req.GetArguments()["workflow_id"].(string) + if !ok || workflowID == "" { return to.ErrorResult(fmt.Errorf("workflow_id is required")) } var result any _, _, err := doJSONWithFallback(ctx, "GET", []string{ - fmt.Sprintf("repos/%s/%s/actions/workflows/%d", url.PathEscape(owner), url.PathEscape(repo), int64(workflowID)), + fmt.Sprintf("repos/%s/%s/actions/workflows/%s", url.PathEscape(owner), url.PathEscape(repo), url.PathEscape(workflowID)), }, nil, nil, &result, ) @@ -215,8 +215,8 @@ func DispatchRepoActionWorkflowFn(ctx context.Context, req mcp.CallToolRequest) if !ok || repo == "" { return to.ErrorResult(fmt.Errorf("repo is required")) } - workflowID, ok := req.GetArguments()["workflow_id"].(float64) - if !ok || workflowID <= 0 { + workflowID, ok := req.GetArguments()["workflow_id"].(string) + if !ok || workflowID == "" { return to.ErrorResult(fmt.Errorf("workflow_id is required")) } ref, ok := req.GetArguments()["ref"].(string) @@ -245,8 +245,8 @@ func DispatchRepoActionWorkflowFn(ctx context.Context, req mcp.CallToolRequest) _, _, err := doJSONWithFallback(ctx, "POST", []string{ - fmt.Sprintf("repos/%s/%s/actions/workflows/%d/dispatches", url.PathEscape(owner), url.PathEscape(repo), int64(workflowID)), - fmt.Sprintf("repos/%s/%s/actions/workflows/%d/dispatch", url.PathEscape(owner), url.PathEscape(repo), int64(workflowID)), + fmt.Sprintf("repos/%s/%s/actions/workflows/%s/dispatches", url.PathEscape(owner), url.PathEscape(repo), url.PathEscape(workflowID)), + fmt.Sprintf("repos/%s/%s/actions/workflows/%s/dispatch", url.PathEscape(owner), url.PathEscape(repo), url.PathEscape(workflowID)), }, nil, body, nil, )