Files
gitea-mcp/internal/tools/workflow_run_status.go
T
mathiasandClaude Opus 4.8 4c1f36f9eb
CD / Lint / Test / Vet (push) Successful in 7s
CD / Build & Import (push) Successful in 23s
CD / Deploy via GitOps (push) Has been skipped
chore(rename): module gitea.d-ma.be → git.d-ma.be/mathias/gitea-mcp (#39)
Gitea host renamed (infra ADR-0004); the mcp-chassis dep already migrated
(3329ff3), so the sequencing gate is clear. `go mod edit -module` + bulk import
rewrite across all .go files. gitea-mcp is a server binary (not an imported
library), so no downstream consumers break. build + task check green.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-03 22:48:26 +02:00

70 lines
1.7 KiB
Go

package tools
import (
"context"
"encoding/json"
"fmt"
"git.d-ma.be/mathias/gitea-mcp/internal/allowlist"
"git.d-ma.be/mathias/gitea-mcp/internal/gitea"
"git.d-ma.be/mathias/gitea-mcp/internal/registry"
)
// WorkflowRunStatus fetches the status of a Gitea Actions run.
type WorkflowRunStatus struct {
c *gitea.Client
a *allowlist.Allowlist
}
func NewWorkflowRunStatus(c *gitea.Client, a *allowlist.Allowlist) *WorkflowRunStatus {
return &WorkflowRunStatus{c: c, a: a}
}
func (t *WorkflowRunStatus) Descriptor() registry.ToolDescriptor {
return registry.ToolDescriptor{
Name: "workflow_run_status",
Description: "Get the status of a Gitea Actions workflow run.",
InputSchema: json.RawMessage(`{
"type":"object",
"properties":{
"owner":{"type":"string"},
"repo":{"type":"string"},
"run_id":{"type":"integer","minimum":1}
},
"required":["owner","repo","run_id"]
}`),
}
}
type workflowRunStatusArgs struct {
Owner string `json:"owner"`
Repo string `json:"repo"`
RunID int64 `json:"run_id"`
}
func (t *WorkflowRunStatus) Call(ctx context.Context, raw json.RawMessage) (json.RawMessage, error) {
var args workflowRunStatusArgs
if err := parseArgs(raw, &args); err != nil {
return nil, err
}
if err := t.a.Check(args.Owner); err != nil {
return nil, err
}
if args.RunID < 1 {
return nil, fmt.Errorf("run_id must be >= 1: %w", gitea.ErrValidation)
}
run, err := t.c.GetWorkflowRun(ctx, args.Owner, args.Repo, args.RunID)
if err != nil {
return nil, err
}
return textOK(map[string]any{
"run_id": run.ID,
"status": run.Status,
"conclusion": run.Conclusion,
"started_at": run.StartedAt,
"html_url": run.HTMLURL,
})
}