Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit834f0fa

Browse files
Switch to getClient idiom
1 parenteb706e8 commit834f0fa

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

‎pkg/github/organizations.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import (
1313
)
1414

1515
// ListCommits creates a tool to get commits of a branch in a repository.
16-
funcListRepositories(client*github.Client,t translations.TranslationHelperFunc) (tool mcp.Tool,handler server.ToolHandlerFunc) {
16+
funcListRepositories(getClientGetClientFn,t translations.TranslationHelperFunc) (tool mcp.Tool,handler server.ToolHandlerFunc) {
1717
returnmcp.NewTool("list_repositories",
1818
mcp.WithDescription(t("TOOL_LIST_REPOSITORIES_DESCRIPTION","Get list of repositories in a GitHub organization")),
1919
mcp.WithString("org",
@@ -70,6 +70,11 @@ func ListRepositories(client *github.Client, t translations.TranslationHelperFun
7070
opts.Direction=direction
7171
}
7272

73+
client,err:=getClient(ctx)
74+
iferr!=nil {
75+
returnnil,fmt.Errorf("failed to get GitHub client: %w",err)
76+
}
77+
7378
repos,resp,err:=client.Repositories.ListByOrg(ctx,org,opts)
7479
iferr!=nil {
7580
returnnil,fmt.Errorf("failed to list repositories: %w",err)

‎pkg/github/organizations_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
funcTest_ListRepositories(t*testing.T) {
1717
// Verify tool definition once
1818
mockClient:=github.NewClient(nil)
19-
tool,_:=ListRepositories(mockClient,translations.NullTranslationHelper)
19+
tool,_:=ListRepositories(stubGetClientFn(mockClient),translations.NullTranslationHelper)
2020

2121
assert.Equal(t,"list_repositories",tool.Name)
2222
assert.NotEmpty(t,tool.Description)
@@ -172,7 +172,7 @@ func Test_ListRepositories(t *testing.T) {
172172
t.Run(tc.name,func(t*testing.T) {
173173
// Setup client with mock
174174
client:=github.NewClient(tc.mockedClient)
175-
_,handler:=ListRepositories(client,translations.NullTranslationHelper)
175+
_,handler:=ListRepositories(stubGetClientFn(client),translations.NullTranslationHelper)
176176

177177
// Create call request
178178
request:=createMCPRequest(tc.requestArgs)

‎pkg/github/server.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ func NewServer(getClient GetClientFn, version string, readOnly bool, t translati
8080
}
8181

8282
// Add GitHub tools - Organizations
83-
s.AddTool(ListRepositories(client,t))
83+
s.AddTool(ListRepositories(getClient,t))
8484

8585
// Add GitHub tools - Search
8686
s.AddTool(SearchCode(getClient,t))
@@ -181,7 +181,6 @@ func requiredParam[T comparable](r mcp.CallToolRequest, p string) (T, error) {
181181

182182
ifr.Params.Arguments[p].(T)==zero {
183183
returnzero,fmt.Errorf("missing required parameter: %s",p)
184-
185184
}
186185

187186
returnr.Params.Arguments[p].(T),nil

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp