Skip to content

Conversation

@SamMorrowDrums
Copy link
Collaborator

Summary

Second PR in the ServerTool refactor stack. Migrates context_tools.go to the new typed dependency injection pattern.

Changes

  • Convert GetMe, GetTeams, and GetTeamMembers to use NewTool helper
  • Functions now take only translations.TranslationHelperFunc, returning toolsets.ServerTool
  • Handler generated lazily via deps.GetClient(ctx) / deps.GetGQLClient(ctx)
  • Tests updated to use serverTool.Handler(deps) pattern with proper error handling
  • Fixed error return pattern to return nil for Go error (errors reported via result.IsError)

Stack

Testing

  • All existing tests updated and passing
  • script/lint passes
  • script/test passes

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

Migrate search.go tools (SearchRepositories, SearchCode, SearchUsers,
SearchOrgs) to use the new NewTool helper and ToolDependencies pattern.

- Functions now take only TranslationHelperFunc and return ServerTool
- Handler generation uses ToolDependencies for typed access to clients
- Update tools.go call sites to remove getClient parameter
- Update tests to use new Handler(deps) pattern

This demonstrates the migration pattern for additional tool files.

Co-authored-by: Adam Holt <oholt@github.com>
Copilot AI review requested due to automatic review settings December 13, 2025 12:01
@SamMorrowDrums SamMorrowDrums requested a review from a team as a code owner December 13, 2025 12:01
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 context_tools.go to the new ServerTool pattern with typed dependency injection, building on the infrastructure established in PR #1589. The changes eliminate direct dependency passing through function parameters in favor of lazy dependency resolution through the ToolDependencies struct.

Key Changes:

  • Migrated three MCP tools (GetMe, GetTeams, GetTeamMembers) to use the NewTool helper with dependency injection
  • Updated all related tests to use the new serverTool.Handler(deps) pattern with proper error handling
  • Fixed error return patterns to consistently return nil for Go errors (MCP errors are reported via result.IsError)

Reviewed changes

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

File Description
pkg/github/tools.go Removes NewServerToolLegacy wrappers, now directly calls GetMe, GetTeams, and GetTeamMembers which return ServerTool types
pkg/github/context_tools.go Refactors three tool functions to use NewTool helper with typed dependency injection; handlers now access clients via deps.GetClient(ctx) and deps.GetGQLClient(ctx); error handling updated to return nil for Go errors
pkg/github/context_tools_test.go Updates all tests to use serverTool.Handler(deps) pattern; restructures error handling to use getErrorResult helper consistently; adds explicit require.False(t, result.IsError) checks in success paths

Convert GetMe, GetTeams, and GetTeamMembers to use the new typed
dependency injection pattern:
- Functions now take only translations helper, return toolsets.ServerTool
- Handler is generated lazily via deps.GetClient/deps.GetGQLClient
- Tests updated to use serverTool.Handler(deps) pattern
- Fixed error return pattern to return nil for Go error (via result.IsError)

Co-authored-by: Adam Holt <omgitsads@users.noreply.github.com>
@SamMorrowDrums SamMorrowDrums force-pushed the SamMorrowDrums/server-tool-refactor-context-tools branch from 07249a0 to b863da9 Compare December 13, 2025 14:18
@SamMorrowDrums SamMorrowDrums force-pushed the SamMorrowDrums/server-tool-refactor branch from b29546e to 43acefe Compare December 13, 2025 14:19
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