Skip to content

Conversation

@SamMorrowDrums
Copy link
Collaborator

Summary

Part of a stacked PR series to migrate all tool files to the new NewTool helper pattern. This PR migrates issues.go (8 tool functions).

Changes

Converted Functions

All 8 tool functions in issues.go now use the NewTool helper:

Function Dependencies Used
IssueRead GetClient, GetGQLClient, RepoAccessCache, Flags
ListIssueTypes GetClient
AddIssueComment GetClient
SubIssueWrite GetClient
SearchIssues GetClient
IssueWrite GetClient, GetGQLClient
ListIssues GetGQLClient
AssignCopilotToIssue GetGQLClient

Pattern Changes

Before:

func IssueRead(getClient GetClientFn, getGQLClient GetGQLClientFn, cache *lockdown.RepoAccessCache, t translations.TranslationHelperFunc, flags FeatureFlags) (mcp.Tool, mcp.ToolHandlerFor[map[string]any, any]) {
    return mcp.Tool{...},
        func(ctx context.Context, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
            client, err := getClient(ctx)
            // ...
        }
}

After:

func IssueRead(t translations.TranslationHelperFunc) toolsets.ServerTool {
    return NewTool(
        mcp.Tool{...},
        func(deps ToolDependencies) mcp.ToolHandlerFor[map[string]any, any] {
            return func(ctx context.Context, _ *mcp.CallToolRequest, args map[string]any) (*mcp.CallToolResult, any, error) {
                client, err := deps.GetClient(ctx)
                // ...
            }
        })
}

Files Modified

  • pkg/github/issues.go - Converted all 8 tool functions
  • pkg/github/tools.go - Removed NewServerToolLegacy wrappers for issue tools
  • pkg/github/issues_test.go - Updated all tests to use new ToolDependencies pattern

PR Stack

  1. refactor: Separate ServerTool with HandlerFunc pattern and ToolDependencies #1589 - Foundation + search.go
  2. Migrate context_tools to new ServerTool pattern #1590 - context_tools.go
  3. refactor(gists): migrate gists.go to NewTool pattern #1591 - gists.go
  4. refactor(notifications): migrate notifications.go to NewTool pattern #1592 - notifications.go
  5. Refactor repositories.go tools to use NewTool pattern with ToolDependencies #1593 - repositories.go
  6. 📍 This PR - issues.go
  7. 🔜 pullrequests.go (next)

Testing

  • script/lint passes
  • script/test passes
  • All issue-related tests updated and passing

Co-authors

Co-authored-by: Adam Holt oholt@github.com

…encies

Convert all 18 tool functions in repositories.go to use the new NewTool helper
pattern with typed ToolDependencies, isolating type assertions to a single
location and improving code maintainability.

Functions converted:
- GetCommit, ListCommits, ListBranches
- CreateOrUpdateFile, CreateRepository, GetFileContents
- ForkRepository, DeleteFile, CreateBranch, PushFiles
- ListTags, GetTag, ListReleases, GetLatestRelease, GetReleaseByTag
- ListStarredRepositories, StarRepository, UnstarRepository

This is part of a stacked PR series to systematically migrate all tool
files to the new pattern.

Co-authored-by: Adam Holt <oholt@github.com>
Copilot AI review requested due to automatic review settings December 13, 2025 13:50
@SamMorrowDrums SamMorrowDrums requested a review from a team as a code owner December 13, 2025 13:50
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 migrates all 8 tool functions in issues.go to the new NewTool helper pattern, completing another step in the stacked PR series to modernize tool creation across the codebase. The refactor replaces explicit dependency injection parameters with a centralized ToolDependencies struct, improving consistency and maintainability.

Key changes:

  • Converted 8 issue-related tool functions to use NewTool helper with ToolDependencies
  • Updated function signatures to accept only TranslationHelperFunc parameter
  • Modified all corresponding tests to use the new handler invocation pattern

Reviewed changes

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

File Description
pkg/github/issues.go Migrated all 8 tool functions (IssueRead, ListIssueTypes, AddIssueComment, SubIssueWrite, SearchIssues, IssueWrite, ListIssues, AssignCopilotToIssue) to use NewTool pattern with ToolDependencies struct for dependency access
pkg/github/tools.go Removed NewServerToolLegacy wrappers for all 8 issue tools, now passing them directly to toolset registration
pkg/github/issues_test.go Updated all test cases to construct ToolDependencies structs and call handlers using the new serverTool.Handler(deps) pattern instead of the old three-return-value handler signature

Convert all 8 tool functions in issues.go to use the new NewTool
helper pattern which standardizes dependency injection:

- IssueRead: GetClient, GetGQLClient, RepoAccessCache, Flags
- ListIssueTypes: GetClient
- AddIssueComment: GetClient
- SubIssueWrite: GetClient
- SearchIssues: GetClient
- IssueWrite: GetClient, GetGQLClient
- ListIssues: GetGQLClient
- AssignCopilotToIssue: GetGQLClient

Updated tools.go to use direct function calls instead of
NewServerToolLegacy wrappers. Updated all tests in issues_test.go
to use the new ToolDependencies pattern and Handler() method.

Co-authored-by: Adam Holt <omgitsads@users.noreply.github.com>
@SamMorrowDrums SamMorrowDrums force-pushed the SamMorrowDrums/server-tool-refactor-issues branch from 53ea837 to 1168315 Compare December 13, 2025 14:17
@SamMorrowDrums SamMorrowDrums force-pushed the SamMorrowDrums/server-tool-refactor-repositories branch from 12ea669 to 37237a3 Compare December 13, 2025 14:17
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