MCPcopy
hub / github.com/github/github-mcp-server / getWorkflow

Function getWorkflow

pkg/github/actions.go:775–797  ·  view source on GitHub ↗

Helper functions for consolidated actions tools

(ctx context.Context, client *github.Client, owner, repo, resourceID string)

Source from the content-addressed store, hash-verified

773// Helper functions for consolidated actions tools
774
775func getWorkflow(ctx context.Context, client *github.Client, owner, repo, resourceID string) (*mcp.CallToolResult, any, error) {
776 var workflow *github.Workflow
777 var resp *github.Response
778 var err error
779
780 if workflowIDInt, parseErr := strconv.ParseInt(resourceID, 10, 64); parseErr == nil {
781 workflow, resp, err = client.Actions.GetWorkflowByID(ctx, owner, repo, workflowIDInt)
782 } else {
783 workflow, resp, err = client.Actions.GetWorkflowByFileName(ctx, owner, repo, resourceID)
784 }
785
786 if err != nil {
787 return ghErrors.NewGitHubAPIErrorResponse(ctx, "failed to get workflow", resp, err), nil, nil
788 }
789
790 defer func() { _ = resp.Body.Close() }()
791 r, err := json.Marshal(workflow)
792 if err != nil {
793 return nil, nil, fmt.Errorf("failed to marshal workflow: %w", err)
794 }
795
796 return utils.NewToolResultText(string(r)), nil, nil
797}
798
799func getWorkflowRun(ctx context.Context, client *github.Client, owner, repo string, resourceID int64) (*mcp.CallToolResult, any, error) {
800 workflowRun, resp, err := client.Actions.GetWorkflowRunByID(ctx, owner, repo, resourceID)

Callers 1

ActionsGetFunction · 0.85

Calls 2

NewToolResultTextFunction · 0.92
CloseMethod · 0.80

Tested by

no test coverage detected