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 <runixer@yandex.ru>
Co-authored-by: hiifong <f@f.style>
Reviewed-on: https://gitea.com/gitea/gitea-mcp/pulls/114
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
Co-authored-by: runixer <runixer@noreply.gitea.com>
Co-committed-by: runixer <runixer@noreply.gitea.com>
This commit is contained in:
runixer
2026-01-01 14:29:06 +00:00
committed by hiifong
parent b8f2377f47
commit e851f542f5

View File

@@ -43,7 +43,7 @@ var (
mcp.WithDescription("Get a repository Actions workflow by ID"), mcp.WithDescription("Get a repository Actions workflow by ID"),
mcp.WithString("owner", mcp.Required(), mcp.Description("repository owner")), mcp.WithString("owner", mcp.Required(), mcp.Description("repository owner")),
mcp.WithString("repo", mcp.Required(), mcp.Description("repository name")), 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( DispatchRepoActionWorkflowTool = mcp.NewTool(
@@ -51,7 +51,7 @@ var (
mcp.WithDescription("Trigger (dispatch) a repository Actions workflow"), mcp.WithDescription("Trigger (dispatch) a repository Actions workflow"),
mcp.WithString("owner", mcp.Required(), mcp.Description("repository owner")), mcp.WithString("owner", mcp.Required(), mcp.Description("repository owner")),
mcp.WithString("repo", mcp.Required(), mcp.Description("repository name")), 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.WithString("ref", mcp.Required(), mcp.Description("git ref (branch or tag)")),
mcp.WithObject("inputs", mcp.Description("workflow inputs object")), mcp.WithObject("inputs", mcp.Description("workflow inputs object")),
) )
@@ -187,15 +187,15 @@ func GetRepoActionWorkflowFn(ctx context.Context, req mcp.CallToolRequest) (*mcp
if !ok || repo == "" { if !ok || repo == "" {
return to.ErrorResult(fmt.Errorf("repo is required")) return to.ErrorResult(fmt.Errorf("repo is required"))
} }
workflowID, ok := req.GetArguments()["workflow_id"].(float64) workflowID, ok := req.GetArguments()["workflow_id"].(string)
if !ok || workflowID <= 0 { if !ok || workflowID == "" {
return to.ErrorResult(fmt.Errorf("workflow_id is required")) return to.ErrorResult(fmt.Errorf("workflow_id is required"))
} }
var result any var result any
_, _, err := doJSONWithFallback(ctx, "GET", _, _, err := doJSONWithFallback(ctx, "GET",
[]string{ []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, nil, nil, &result,
) )
@@ -215,8 +215,8 @@ func DispatchRepoActionWorkflowFn(ctx context.Context, req mcp.CallToolRequest)
if !ok || repo == "" { if !ok || repo == "" {
return to.ErrorResult(fmt.Errorf("repo is required")) return to.ErrorResult(fmt.Errorf("repo is required"))
} }
workflowID, ok := req.GetArguments()["workflow_id"].(float64) workflowID, ok := req.GetArguments()["workflow_id"].(string)
if !ok || workflowID <= 0 { if !ok || workflowID == "" {
return to.ErrorResult(fmt.Errorf("workflow_id is required")) return to.ErrorResult(fmt.Errorf("workflow_id is required"))
} }
ref, ok := req.GetArguments()["ref"].(string) ref, ok := req.GetArguments()["ref"].(string)
@@ -245,8 +245,8 @@ func DispatchRepoActionWorkflowFn(ctx context.Context, req mcp.CallToolRequest)
_, _, err := doJSONWithFallback(ctx, "POST", _, _, err := doJSONWithFallback(ctx, "POST",
[]string{ []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/%s/dispatches", url.PathEscape(owner), url.PathEscape(repo), url.PathEscape(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/dispatch", url.PathEscape(owner), url.PathEscape(repo), url.PathEscape(workflowID)),
}, },
nil, body, nil, nil, body, nil,
) )