@@ -188,7 +188,7 @@ func ActionsRead(getClient GetClientFn, t translations.TranslationHelperFunc) (t
188188 return mcp .NewToolResultError (fmt .Sprintf ("unknown action: %s" , actionTypeStr )), nil
189189 }
190190
191- resourceIDInt , err := RequiredInt (request , "resource_id" )
191+ resourceID , err := RequiredParam [ string ] (request , "resource_id" )
192192 if err != nil {
193193 return mcp .NewToolResultError (err .Error ()), nil
194194 }
@@ -203,23 +203,36 @@ func ActionsRead(getClient GetClientFn, t translations.TranslationHelperFunc) (t
203203 return nil , fmt .Errorf ("failed to get GitHub client: %w" , err )
204204 }
205205
206+ var resourceIDInt int64
207+ var parseErr error
208+ switch resourceType {
209+ case actionsActionTypeGetWorkflow , actionsActionTypeListWorkflowRuns :
210+ // Do nothing, we accept both a string workflow ID or filename
211+ default :
212+ // For other actions, resource ID must be an integer
213+ resourceIDInt , parseErr = strconv .ParseInt (resourceID , 10 , 64 )
214+ if parseErr != nil {
215+ return mcp .NewToolResultError (fmt .Sprintf ("invalid resource_id, must be an integer for action %s: %v" , actionTypeStr , parseErr )), nil
216+ }
217+ }
218+
206219 switch resourceType {
207220 case actionsActionTypeGetWorkflow :
208- return getWorkflow (ctx , client , request , owner , repo , int64 ( resourceIDInt ) )
221+ return getWorkflow (ctx , client , request , owner , repo , resourceID )
209222 case actionsActionTypeGetWorkflowRun :
210- return getWorkflowRun (ctx , client , request , owner , repo , int64 ( resourceIDInt ) )
223+ return getWorkflowRun (ctx , client , request , owner , repo , resourceIDInt )
211224 case actionsActionTypeListWorkflowRuns :
212- return listWorkflowRuns (ctx , client , request , owner , repo , int64 ( resourceIDInt ) , pagination )
225+ return listWorkflowRuns (ctx , client , request , owner , repo , resourceID , pagination )
213226 case actionsActionTypeGetWorkflowJob :
214- return getWorkflowJob (ctx , client , request , owner , repo , int64 ( resourceIDInt ) )
227+ return getWorkflowJob (ctx , client , request , owner , repo , resourceIDInt )
215228 case actionsActionTypeListWorkflowJobs :
216- return listWorkflowJobs (ctx , client , request , owner , repo , int64 ( resourceIDInt ) , pagination )
229+ return listWorkflowJobs (ctx , client , request , owner , repo , resourceIDInt , pagination )
217230 case actionsActionTypeDownloadWorkflowArtifact :
218- return downloadWorkflowArtifact (ctx , client , request , owner , repo , int64 ( resourceIDInt ) )
231+ return downloadWorkflowArtifact (ctx , client , request , owner , repo , resourceIDInt )
219232 case actionsActionTypeListWorkflowArtifacts :
220- return listWorkflowArtifacts (ctx , client , request , owner , repo , int64 ( resourceIDInt ) , pagination )
233+ return listWorkflowArtifacts (ctx , client , request , owner , repo , resourceIDInt , pagination )
221234 case actionsActionTypeGetWorkflowRunUsage :
222- return getWorkflowRunUsage (ctx , client , request , owner , repo , int64 ( resourceIDInt ) )
235+ return getWorkflowRunUsage (ctx , client , request , owner , repo , resourceIDInt )
223236 case actionsActionTypeUnknown :
224237 return mcp .NewToolResultError (fmt .Sprintf ("unknown action: %s" , actionTypeStr )), nil
225238 default :
@@ -229,8 +242,17 @@ func ActionsRead(getClient GetClientFn, t translations.TranslationHelperFunc) (t
229242 }
230243}
231244
232- func getWorkflow (ctx context.Context , client * github.Client , _ mcp.CallToolRequest , owner , repo string , resourceID int64 ) (* mcp.CallToolResult , error ) {
233- workflow , resp , err := client .Actions .GetWorkflowByID (ctx , owner , repo , resourceID )
245+ func getWorkflow (ctx context.Context , client * github.Client , _ mcp.CallToolRequest , owner , repo string , resourceID string ) (* mcp.CallToolResult , error ) {
246+ var workflow * github.Workflow
247+ var resp * github.Response
248+ var err error
249+
250+ if workflowIDInt , parseErr := strconv .ParseInt (resourceID , 10 , 64 ); parseErr == nil {
251+ workflow , resp , err = client .Actions .GetWorkflowByID (ctx , owner , repo , workflowIDInt )
252+ } else {
253+ workflow , resp , err = client .Actions .GetWorkflowByFileName (ctx , owner , repo , resourceID )
254+ }
255+
234256 if err != nil {
235257 return ghErrors .NewGitHubAPIErrorResponse (ctx , "failed to get workflow" , resp , err ), nil
236258 }
@@ -257,7 +279,7 @@ func getWorkflowRun(ctx context.Context, client *github.Client, _ mcp.CallToolRe
257279 return mcp .NewToolResultText (string (r )), nil
258280}
259281
260- func listWorkflowRuns (ctx context.Context , client * github.Client , request mcp.CallToolRequest , owner , repo string , resourceID int64 , pagination PaginationParams ) (* mcp.CallToolResult , error ) {
282+ func listWorkflowRuns (ctx context.Context , client * github.Client , request mcp.CallToolRequest , owner , repo string , resourceID string , pagination PaginationParams ) (* mcp.CallToolResult , error ) {
261283 filterArgs , err := OptionalParam [map [string ]any ](request , "workflow_runs_filter" )
262284 if err != nil {
263285 return mcp .NewToolResultError (err .Error ()), nil
@@ -272,7 +294,7 @@ func listWorkflowRuns(ctx context.Context, client *github.Client, request mcp.Ca
272294 }
273295 }
274296
275- workflowRuns , resp , err := client . Actions . ListWorkflowRunsByID ( ctx , owner , repo , resourceID , & github.ListWorkflowRunsOptions {
297+ listWorkflowRunsOptions := & github.ListWorkflowRunsOptions {
276298 Actor : filterArgsTyped ["actor" ],
277299 Branch : filterArgsTyped ["branch" ],
278300 Event : filterArgsTyped ["event" ],
@@ -281,7 +303,17 @@ func listWorkflowRuns(ctx context.Context, client *github.Client, request mcp.Ca
281303 Page : pagination .Page ,
282304 PerPage : pagination .PerPage ,
283305 },
284- })
306+ }
307+
308+ var workflowRuns * github.WorkflowRuns
309+ var resp * github.Response
310+
311+ if workflowIDInt , parseErr := strconv .ParseInt (resourceID , 10 , 64 ); parseErr == nil {
312+ workflowRuns , resp , err = client .Actions .ListWorkflowRunsByID (ctx , owner , repo , workflowIDInt , listWorkflowRunsOptions )
313+ } else {
314+ workflowRuns , resp , err = client .Actions .ListWorkflowRunsByFileName (ctx , owner , repo , resourceID , listWorkflowRunsOptions )
315+ }
316+
285317 if err != nil {
286318 return ghErrors .NewGitHubAPIErrorResponse (ctx , "failed to list workflow runs" , resp , err ), nil
287319 }
0 commit comments