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

Commitc1bdd6a

Browse files
chore: export repository funcs
1 parentc85dd07 commitc1bdd6a

File tree

5 files changed

+68
-67
lines changed

5 files changed

+68
-67
lines changed

‎pkg/github/repositories.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ import (
1313
"github.com/mark3labs/mcp-go/server"
1414
)
1515

16-
//listCommits creates a tool to get commits of a branch in a repository.
17-
funclistCommits(client*github.Client,t translations.TranslationHelperFunc) (tool mcp.Tool,handler server.ToolHandlerFunc) {
16+
//ListCommits creates a tool to get commits of a branch in a repository.
17+
funcListCommits(client*github.Client,t translations.TranslationHelperFunc) (tool mcp.Tool,handler server.ToolHandlerFunc) {
1818
returnmcp.NewTool("list_commits",
1919
mcp.WithDescription(t("TOOL_LIST_COMMITS_DESCRIPTION","Get list of commits of a branch in a GitHub repository")),
2020
mcp.WithString("owner",
@@ -79,8 +79,8 @@ func listCommits(client *github.Client, t translations.TranslationHelperFunc) (t
7979
}
8080
}
8181

82-
//createOrUpdateFile creates a tool to create or update a file in a GitHub repository.
83-
funccreateOrUpdateFile(client*github.Client,t translations.TranslationHelperFunc) (tool mcp.Tool,handler server.ToolHandlerFunc) {
82+
//CreateOrUpdateFile creates a tool to create or update a file in a GitHub repository.
83+
funcCreateOrUpdateFile(client*github.Client,t translations.TranslationHelperFunc) (tool mcp.Tool,handler server.ToolHandlerFunc) {
8484
returnmcp.NewTool("create_or_update_file",
8585
mcp.WithDescription(t("TOOL_CREATE_OR_UPDATE_FILE_DESCRIPTION","Create or update a single file in a GitHub repository")),
8686
mcp.WithString("owner",
@@ -180,8 +180,8 @@ func createOrUpdateFile(client *github.Client, t translations.TranslationHelperF
180180
}
181181
}
182182

183-
//createRepository creates a tool to create a new GitHub repository.
184-
funccreateRepository(client*github.Client,t translations.TranslationHelperFunc) (tool mcp.Tool,handler server.ToolHandlerFunc) {
183+
//CreateRepository creates a tool to create a new GitHub repository.
184+
funcCreateRepository(client*github.Client,t translations.TranslationHelperFunc) (tool mcp.Tool,handler server.ToolHandlerFunc) {
185185
returnmcp.NewTool("create_repository",
186186
mcp.WithDescription(t("TOOL_CREATE_REPOSITORY_DESCRIPTION","Create a new GitHub repository in your account")),
187187
mcp.WithString("name",
@@ -246,8 +246,8 @@ func createRepository(client *github.Client, t translations.TranslationHelperFun
246246
}
247247
}
248248

249-
//getFileContents creates a tool to get the contents of a file or directory from a GitHub repository.
250-
funcgetFileContents(client*github.Client,t translations.TranslationHelperFunc) (tool mcp.Tool,handler server.ToolHandlerFunc) {
249+
//GetFileContents creates a tool to get the contents of a file or directory from a GitHub repository.
250+
funcGetFileContents(client*github.Client,t translations.TranslationHelperFunc) (tool mcp.Tool,handler server.ToolHandlerFunc) {
251251
returnmcp.NewTool("get_file_contents",
252252
mcp.WithDescription(t("TOOL_GET_FILE_CONTENTS_DESCRIPTION","Get the contents of a file or directory from a GitHub repository")),
253253
mcp.WithString("owner",
@@ -315,8 +315,8 @@ func getFileContents(client *github.Client, t translations.TranslationHelperFunc
315315
}
316316
}
317317

318-
//forkRepository creates a tool to fork a repository.
319-
funcforkRepository(client*github.Client,t translations.TranslationHelperFunc) (tool mcp.Tool,handler server.ToolHandlerFunc) {
318+
//ForkRepository creates a tool to fork a repository.
319+
funcForkRepository(client*github.Client,t translations.TranslationHelperFunc) (tool mcp.Tool,handler server.ToolHandlerFunc) {
320320
returnmcp.NewTool("fork_repository",
321321
mcp.WithDescription(t("TOOL_FORK_REPOSITORY_DESCRIPTION","Fork a GitHub repository to your account or specified organization")),
322322
mcp.WithString("owner",
@@ -378,8 +378,8 @@ func forkRepository(client *github.Client, t translations.TranslationHelperFunc)
378378
}
379379
}
380380

381-
//createBranch creates a tool to create a new branch.
382-
funccreateBranch(client*github.Client,t translations.TranslationHelperFunc) (tool mcp.Tool,handler server.ToolHandlerFunc) {
381+
//CreateBranch creates a tool to create a new branch.
382+
funcCreateBranch(client*github.Client,t translations.TranslationHelperFunc) (tool mcp.Tool,handler server.ToolHandlerFunc) {
383383
returnmcp.NewTool("create_branch",
384384
mcp.WithDescription(t("TOOL_CREATE_BRANCH_DESCRIPTION","Create a new branch in a GitHub repository")),
385385
mcp.WithString("owner",
@@ -458,8 +458,8 @@ func createBranch(client *github.Client, t translations.TranslationHelperFunc) (
458458
}
459459
}
460460

461-
//pushFiles creates a tool to push multiple files in a single commit to a GitHub repository.
462-
funcpushFiles(client*github.Client,t translations.TranslationHelperFunc) (tool mcp.Tool,handler server.ToolHandlerFunc) {
461+
//PushFiles creates a tool to push multiple files in a single commit to a GitHub repository.
462+
funcPushFiles(client*github.Client,t translations.TranslationHelperFunc) (tool mcp.Tool,handler server.ToolHandlerFunc) {
463463
returnmcp.NewTool("push_files",
464464
mcp.WithDescription(t("TOOL_PUSH_FILES_DESCRIPTION","Push multiple files to a GitHub repository in a single commit")),
465465
mcp.WithString("owner",

‎pkg/github/repositories_test.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
funcTest_GetFileContents(t*testing.T) {
1919
// Verify tool definition once
2020
mockClient:=github.NewClient(nil)
21-
tool,_:=getFileContents(mockClient,translations.NullTranslationHelper)
21+
tool,_:=GetFileContents(mockClient,translations.NullTranslationHelper)
2222

2323
assert.Equal(t,"get_file_contents",tool.Name)
2424
assert.NotEmpty(t,tool.Description)
@@ -132,7 +132,7 @@ func Test_GetFileContents(t *testing.T) {
132132
t.Run(tc.name,func(t*testing.T) {
133133
// Setup client with mock
134134
client:=github.NewClient(tc.mockedClient)
135-
_,handler:=getFileContents(client,translations.NullTranslationHelper)
135+
_,handler:=GetFileContents(client,translations.NullTranslationHelper)
136136

137137
// Create call request
138138
request:= mcp.CallToolRequest{
@@ -189,7 +189,7 @@ func Test_GetFileContents(t *testing.T) {
189189
funcTest_ForkRepository(t*testing.T) {
190190
// Verify tool definition once
191191
mockClient:=github.NewClient(nil)
192-
tool,_:=forkRepository(mockClient,translations.NullTranslationHelper)
192+
tool,_:=ForkRepository(mockClient,translations.NullTranslationHelper)
193193

194194
assert.Equal(t,"fork_repository",tool.Name)
195195
assert.NotEmpty(t,tool.Description)
@@ -259,7 +259,7 @@ func Test_ForkRepository(t *testing.T) {
259259
t.Run(tc.name,func(t*testing.T) {
260260
// Setup client with mock
261261
client:=github.NewClient(tc.mockedClient)
262-
_,handler:=forkRepository(client,translations.NullTranslationHelper)
262+
_,handler:=ForkRepository(client,translations.NullTranslationHelper)
263263

264264
// Create call request
265265
request:=createMCPRequest(tc.requestArgs)
@@ -287,7 +287,7 @@ func Test_ForkRepository(t *testing.T) {
287287
funcTest_CreateBranch(t*testing.T) {
288288
// Verify tool definition once
289289
mockClient:=github.NewClient(nil)
290-
tool,_:=createBranch(mockClient,translations.NullTranslationHelper)
290+
tool,_:=CreateBranch(mockClient,translations.NullTranslationHelper)
291291

292292
assert.Equal(t,"create_branch",tool.Name)
293293
assert.NotEmpty(t,tool.Description)
@@ -445,7 +445,7 @@ func Test_CreateBranch(t *testing.T) {
445445
t.Run(tc.name,func(t*testing.T) {
446446
// Setup client with mock
447447
client:=github.NewClient(tc.mockedClient)
448-
_,handler:=createBranch(client,translations.NullTranslationHelper)
448+
_,handler:=CreateBranch(client,translations.NullTranslationHelper)
449449

450450
// Create call request
451451
request:=createMCPRequest(tc.requestArgs)
@@ -478,7 +478,7 @@ func Test_CreateBranch(t *testing.T) {
478478
funcTest_ListCommits(t*testing.T) {
479479
// Verify tool definition once
480480
mockClient:=github.NewClient(nil)
481-
tool,_:=listCommits(mockClient,translations.NullTranslationHelper)
481+
tool,_:=ListCommits(mockClient,translations.NullTranslationHelper)
482482

483483
assert.Equal(t,"list_commits",tool.Name)
484484
assert.NotEmpty(t,tool.Description)
@@ -614,7 +614,7 @@ func Test_ListCommits(t *testing.T) {
614614
t.Run(tc.name,func(t*testing.T) {
615615
// Setup client with mock
616616
client:=github.NewClient(tc.mockedClient)
617-
_,handler:=listCommits(client,translations.NullTranslationHelper)
617+
_,handler:=ListCommits(client,translations.NullTranslationHelper)
618618

619619
// Create call request
620620
request:=createMCPRequest(tc.requestArgs)
@@ -652,7 +652,7 @@ func Test_ListCommits(t *testing.T) {
652652
funcTest_CreateOrUpdateFile(t*testing.T) {
653653
// Verify tool definition once
654654
mockClient:=github.NewClient(nil)
655-
tool,_:=createOrUpdateFile(mockClient,translations.NullTranslationHelper)
655+
tool,_:=CreateOrUpdateFile(mockClient,translations.NullTranslationHelper)
656656

657657
assert.Equal(t,"create_or_update_file",tool.Name)
658658
assert.NotEmpty(t,tool.Description)
@@ -775,7 +775,7 @@ func Test_CreateOrUpdateFile(t *testing.T) {
775775
t.Run(tc.name,func(t*testing.T) {
776776
// Setup client with mock
777777
client:=github.NewClient(tc.mockedClient)
778-
_,handler:=createOrUpdateFile(client,translations.NullTranslationHelper)
778+
_,handler:=CreateOrUpdateFile(client,translations.NullTranslationHelper)
779779

780780
// Create call request
781781
request:=createMCPRequest(tc.requestArgs)
@@ -815,7 +815,7 @@ func Test_CreateOrUpdateFile(t *testing.T) {
815815
funcTest_CreateRepository(t*testing.T) {
816816
// Verify tool definition once
817817
mockClient:=github.NewClient(nil)
818-
tool,_:=createRepository(mockClient,translations.NullTranslationHelper)
818+
tool,_:=CreateRepository(mockClient,translations.NullTranslationHelper)
819819

820820
assert.Equal(t,"create_repository",tool.Name)
821821
assert.NotEmpty(t,tool.Description)
@@ -923,7 +923,7 @@ func Test_CreateRepository(t *testing.T) {
923923
t.Run(tc.name,func(t*testing.T) {
924924
// Setup client with mock
925925
client:=github.NewClient(tc.mockedClient)
926-
_,handler:=createRepository(client,translations.NullTranslationHelper)
926+
_,handler:=CreateRepository(client,translations.NullTranslationHelper)
927927

928928
// Create call request
929929
request:=createMCPRequest(tc.requestArgs)
@@ -961,7 +961,7 @@ func Test_CreateRepository(t *testing.T) {
961961
funcTest_PushFiles(t*testing.T) {
962962
// Verify tool definition once
963963
mockClient:=github.NewClient(nil)
964-
tool,_:=pushFiles(mockClient,translations.NullTranslationHelper)
964+
tool,_:=PushFiles(mockClient,translations.NullTranslationHelper)
965965

966966
assert.Equal(t,"push_files",tool.Name)
967967
assert.NotEmpty(t,tool.Description)
@@ -1256,7 +1256,7 @@ func Test_PushFiles(t *testing.T) {
12561256
t.Run(tc.name,func(t*testing.T) {
12571257
// Setup client with mock
12581258
client:=github.NewClient(tc.mockedClient)
1259-
_,handler:=pushFiles(client,translations.NullTranslationHelper)
1259+
_,handler:=PushFiles(client,translations.NullTranslationHelper)
12601260

12611261
// Create call request
12621262
request:=createMCPRequest(tc.requestArgs)

‎pkg/github/repository_resource.go

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,52 +17,53 @@ import (
1717
"github.com/mark3labs/mcp-go/server"
1818
)
1919

20-
//getRepositoryResourceContent defines the resource template and handler for getting repository content.
21-
funcgetRepositoryResourceContent(client*github.Client,t translations.TranslationHelperFunc) (mcp.ResourceTemplate, server.ResourceTemplateHandlerFunc) {
20+
//GetRepositoryResourceContent defines the resource template and handler for getting repository content.
21+
funcGetRepositoryResourceContent(client*github.Client,t translations.TranslationHelperFunc) (mcp.ResourceTemplate, server.ResourceTemplateHandlerFunc) {
2222
returnmcp.NewResourceTemplate(
2323
"repo://{owner}/{repo}/contents{/path*}",// Resource template
2424
t("RESOURCE_REPOSITORY_CONTENT_DESCRIPTION","Repository Content"),
2525
),
26-
repositoryResourceContentsHandler(client)
26+
RepositoryResourceContentsHandler(client)
2727
}
2828

29-
//getRepositoryContent defines the resource template and handler for getting repository content for a branch.
30-
funcgetRepositoryResourceBranchContent(client*github.Client,t translations.TranslationHelperFunc) (mcp.ResourceTemplate, server.ResourceTemplateHandlerFunc) {
29+
//GetRepositoryResourceBranchContent defines the resource template and handler for getting repository content for a branch.
30+
funcGetRepositoryResourceBranchContent(client*github.Client,t translations.TranslationHelperFunc) (mcp.ResourceTemplate, server.ResourceTemplateHandlerFunc) {
3131
returnmcp.NewResourceTemplate(
3232
"repo://{owner}/{repo}/refs/heads/{branch}/contents{/path*}",// Resource template
3333
t("RESOURCE_REPOSITORY_CONTENT_BRANCH_DESCRIPTION","Repository Content for specific branch"),
3434
),
35-
repositoryResourceContentsHandler(client)
35+
RepositoryResourceContentsHandler(client)
3636
}
3737

38-
//getRepositoryResourceCommitContent defines the resource template and handler for getting repository content for a commit.
39-
funcgetRepositoryResourceCommitContent(client*github.Client,t translations.TranslationHelperFunc) (mcp.ResourceTemplate, server.ResourceTemplateHandlerFunc) {
38+
//GetRepositoryResourceCommitContent defines the resource template and handler for getting repository content for a commit.
39+
funcGetRepositoryResourceCommitContent(client*github.Client,t translations.TranslationHelperFunc) (mcp.ResourceTemplate, server.ResourceTemplateHandlerFunc) {
4040
returnmcp.NewResourceTemplate(
4141
"repo://{owner}/{repo}/sha/{sha}/contents{/path*}",// Resource template
4242
t("RESOURCE_REPOSITORY_CONTENT_COMMIT_DESCRIPTION","Repository Content for specific commit"),
4343
),
44-
repositoryResourceContentsHandler(client)
44+
RepositoryResourceContentsHandler(client)
4545
}
4646

47-
//getRepositoryResourceTagContent defines the resource template and handler for getting repository content for a tag.
48-
funcgetRepositoryResourceTagContent(client*github.Client,t translations.TranslationHelperFunc) (mcp.ResourceTemplate, server.ResourceTemplateHandlerFunc) {
47+
//GetRepositoryResourceTagContent defines the resource template and handler for getting repository content for a tag.
48+
funcGetRepositoryResourceTagContent(client*github.Client,t translations.TranslationHelperFunc) (mcp.ResourceTemplate, server.ResourceTemplateHandlerFunc) {
4949
returnmcp.NewResourceTemplate(
5050
"repo://{owner}/{repo}/refs/tags/{tag}/contents{/path*}",// Resource template
5151
t("RESOURCE_REPOSITORY_CONTENT_TAG_DESCRIPTION","Repository Content for specific tag"),
5252
),
53-
repositoryResourceContentsHandler(client)
53+
RepositoryResourceContentsHandler(client)
5454
}
5555

56-
//getRepositoryResourcePrContent defines the resource template and handler for getting repository content for a pull request.
57-
funcgetRepositoryResourcePrContent(client*github.Client,t translations.TranslationHelperFunc) (mcp.ResourceTemplate, server.ResourceTemplateHandlerFunc) {
56+
//GetRepositoryResourcePrContent defines the resource template and handler for getting repository content for a pull request.
57+
funcGetRepositoryResourcePrContent(client*github.Client,t translations.TranslationHelperFunc) (mcp.ResourceTemplate, server.ResourceTemplateHandlerFunc) {
5858
returnmcp.NewResourceTemplate(
5959
"repo://{owner}/{repo}/refs/pull/{prNumber}/head/contents{/path*}",// Resource template
6060
t("RESOURCE_REPOSITORY_CONTENT_PR_DESCRIPTION","Repository Content for specific pull request"),
6161
),
62-
repositoryResourceContentsHandler(client)
62+
RepositoryResourceContentsHandler(client)
6363
}
6464

65-
funcrepositoryResourceContentsHandler(client*github.Client)func(ctx context.Context,request mcp.ReadResourceRequest) ([]mcp.ResourceContents,error) {
65+
// RepositoryResourceContentsHandler returns a handler function for repository content requests.
66+
funcRepositoryResourceContentsHandler(client*github.Client)func(ctx context.Context,request mcp.ReadResourceRequest) ([]mcp.ResourceContents,error) {
6667
returnfunc(ctx context.Context,request mcp.ReadResourceRequest) ([]mcp.ResourceContents,error) {
6768
// the matcher will give []string with one element
6869
// https://github.com/mark3labs/mcp-go/pull/54

‎pkg/github/repository_resource_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ func Test_repositoryResourceContentsHandler(t *testing.T) {
234234
for_,tc:=rangetests {
235235
t.Run(tc.name,func(t*testing.T) {
236236
client:=github.NewClient(tc.mockedClient)
237-
handler:=repositoryResourceContentsHandler(client)
237+
handler:=RepositoryResourceContentsHandler(client)
238238

239239
request:= mcp.ReadResourceRequest{
240240
Params:struct {
@@ -258,26 +258,26 @@ func Test_repositoryResourceContentsHandler(t *testing.T) {
258258
}
259259
}
260260

261-
funcTest_getRepositoryResourceContent(t*testing.T) {
262-
tmpl,_:=getRepositoryResourceContent(nil,translations.NullTranslationHelper)
261+
funcTest_GetRepositoryResourceContent(t*testing.T) {
262+
tmpl,_:=GetRepositoryResourceContent(nil,translations.NullTranslationHelper)
263263
require.Equal(t,"repo://{owner}/{repo}/contents{/path*}",tmpl.URITemplate.Raw())
264264
}
265265

266-
funcTest_getRepositoryResourceBranchContent(t*testing.T) {
267-
tmpl,_:=getRepositoryResourceBranchContent(nil,translations.NullTranslationHelper)
266+
funcTest_GetRepositoryResourceBranchContent(t*testing.T) {
267+
tmpl,_:=GetRepositoryResourceBranchContent(nil,translations.NullTranslationHelper)
268268
require.Equal(t,"repo://{owner}/{repo}/refs/heads/{branch}/contents{/path*}",tmpl.URITemplate.Raw())
269269
}
270-
funcTest_getRepositoryResourceCommitContent(t*testing.T) {
271-
tmpl,_:=getRepositoryResourceCommitContent(nil,translations.NullTranslationHelper)
270+
funcTest_GetRepositoryResourceCommitContent(t*testing.T) {
271+
tmpl,_:=GetRepositoryResourceCommitContent(nil,translations.NullTranslationHelper)
272272
require.Equal(t,"repo://{owner}/{repo}/sha/{sha}/contents{/path*}",tmpl.URITemplate.Raw())
273273
}
274274

275-
funcTest_getRepositoryResourceTagContent(t*testing.T) {
276-
tmpl,_:=getRepositoryResourceTagContent(nil,translations.NullTranslationHelper)
275+
funcTest_GetRepositoryResourceTagContent(t*testing.T) {
276+
tmpl,_:=GetRepositoryResourceTagContent(nil,translations.NullTranslationHelper)
277277
require.Equal(t,"repo://{owner}/{repo}/refs/tags/{tag}/contents{/path*}",tmpl.URITemplate.Raw())
278278
}
279279

280-
funcTest_getRepositoryResourcePrContent(t*testing.T) {
281-
tmpl,_:=getRepositoryResourcePrContent(nil,translations.NullTranslationHelper)
280+
funcTest_GetRepositoryResourcePrContent(t*testing.T) {
281+
tmpl,_:=GetRepositoryResourcePrContent(nil,translations.NullTranslationHelper)
282282
require.Equal(t,"repo://{owner}/{repo}/refs/pull/{prNumber}/head/contents{/path*}",tmpl.URITemplate.Raw())
283283
}

‎pkg/github/server.go

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ func NewServer(client *github.Client, version string, readOnly bool, t translati
2424
server.WithLogging())
2525

2626
// Add GitHub Resources
27-
s.AddResourceTemplate(getRepositoryResourceContent(client,t))
28-
s.AddResourceTemplate(getRepositoryResourceBranchContent(client,t))
29-
s.AddResourceTemplate(getRepositoryResourceCommitContent(client,t))
30-
s.AddResourceTemplate(getRepositoryResourceTagContent(client,t))
31-
s.AddResourceTemplate(getRepositoryResourcePrContent(client,t))
27+
s.AddResourceTemplate(GetRepositoryResourceContent(client,t))
28+
s.AddResourceTemplate(GetRepositoryResourceBranchContent(client,t))
29+
s.AddResourceTemplate(GetRepositoryResourceCommitContent(client,t))
30+
s.AddResourceTemplate(GetRepositoryResourceTagContent(client,t))
31+
s.AddResourceTemplate(GetRepositoryResourcePrContent(client,t))
3232

3333
// Add GitHub tools - Issues
3434
s.AddTool(GetIssue(client,t))
@@ -57,14 +57,14 @@ func NewServer(client *github.Client, version string, readOnly bool, t translati
5757

5858
// Add GitHub tools - Repositories
5959
s.AddTool(searchRepositories(client,t))
60-
s.AddTool(getFileContents(client,t))
61-
s.AddTool(listCommits(client,t))
60+
s.AddTool(GetFileContents(client,t))
61+
s.AddTool(ListCommits(client,t))
6262
if!readOnly {
63-
s.AddTool(createOrUpdateFile(client,t))
64-
s.AddTool(createRepository(client,t))
65-
s.AddTool(forkRepository(client,t))
66-
s.AddTool(createBranch(client,t))
67-
s.AddTool(pushFiles(client,t))
63+
s.AddTool(CreateOrUpdateFile(client,t))
64+
s.AddTool(CreateRepository(client,t))
65+
s.AddTool(ForkRepository(client,t))
66+
s.AddTool(CreateBranch(client,t))
67+
s.AddTool(PushFiles(client,t))
6868
}
6969

7070
// Add GitHub tools - Search

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp