Skip to content

Conversation

@SamMorrowDrums
Copy link
Collaborator

Summary

Convert all 14 tool functions in actions.go to use the NewTool pattern with ToolDependencies for dependency injection. This is part of a broader effort to standardize the tool implementation pattern across the codebase.

Changes

Tools Converted

  • ListWorkflows
  • ListWorkflowRuns
  • RunWorkflow
  • GetWorkflowRun
  • GetWorkflowRunLogs
  • ListWorkflowJobs
  • GetJobLogs
  • RerunWorkflowRun
  • RerunFailedJobs
  • CancelWorkflowRun
  • ListWorkflowRunArtifacts
  • DownloadWorkflowRunArtifact
  • DeleteWorkflowRunLogs
  • GetWorkflowRunUsage

Pattern Details

The new pattern:

  • Takes only translations.TranslationHelperFunc as parameter
  • Returns toolsets.ServerTool with Tool and Handler
  • Handler receives ToolDependencies for client access
  • Enables better testability and consistent interface

Files Modified

  • pkg/github/actions.go - Tool function implementations
  • pkg/github/actions_test.go - Updated test signatures
  • pkg/github/tools.go - Updated tool registration

Testing

  • All existing tests pass
  • Lint passes

Stack

Part of the server tool refactoring stack:

Convert all 14 tool functions in actions.go to use the NewTool pattern with
ToolDependencies for dependency injection. This is part of a broader effort
to standardize the tool implementation pattern across the codebase.

Changes:
- ListWorkflows, ListWorkflowRuns, RunWorkflow, GetWorkflowRun
- GetWorkflowRunLogs, ListWorkflowJobs, GetJobLogs
- RerunWorkflowRun, RerunFailedJobs, CancelWorkflowRun
- ListWorkflowRunArtifacts, DownloadWorkflowRunArtifact
- DeleteWorkflowRunLogs, GetWorkflowRunUsage

The new pattern:
- Takes only translations.TranslationHelperFunc as parameter
- Returns toolsets.ServerTool with Tool and Handler
- Handler receives ToolDependencies for client access
- Enables better testability and consistent interface

Co-authored-by: Adam Holt <omgitsads@users.noreply.github.com>
@SamMorrowDrums SamMorrowDrums requested a review from a team as a code owner December 13, 2025 14:37
Copilot AI review requested due to automatic review settings December 13, 2025 14:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR successfully refactors all 14 tool functions in actions.go from the legacy pattern to the NewTool pattern with ToolDependencies for dependency injection. This is part of a broader effort to standardize tool implementation across the codebase.

Key Changes:

  • Tool functions now accept only translations.TranslationHelperFunc as a parameter instead of GetClientFn and other dependencies
  • Return type changed from (mcp.Tool, mcp.ToolHandlerFor[...]) to toolsets.ServerTool
  • Dependencies (client, contentWindowSize) are now accessed via ToolDependencies struct passed to handlers
  • Test files updated to use the new pattern with toolDef.Handler(deps) instead of direct handler calls

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
pkg/github/actions.go Refactored all 14 tool functions (ListWorkflows, ListWorkflowRuns, RunWorkflow, GetWorkflowRun, GetWorkflowRunLogs, ListWorkflowJobs, GetJobLogs, RerunWorkflowRun, RerunFailedJobs, CancelWorkflowRun, ListWorkflowRunArtifacts, DownloadWorkflowRunArtifact, DeleteWorkflowRunLogs, GetWorkflowRunUsage) to use NewTool pattern with ToolDependencies
pkg/github/tools.go Updated tool registration in actions toolset to call tool functions directly without NewServerToolLegacy wrapper
pkg/github/actions_test.go Updated all test functions to use new pattern: toolDef structure, ToolDependencies struct, and simplified handler invocation

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants