Skip to content

Conversation

@SamMorrowDrums
Copy link
Collaborator

Summary

This PR continues the effort to eliminate NewServerToolLegacy wrappers by migrating discussions tools to the new NewTool pattern with ToolDependencies.

Changes

Converts all functions in discussions.go (4 functions):

  • ListDiscussions
  • GetDiscussion
  • GetDiscussionComments
  • ListDiscussionCategories

Updates the test file to use the new handler pattern.

Stack

Pattern

Functions are converted from:

func FuncName(getGQLClient GetGQLClientFn, t translations.TranslationHelperFunc) (mcp.Tool, mcp.ToolHandlerFor[...])

To:

func FuncName(t translations.TranslationHelperFunc) toolsets.ServerTool {
    return NewTool(mcp.Tool{...}, func(deps ToolDependencies) mcp.ToolHandlerFor[...] {
        // Uses deps.GetGQLClient(ctx) instead of getGQLClient(ctx)
    })
}

Co-authored-by: Adam Holt omgitsads@users.noreply.github.com

Co-authored-by: Adam Holt <omgitsads@users.noreply.github.com>
Copilot AI review requested due to automatic review settings December 13, 2025 17:40
@SamMorrowDrums SamMorrowDrums requested a review from a team as a code owner December 13, 2025 17:40
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 migrates discussion tools from NewServerToolLegacy wrappers to the modern NewTool pattern with ToolDependencies. The refactoring eliminates the need to pass getGQLClient as a function parameter, instead accessing it through the ToolDependencies struct injected via the handler factory pattern.

Key Changes:

  • Converted 4 discussion functions to use NewTool with dependency injection
  • Updated function signatures to return toolsets.ServerTool and accept only translation helper
  • Modified all 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/discussions.go Refactored all 4 discussion functions (ListDiscussions, GetDiscussion, GetDiscussionComments, ListDiscussionCategories) to use NewTool pattern with handler factory that accepts ToolDependencies
pkg/github/tools.go Removed NewServerToolLegacy wrappers from discussion tools registration, now calling functions directly with translation helper
pkg/github/discussions_test.go Updated all test cases to use new pattern: create toolDef, extract tool, create ToolDependencies, call toolDef.Handler(deps), and invoke handler without explicit params

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