Skip to content

Commit 72fb1d5

Browse files
committed
lint and bug fixes for actions get logs tools
1 parent d8e9492 commit 72fb1d5

File tree

3 files changed

+19
-27
lines changed

3 files changed

+19
-27
lines changed

README.md

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -431,13 +431,18 @@ The following sets of tools are available:
431431

432432
- **actions_get** - Get details of GitHub Actions resources (workflows, workflow runs, jobs, and artifacts)
433433
- `action`: The action to perform (string, required)
434+
- `failed_only`: When true, gets logs for all failed jobs in the workflow run specified by resource_id (only for 'get_job_logs' action) (boolean, optional)
435+
- `job_id`: The unique identifier of the workflow job (required for single job logs when action is 'get_job_logs') (number, optional)
434436
- `owner`: Repository owner (string, required)
435437
- `repo`: Repository name (string, required)
436438
- `resource_id`: The unique identifier of the resource. This will vary based on the "action" provided, so ensure you provide the correct ID:
437439
- Provide a workflow ID or workflow file name (e.g. ci.yaml) for 'get_workflow' action.
438-
- Provide a workflow run ID for 'get_workflow_run', 'download_workflow_run_artifact' and 'get_workflow_run_usage' actions.
440+
- Provide a workflow run ID for 'get_workflow_run', 'download_workflow_run_artifact', 'get_workflow_run_usage', and 'get_workflow_run_logs' actions.
439441
- Provide a job ID for the 'get_workflow_job' action.
440-
(string, required)
442+
- Provide a workflow run ID for 'get_job_logs' action when using failed_only parameter.
443+
(string, optional)
444+
- `return_content`: Returns actual log content instead of URLs (only for 'get_job_logs' action) (boolean, optional)
445+
- `tail_lines`: Number of lines to return from the end of the log (only for 'get_job_logs' action) (number, optional)
441446

442447
- **actions_list** - List GitHub Actions workflows in a repository
443448
- `action`: The action to perform (string, required)
@@ -464,20 +469,6 @@ The following sets of tools are available:
464469
- `repo`: Repository name (string, required)
465470
- `run_id`: The unique identifier of the workflow run (number, required)
466471

467-
- **get_job_logs** - Get job logs
468-
- `failed_only`: When true, gets logs for all failed jobs in run_id (boolean, optional)
469-
- `job_id`: The unique identifier of the workflow job (required for single job logs) (number, optional)
470-
- `owner`: Repository owner (string, required)
471-
- `repo`: Repository name (string, required)
472-
- `return_content`: Returns actual log content instead of URLs (boolean, optional)
473-
- `run_id`: Workflow run ID (required when using failed_only) (number, optional)
474-
- `tail_lines`: Number of lines to return from the end of the log (number, optional)
475-
476-
- **get_workflow_run_logs** - Get workflow run logs
477-
- `owner`: Repository owner (string, required)
478-
- `repo`: Repository name (string, required)
479-
- `run_id`: The unique identifier of the workflow run (number, required)
480-
481472
- **run_workflow** - Run workflow
482473
- `inputs`: Inputs the workflow accepts (object, optional)
483474
- `owner`: Repository owner (string, required)

pkg/github/actions.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ func actionFromString(s string) actionsActionType {
7878
return actionsActionTypeUnknown
7979
}
8080

81-
func ActionsList(getClient GetClientFn, t translations.TranslationHelperFunc, contentWindowSize int) (tool mcp.Tool, handler server.ToolHandlerFunc) {
81+
func ActionsList(getClient GetClientFn, t translations.TranslationHelperFunc, _ int) (tool mcp.Tool, handler server.ToolHandlerFunc) {
8282
return mcp.NewTool("actions_list",
8383
mcp.WithDescription(t("TOOL_ACTIONS_LIST_DESCRIPTION", `Tools for listing GitHub Actions resources.
8484
Use this tool to list workflows in a repository, or list workflow runs, jobs, and artifacts for a specific workflow or workflow run.
@@ -289,8 +289,8 @@ Use this tool to get details about individual workflows, workflow runs, jobs, an
289289
- Provide a workflow run ID for 'get_job_logs' action when using failed_only parameter.
290290
`),
291291
),
292-
mcp.WithBoolean("job_id",
293-
mcp.Description("The ID of the job to get logs for (only for 'get_job_logs' action)"),
292+
mcp.WithNumber("job_id",
293+
mcp.Description("The unique identifier of the workflow job (required for single job logs when action is 'get_job_logs')"),
294294
),
295295
mcp.WithBoolean("failed_only",
296296
mcp.Description("When true, gets logs for all failed jobs in the workflow run specified by resource_id (only for 'get_job_logs' action)"),
@@ -336,7 +336,7 @@ Use this tool to get details about individual workflows, workflow runs, jobs, an
336336
}
337337

338338
// Get optional parameters for get_job_logs
339-
jobID, err := OptionalParam[int64](request, "job_id")
339+
jobID, err := OptionalIntParam(request, "job_id")
340340
if err != nil {
341341
return mcp.NewToolResultError(err.Error()), nil
342342
}
@@ -351,7 +351,7 @@ Use this tool to get details about individual workflows, workflow runs, jobs, an
351351
return mcp.NewToolResultError(err.Error()), nil
352352
}
353353

354-
tailLines, err := OptionalParam[int](request, "tail_lines")
354+
tailLines, err := OptionalIntParam(request, "tail_lines")
355355
if err != nil {
356356
return mcp.NewToolResultError(err.Error()), nil
357357
}
@@ -394,7 +394,7 @@ Use this tool to get details about individual workflows, workflow runs, jobs, an
394394
case actionsActionTypeGetWorkflowRunLogs:
395395
return getWorkflowRunLogs(ctx, client, request, owner, repo, resourceIDInt)
396396
case actionsActionTypeGetWorkflowJobLogs:
397-
return getWorkflowJobLogs(ctx, client, request, owner, repo, resourceIDInt, jobID, returnContent, failedOnly, tailLines, contentWindowSize)
397+
return getWorkflowJobLogs(ctx, client, request, owner, repo, resourceIDInt, int64(jobID), returnContent, failedOnly, tailLines, contentWindowSize)
398398
case actionsActionTypeUnknown:
399399
return mcp.NewToolResultError(fmt.Sprintf("unknown action: %s", actionTypeStr)), nil
400400
default:
@@ -810,7 +810,7 @@ func getWorkflowRunLogs(ctx context.Context, client *github.Client, _ mcp.CallTo
810810
}
811811

812812
// getWorkflowJobLogs downloads logs for a specific workflow job or efficiently gets all failed job logs for a workflow run
813-
func getWorkflowJobLogs(ctx context.Context, client *github.Client, request mcp.CallToolRequest, owner, repo string, runID int64, jobID int64, returnContent bool, failedOnly bool, tailLines int, contentWindowSize int) (*mcp.CallToolResult, error) {
813+
func getWorkflowJobLogs(ctx context.Context, client *github.Client, _ mcp.CallToolRequest, owner, repo string, runID int64, jobID int64, returnContent bool, failedOnly bool, tailLines int, contentWindowSize int) (*mcp.CallToolResult, error) {
814814
// Default to 500 lines if not specified
815815
if tailLines == 0 {
816816
tailLines = 500

pkg/github/actions_test.go

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -783,12 +783,14 @@ func Test_GetJobLogs(t *testing.T) {
783783

784784
assert.Equal(t, "actions_get", tool.Name)
785785
assert.NotEmpty(t, tool.Description)
786+
assert.Contains(t, tool.InputSchema.Properties, "action")
786787
assert.Contains(t, tool.InputSchema.Properties, "owner")
787788
assert.Contains(t, tool.InputSchema.Properties, "repo")
789+
assert.Contains(t, tool.InputSchema.Properties, "resource_id")
788790
assert.Contains(t, tool.InputSchema.Properties, "job_id")
789-
assert.Contains(t, tool.InputSchema.Properties, "run_id")
790791
assert.Contains(t, tool.InputSchema.Properties, "failed_only")
791792
assert.Contains(t, tool.InputSchema.Properties, "return_content")
793+
assert.Contains(t, tool.InputSchema.Properties, "tail_lines")
792794
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"action", "owner", "repo"})
793795

794796
tests := []struct {
@@ -1307,7 +1309,7 @@ func Test_ActionsGet(t *testing.T) {
13071309
assert.Contains(t, tool.InputSchema.Properties, "owner")
13081310
assert.Contains(t, tool.InputSchema.Properties, "repo")
13091311
assert.Contains(t, tool.InputSchema.Properties, "resource_id")
1310-
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"action", "owner", "repo", "resource_id"})
1312+
assert.ElementsMatch(t, tool.InputSchema.Required, []string{"action", "owner", "repo"})
13111313

13121314
tests := []struct {
13131315
name string
@@ -1320,7 +1322,6 @@ func Test_ActionsGet(t *testing.T) {
13201322
name: "missing required parameter action",
13211323
mockedClient: mock.NewMockedHTTPClient(),
13221324
requestArgs: map[string]any{
1323-
"action": actionsActionTypeGetWorkflowJobLogs.String(),
13241325
"owner": "owner",
13251326
"repo": "repo",
13261327
"resource_id": "123",
@@ -2112,7 +2113,7 @@ func Test_ActionsResourceRead_GetWorkflowUsage(t *testing.T) {
21122113
TotalMS: github.Ptr(int64(60000)),
21132114
Jobs: github.Ptr(1),
21142115
JobRuns: []*github.WorkflowRunJobRun{
2115-
&github.WorkflowRunJobRun{
2116+
{
21162117
JobID: github.Ptr(1),
21172118
DurationMS: github.Ptr(int64(600)),
21182119
},

0 commit comments

Comments
 (0)