-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Migrate context_tools to new ServerTool pattern #1590
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Migrate context_tools to new ServerTool pattern #1590
Conversation
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>
There was a problem hiding this 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 theNewToolhelper 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
nilfor Go errors (MCP errors are reported viaresult.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>
07249a0 to
b863da9
Compare
b29546e to
43acefe
Compare
* Migrate context_tools to new ServerTool pattern 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 <oholt@github.com> * refactor(gists): migrate gists.go to NewTool pattern Convert all gist tools (ListGists, GetGist, CreateGist, UpdateGist) to use the new NewTool helper with ToolDependencies injection. - Remove getClient parameter from function signatures - Use deps.GetClient(ctx) inside handlers - Standardize error handling with utils.NewToolResultErrorFromErr() - Update all tests to use serverTool.Handler(deps) pattern Co-authored-by: Adam Holt <omgitsads@users.noreply.github.com> --------- Co-authored-by: Adam Holt <oholt@github.com> Co-authored-by: Adam Holt <omgitsads@users.noreply.github.com>
f735f45
into
SamMorrowDrums/server-tool-refactor
Summary
Second PR in the ServerTool refactor stack. Migrates
context_tools.goto the new typed dependency injection pattern.Changes
GetMe,GetTeams, andGetTeamMembersto useNewToolhelpertranslations.TranslationHelperFunc, returningtoolsets.ServerTooldeps.GetClient(ctx)/deps.GetGQLClient(ctx)serverTool.Handler(deps)pattern with proper error handlingnilfor Go error (errors reported viaresult.IsError)Stack
Testing
script/lintpassesscript/testpassesCo-authored-by: Adam Holt oholt@github.com