Skip to content

Commit f3cb709

Browse files
Merge branch 'main' into github-artifact-attestations
2 parents 1aa3eae + 3f62483 commit f3cb709

15 files changed

Lines changed: 303 additions & 290 deletions

.github/workflows/docker-publish.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,18 @@ jobs:
6666
uses: docker/metadata-action@96383f45573cb7f253c731d3b3ab81c87ef81934 # v5.0.0
6767
with:
6868
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
69+
tags: |
70+
type=schedule
71+
type=ref,event=branch
72+
type=ref,event=tag
73+
type=ref,event=pr
74+
type=semver,pattern={{version}}
75+
type=semver,pattern={{major}}.{{minor}}
76+
type=semver,pattern={{major}}
77+
type=sha
78+
type=edge
79+
# Custom rule to prevent pre-releases from getting latest tag
80+
type=raw,value=latest,enable=${{ github.ref_type == 'tag' && startsWith(github.ref, 'refs/tags/v') && !contains(github.ref, '-') }}
6981
7082
- name: Go Build Cache for Docker
7183
uses: actions/cache@v4

pkg/github/code_scanning.go

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

16-
func getCodeScanningAlert(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
16+
func GetCodeScanningAlert(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
1717
return mcp.NewTool("get_code_scanning_alert",
1818
mcp.WithDescription(t("TOOL_GET_CODE_SCANNING_ALERT_DESCRIPTION", "Get details of a specific code scanning alert in a GitHub repository.")),
1919
mcp.WithString("owner",
@@ -38,7 +38,7 @@ func getCodeScanningAlert(client *github.Client, t translations.TranslationHelpe
3838
if err != nil {
3939
return mcp.NewToolResultError(err.Error()), nil
4040
}
41-
alertNumber, err := requiredInt(request, "alertNumber")
41+
alertNumber, err := RequiredInt(request, "alertNumber")
4242
if err != nil {
4343
return mcp.NewToolResultError(err.Error()), nil
4444
}
@@ -66,7 +66,7 @@ func getCodeScanningAlert(client *github.Client, t translations.TranslationHelpe
6666
}
6767
}
6868

69-
func listCodeScanningAlerts(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
69+
func ListCodeScanningAlerts(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
7070
return mcp.NewTool("list_code_scanning_alerts",
7171
mcp.WithDescription(t("TOOL_LIST_CODE_SCANNING_ALERTS_DESCRIPTION", "List code scanning alerts in a GitHub repository.")),
7272
mcp.WithString("owner",
@@ -97,15 +97,15 @@ func listCodeScanningAlerts(client *github.Client, t translations.TranslationHel
9797
if err != nil {
9898
return mcp.NewToolResultError(err.Error()), nil
9999
}
100-
ref, err := optionalParam[string](request, "ref")
100+
ref, err := OptionalParam[string](request, "ref")
101101
if err != nil {
102102
return mcp.NewToolResultError(err.Error()), nil
103103
}
104-
state, err := optionalParam[string](request, "state")
104+
state, err := OptionalParam[string](request, "state")
105105
if err != nil {
106106
return mcp.NewToolResultError(err.Error()), nil
107107
}
108-
severity, err := optionalParam[string](request, "severity")
108+
severity, err := OptionalParam[string](request, "severity")
109109
if err != nil {
110110
return mcp.NewToolResultError(err.Error()), nil
111111
}

pkg/github/code_scanning_test.go

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

2121
assert.Equal(t, "get_code_scanning_alert", tool.Name)
2222
assert.NotEmpty(t, tool.Description)
@@ -82,7 +82,7 @@ func Test_GetCodeScanningAlert(t *testing.T) {
8282
t.Run(tc.name, func(t *testing.T) {
8383
// Setup client with mock
8484
client := github.NewClient(tc.mockedClient)
85-
_, handler := getCodeScanningAlert(client, translations.NullTranslationHelper)
85+
_, handler := GetCodeScanningAlert(client, translations.NullTranslationHelper)
8686

8787
// Create call request
8888
request := createMCPRequest(tc.requestArgs)
@@ -118,7 +118,7 @@ func Test_GetCodeScanningAlert(t *testing.T) {
118118
func Test_ListCodeScanningAlerts(t *testing.T) {
119119
// Verify tool definition once
120120
mockClient := github.NewClient(nil)
121-
tool, _ := listCodeScanningAlerts(mockClient, translations.NullTranslationHelper)
121+
tool, _ := ListCodeScanningAlerts(mockClient, translations.NullTranslationHelper)
122122

123123
assert.Equal(t, "list_code_scanning_alerts", tool.Name)
124124
assert.NotEmpty(t, tool.Description)
@@ -201,7 +201,7 @@ func Test_ListCodeScanningAlerts(t *testing.T) {
201201
t.Run(tc.name, func(t *testing.T) {
202202
// Setup client with mock
203203
client := github.NewClient(tc.mockedClient)
204-
_, handler := listCodeScanningAlerts(client, translations.NullTranslationHelper)
204+
_, handler := ListCodeScanningAlerts(client, translations.NullTranslationHelper)
205205

206206
// Create call request
207207
request := createMCPRequest(tc.requestArgs)

pkg/github/issues.go

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

17-
// getIssue creates a tool to get details of a specific issue in a GitHub repository.
18-
func getIssue(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
17+
// GetIssue creates a tool to get details of a specific issue in a GitHub repository.
18+
func GetIssue(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
1919
return mcp.NewTool("get_issue",
2020
mcp.WithDescription(t("TOOL_GET_ISSUE_DESCRIPTION", "Get details of a specific issue in a GitHub repository")),
2121
mcp.WithString("owner",
@@ -40,7 +40,7 @@ func getIssue(client *github.Client, t translations.TranslationHelperFunc) (tool
4040
if err != nil {
4141
return mcp.NewToolResultError(err.Error()), nil
4242
}
43-
issueNumber, err := requiredInt(request, "issue_number")
43+
issueNumber, err := RequiredInt(request, "issue_number")
4444
if err != nil {
4545
return mcp.NewToolResultError(err.Error()), nil
4646
}
@@ -68,8 +68,8 @@ func getIssue(client *github.Client, t translations.TranslationHelperFunc) (tool
6868
}
6969
}
7070

71-
// addIssueComment creates a tool to add a comment to an issue.
72-
func addIssueComment(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
71+
// AddIssueComment creates a tool to add a comment to an issue.
72+
func AddIssueComment(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
7373
return mcp.NewTool("add_issue_comment",
7474
mcp.WithDescription(t("TOOL_ADD_ISSUE_COMMENT_DESCRIPTION", "Add a comment to an existing issue")),
7575
mcp.WithString("owner",
@@ -98,7 +98,7 @@ func addIssueComment(client *github.Client, t translations.TranslationHelperFunc
9898
if err != nil {
9999
return mcp.NewToolResultError(err.Error()), nil
100100
}
101-
issueNumber, err := requiredInt(request, "issue_number")
101+
issueNumber, err := RequiredInt(request, "issue_number")
102102
if err != nil {
103103
return mcp.NewToolResultError(err.Error()), nil
104104
}
@@ -134,8 +134,8 @@ func addIssueComment(client *github.Client, t translations.TranslationHelperFunc
134134
}
135135
}
136136

137-
// searchIssues creates a tool to search for issues and pull requests.
138-
func searchIssues(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
137+
// SearchIssues creates a tool to search for issues and pull requests.
138+
func SearchIssues(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
139139
return mcp.NewTool("search_issues",
140140
mcp.WithDescription(t("TOOL_SEARCH_ISSUES_DESCRIPTION", "Search for issues and pull requests across GitHub repositories")),
141141
mcp.WithString("q",
@@ -162,22 +162,22 @@ func searchIssues(client *github.Client, t translations.TranslationHelperFunc) (
162162
mcp.Description("Sort order ('asc' or 'desc')"),
163163
mcp.Enum("asc", "desc"),
164164
),
165-
withPagination(),
165+
WithPagination(),
166166
),
167167
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
168168
query, err := requiredParam[string](request, "q")
169169
if err != nil {
170170
return mcp.NewToolResultError(err.Error()), nil
171171
}
172-
sort, err := optionalParam[string](request, "sort")
172+
sort, err := OptionalParam[string](request, "sort")
173173
if err != nil {
174174
return mcp.NewToolResultError(err.Error()), nil
175175
}
176-
order, err := optionalParam[string](request, "order")
176+
order, err := OptionalParam[string](request, "order")
177177
if err != nil {
178178
return mcp.NewToolResultError(err.Error()), nil
179179
}
180-
pagination, err := optionalPaginationParams(request)
180+
pagination, err := OptionalPaginationParams(request)
181181
if err != nil {
182182
return mcp.NewToolResultError(err.Error()), nil
183183
}
@@ -214,8 +214,8 @@ func searchIssues(client *github.Client, t translations.TranslationHelperFunc) (
214214
}
215215
}
216216

217-
// createIssue creates a tool to create a new issue in a GitHub repository.
218-
func createIssue(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
217+
// CreateIssue creates a tool to create a new issue in a GitHub repository.
218+
func CreateIssue(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
219219
return mcp.NewTool("create_issue",
220220
mcp.WithDescription(t("TOOL_CREATE_ISSUE_DESCRIPTION", "Create a new issue in a GitHub repository")),
221221
mcp.WithString("owner",
@@ -268,25 +268,25 @@ func createIssue(client *github.Client, t translations.TranslationHelperFunc) (t
268268
}
269269

270270
// Optional parameters
271-
body, err := optionalParam[string](request, "body")
271+
body, err := OptionalParam[string](request, "body")
272272
if err != nil {
273273
return mcp.NewToolResultError(err.Error()), nil
274274
}
275275

276276
// Get assignees
277-
assignees, err := optionalStringArrayParam(request, "assignees")
277+
assignees, err := OptionalStringArrayParam(request, "assignees")
278278
if err != nil {
279279
return mcp.NewToolResultError(err.Error()), nil
280280
}
281281

282282
// Get labels
283-
labels, err := optionalStringArrayParam(request, "labels")
283+
labels, err := OptionalStringArrayParam(request, "labels")
284284
if err != nil {
285285
return mcp.NewToolResultError(err.Error()), nil
286286
}
287287

288288
// Get optional milestone
289-
milestone, err := optionalIntParam(request, "milestone")
289+
milestone, err := OptionalIntParam(request, "milestone")
290290
if err != nil {
291291
return mcp.NewToolResultError(err.Error()), nil
292292
}
@@ -328,8 +328,8 @@ func createIssue(client *github.Client, t translations.TranslationHelperFunc) (t
328328
}
329329
}
330330

331-
// listIssues creates a tool to list and filter repository issues
332-
func listIssues(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
331+
// ListIssues creates a tool to list and filter repository issues
332+
func ListIssues(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
333333
return mcp.NewTool("list_issues",
334334
mcp.WithDescription(t("TOOL_LIST_ISSUES_DESCRIPTION", "List issues in a GitHub repository with filtering options")),
335335
mcp.WithString("owner",
@@ -363,7 +363,7 @@ func listIssues(client *github.Client, t translations.TranslationHelperFunc) (to
363363
mcp.WithString("since",
364364
mcp.Description("Filter by date (ISO 8601 timestamp)"),
365365
),
366-
withPagination(),
366+
WithPagination(),
367367
),
368368
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
369369
owner, err := requiredParam[string](request, "owner")
@@ -378,28 +378,28 @@ func listIssues(client *github.Client, t translations.TranslationHelperFunc) (to
378378
opts := &github.IssueListByRepoOptions{}
379379

380380
// Set optional parameters if provided
381-
opts.State, err = optionalParam[string](request, "state")
381+
opts.State, err = OptionalParam[string](request, "state")
382382
if err != nil {
383383
return mcp.NewToolResultError(err.Error()), nil
384384
}
385385

386386
// Get labels
387-
opts.Labels, err = optionalStringArrayParam(request, "labels")
387+
opts.Labels, err = OptionalStringArrayParam(request, "labels")
388388
if err != nil {
389389
return mcp.NewToolResultError(err.Error()), nil
390390
}
391391

392-
opts.Sort, err = optionalParam[string](request, "sort")
392+
opts.Sort, err = OptionalParam[string](request, "sort")
393393
if err != nil {
394394
return mcp.NewToolResultError(err.Error()), nil
395395
}
396396

397-
opts.Direction, err = optionalParam[string](request, "direction")
397+
opts.Direction, err = OptionalParam[string](request, "direction")
398398
if err != nil {
399399
return mcp.NewToolResultError(err.Error()), nil
400400
}
401401

402-
since, err := optionalParam[string](request, "since")
402+
since, err := OptionalParam[string](request, "since")
403403
if err != nil {
404404
return mcp.NewToolResultError(err.Error()), nil
405405
}
@@ -442,8 +442,8 @@ func listIssues(client *github.Client, t translations.TranslationHelperFunc) (to
442442
}
443443
}
444444

445-
// updateIssue creates a tool to update an existing issue in a GitHub repository.
446-
func updateIssue(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
445+
// UpdateIssue creates a tool to update an existing issue in a GitHub repository.
446+
func UpdateIssue(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
447447
return mcp.NewTool("update_issue",
448448
mcp.WithDescription(t("TOOL_UPDATE_ISSUE_DESCRIPTION", "Update an existing issue in a GitHub repository")),
449449
mcp.WithString("owner",
@@ -497,7 +497,7 @@ func updateIssue(client *github.Client, t translations.TranslationHelperFunc) (t
497497
if err != nil {
498498
return mcp.NewToolResultError(err.Error()), nil
499499
}
500-
issueNumber, err := requiredInt(request, "issue_number")
500+
issueNumber, err := RequiredInt(request, "issue_number")
501501
if err != nil {
502502
return mcp.NewToolResultError(err.Error()), nil
503503
}
@@ -506,23 +506,23 @@ func updateIssue(client *github.Client, t translations.TranslationHelperFunc) (t
506506
issueRequest := &github.IssueRequest{}
507507

508508
// Set optional parameters if provided
509-
title, err := optionalParam[string](request, "title")
509+
title, err := OptionalParam[string](request, "title")
510510
if err != nil {
511511
return mcp.NewToolResultError(err.Error()), nil
512512
}
513513
if title != "" {
514514
issueRequest.Title = github.Ptr(title)
515515
}
516516

517-
body, err := optionalParam[string](request, "body")
517+
body, err := OptionalParam[string](request, "body")
518518
if err != nil {
519519
return mcp.NewToolResultError(err.Error()), nil
520520
}
521521
if body != "" {
522522
issueRequest.Body = github.Ptr(body)
523523
}
524524

525-
state, err := optionalParam[string](request, "state")
525+
state, err := OptionalParam[string](request, "state")
526526
if err != nil {
527527
return mcp.NewToolResultError(err.Error()), nil
528528
}
@@ -531,7 +531,7 @@ func updateIssue(client *github.Client, t translations.TranslationHelperFunc) (t
531531
}
532532

533533
// Get labels
534-
labels, err := optionalStringArrayParam(request, "labels")
534+
labels, err := OptionalStringArrayParam(request, "labels")
535535
if err != nil {
536536
return mcp.NewToolResultError(err.Error()), nil
537537
}
@@ -540,15 +540,15 @@ func updateIssue(client *github.Client, t translations.TranslationHelperFunc) (t
540540
}
541541

542542
// Get assignees
543-
assignees, err := optionalStringArrayParam(request, "assignees")
543+
assignees, err := OptionalStringArrayParam(request, "assignees")
544544
if err != nil {
545545
return mcp.NewToolResultError(err.Error()), nil
546546
}
547547
if len(assignees) > 0 {
548548
issueRequest.Assignees = &assignees
549549
}
550550

551-
milestone, err := optionalIntParam(request, "milestone")
551+
milestone, err := OptionalIntParam(request, "milestone")
552552
if err != nil {
553553
return mcp.NewToolResultError(err.Error()), nil
554554
}
@@ -580,8 +580,8 @@ func updateIssue(client *github.Client, t translations.TranslationHelperFunc) (t
580580
}
581581
}
582582

583-
// getIssueComments creates a tool to get comments for a GitHub issue.
584-
func getIssueComments(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
583+
// GetIssueComments creates a tool to get comments for a GitHub issue.
584+
func GetIssueComments(client *github.Client, t translations.TranslationHelperFunc) (tool mcp.Tool, handler server.ToolHandlerFunc) {
585585
return mcp.NewTool("get_issue_comments",
586586
mcp.WithDescription(t("TOOL_GET_ISSUE_COMMENTS_DESCRIPTION", "Get comments for a GitHub issue")),
587587
mcp.WithString("owner",
@@ -612,15 +612,15 @@ func getIssueComments(client *github.Client, t translations.TranslationHelperFun
612612
if err != nil {
613613
return mcp.NewToolResultError(err.Error()), nil
614614
}
615-
issueNumber, err := requiredInt(request, "issue_number")
615+
issueNumber, err := RequiredInt(request, "issue_number")
616616
if err != nil {
617617
return mcp.NewToolResultError(err.Error()), nil
618618
}
619-
page, err := optionalIntParamWithDefault(request, "page", 1)
619+
page, err := OptionalIntParamWithDefault(request, "page", 1)
620620
if err != nil {
621621
return mcp.NewToolResultError(err.Error()), nil
622622
}
623-
perPage, err := optionalIntParamWithDefault(request, "per_page", 30)
623+
perPage, err := OptionalIntParamWithDefault(request, "per_page", 30)
624624
if err != nil {
625625
return mcp.NewToolResultError(err.Error()), nil
626626
}

0 commit comments

Comments
 (0)