Skip to content

Commit cbcf29f

Browse files
authored
Export ToBoolPtr and RequiredParam (#495)
* ToBoolPtr, RequiredParam * lint: type assertion in RequiredParam * cap docstring
1 parent 392df2d commit cbcf29f

12 files changed

+167
-166
lines changed

pkg/github/code_scanning.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func GetCodeScanningAlert(getClient GetClientFn, t translations.TranslationHelpe
1818
mcp.WithDescription(t("TOOL_GET_CODE_SCANNING_ALERT_DESCRIPTION", "Get details of a specific code scanning alert in a GitHub repository.")),
1919
mcp.WithToolAnnotation(mcp.ToolAnnotation{
2020
Title: t("TOOL_GET_CODE_SCANNING_ALERT_USER_TITLE", "Get code scanning alert"),
21-
ReadOnlyHint: toBoolPtr(true),
21+
ReadOnlyHint: ToBoolPtr(true),
2222
}),
2323
mcp.WithString("owner",
2424
mcp.Required(),
@@ -34,11 +34,11 @@ func GetCodeScanningAlert(getClient GetClientFn, t translations.TranslationHelpe
3434
),
3535
),
3636
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
37-
owner, err := requiredParam[string](request, "owner")
37+
owner, err := RequiredParam[string](request, "owner")
3838
if err != nil {
3939
return mcp.NewToolResultError(err.Error()), nil
4040
}
41-
repo, err := requiredParam[string](request, "repo")
41+
repo, err := RequiredParam[string](request, "repo")
4242
if err != nil {
4343
return mcp.NewToolResultError(err.Error()), nil
4444
}
@@ -80,7 +80,7 @@ func ListCodeScanningAlerts(getClient GetClientFn, t translations.TranslationHel
8080
mcp.WithDescription(t("TOOL_LIST_CODE_SCANNING_ALERTS_DESCRIPTION", "List code scanning alerts in a GitHub repository.")),
8181
mcp.WithToolAnnotation(mcp.ToolAnnotation{
8282
Title: t("TOOL_LIST_CODE_SCANNING_ALERTS_USER_TITLE", "List code scanning alerts"),
83-
ReadOnlyHint: toBoolPtr(true),
83+
ReadOnlyHint: ToBoolPtr(true),
8484
}),
8585
mcp.WithString("owner",
8686
mcp.Required(),
@@ -107,11 +107,11 @@ func ListCodeScanningAlerts(getClient GetClientFn, t translations.TranslationHel
107107
),
108108
),
109109
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
110-
owner, err := requiredParam[string](request, "owner")
110+
owner, err := RequiredParam[string](request, "owner")
111111
if err != nil {
112112
return mcp.NewToolResultError(err.Error()), nil
113113
}
114-
repo, err := requiredParam[string](request, "repo")
114+
repo, err := RequiredParam[string](request, "repo")
115115
if err != nil {
116116
return mcp.NewToolResultError(err.Error()), nil
117117
}

pkg/github/context_tools.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ func GetMe(getClient GetClientFn, t translations.TranslationHelperFunc) (mcp.Too
1414
mcp.WithDescription(t("TOOL_GET_ME_DESCRIPTION", "Get details of the authenticated GitHub user. Use this when a request includes \"me\", \"my\". The output will not change unless the user changes their profile, so only call this once.")),
1515
mcp.WithToolAnnotation(mcp.ToolAnnotation{
1616
Title: t("TOOL_GET_ME_USER_TITLE", "Get my user profile"),
17-
ReadOnlyHint: toBoolPtr(true),
17+
ReadOnlyHint: ToBoolPtr(true),
1818
}),
1919
mcp.WithString("reason",
2020
mcp.Description("Optional: the reason for requesting the user information"),

pkg/github/dynamic_tools.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ func EnableToolset(s *server.MCPServer, toolsetGroup *toolsets.ToolsetGroup, t t
2525
mcp.WithToolAnnotation(mcp.ToolAnnotation{
2626
Title: t("TOOL_ENABLE_TOOLSET_USER_TITLE", "Enable a toolset"),
2727
// Not modifying GitHub data so no need to show a warning
28-
ReadOnlyHint: toBoolPtr(true),
28+
ReadOnlyHint: ToBoolPtr(true),
2929
}),
3030
mcp.WithString("toolset",
3131
mcp.Required(),
@@ -35,7 +35,7 @@ func EnableToolset(s *server.MCPServer, toolsetGroup *toolsets.ToolsetGroup, t t
3535
),
3636
func(_ context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
3737
// We need to convert the toolsets back to a map for JSON serialization
38-
toolsetName, err := requiredParam[string](request, "toolset")
38+
toolsetName, err := RequiredParam[string](request, "toolset")
3939
if err != nil {
4040
return mcp.NewToolResultError(err.Error()), nil
4141
}
@@ -64,7 +64,7 @@ func ListAvailableToolsets(toolsetGroup *toolsets.ToolsetGroup, t translations.T
6464
mcp.WithDescription(t("TOOL_LIST_AVAILABLE_TOOLSETS_DESCRIPTION", "List all available toolsets this GitHub MCP server can offer, providing the enabled status of each. Use this when a task could be achieved with a GitHub tool and the currently available tools aren't enough. Call get_toolset_tools with these toolset names to discover specific tools you can call")),
6565
mcp.WithToolAnnotation(mcp.ToolAnnotation{
6666
Title: t("TOOL_LIST_AVAILABLE_TOOLSETS_USER_TITLE", "List available toolsets"),
67-
ReadOnlyHint: toBoolPtr(true),
67+
ReadOnlyHint: ToBoolPtr(true),
6868
}),
6969
),
7070
func(_ context.Context, _ mcp.CallToolRequest) (*mcp.CallToolResult, error) {
@@ -98,7 +98,7 @@ func GetToolsetsTools(toolsetGroup *toolsets.ToolsetGroup, t translations.Transl
9898
mcp.WithDescription(t("TOOL_GET_TOOLSET_TOOLS_DESCRIPTION", "Lists all the capabilities that are enabled with the specified toolset, use this to get clarity on whether enabling a toolset would help you to complete a task")),
9999
mcp.WithToolAnnotation(mcp.ToolAnnotation{
100100
Title: t("TOOL_GET_TOOLSET_TOOLS_USER_TITLE", "List all tools in a toolset"),
101-
ReadOnlyHint: toBoolPtr(true),
101+
ReadOnlyHint: ToBoolPtr(true),
102102
}),
103103
mcp.WithString("toolset",
104104
mcp.Required(),
@@ -108,7 +108,7 @@ func GetToolsetsTools(toolsetGroup *toolsets.ToolsetGroup, t translations.Transl
108108
),
109109
func(_ context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
110110
// We need to convert the toolsetGroup back to a map for JSON serialization
111-
toolsetName, err := requiredParam[string](request, "toolset")
111+
toolsetName, err := RequiredParam[string](request, "toolset")
112112
if err != nil {
113113
return mcp.NewToolResultError(err.Error()), nil
114114
}

pkg/github/issues.go

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ func GetIssue(getClient GetClientFn, t translations.TranslationHelperFunc) (tool
2323
mcp.WithDescription(t("TOOL_GET_ISSUE_DESCRIPTION", "Get details of a specific issue in a GitHub repository.")),
2424
mcp.WithToolAnnotation(mcp.ToolAnnotation{
2525
Title: t("TOOL_GET_ISSUE_USER_TITLE", "Get issue details"),
26-
ReadOnlyHint: toBoolPtr(true),
26+
ReadOnlyHint: ToBoolPtr(true),
2727
}),
2828
mcp.WithString("owner",
2929
mcp.Required(),
@@ -39,11 +39,11 @@ func GetIssue(getClient GetClientFn, t translations.TranslationHelperFunc) (tool
3939
),
4040
),
4141
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
42-
owner, err := requiredParam[string](request, "owner")
42+
owner, err := RequiredParam[string](request, "owner")
4343
if err != nil {
4444
return mcp.NewToolResultError(err.Error()), nil
4545
}
46-
repo, err := requiredParam[string](request, "repo")
46+
repo, err := RequiredParam[string](request, "repo")
4747
if err != nil {
4848
return mcp.NewToolResultError(err.Error()), nil
4949
}
@@ -85,7 +85,7 @@ func AddIssueComment(getClient GetClientFn, t translations.TranslationHelperFunc
8585
mcp.WithDescription(t("TOOL_ADD_ISSUE_COMMENT_DESCRIPTION", "Add a comment to a specific issue in a GitHub repository.")),
8686
mcp.WithToolAnnotation(mcp.ToolAnnotation{
8787
Title: t("TOOL_ADD_ISSUE_COMMENT_USER_TITLE", "Add comment to issue"),
88-
ReadOnlyHint: toBoolPtr(false),
88+
ReadOnlyHint: ToBoolPtr(false),
8989
}),
9090
mcp.WithString("owner",
9191
mcp.Required(),
@@ -105,19 +105,19 @@ func AddIssueComment(getClient GetClientFn, t translations.TranslationHelperFunc
105105
),
106106
),
107107
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
108-
owner, err := requiredParam[string](request, "owner")
108+
owner, err := RequiredParam[string](request, "owner")
109109
if err != nil {
110110
return mcp.NewToolResultError(err.Error()), nil
111111
}
112-
repo, err := requiredParam[string](request, "repo")
112+
repo, err := RequiredParam[string](request, "repo")
113113
if err != nil {
114114
return mcp.NewToolResultError(err.Error()), nil
115115
}
116116
issueNumber, err := RequiredInt(request, "issue_number")
117117
if err != nil {
118118
return mcp.NewToolResultError(err.Error()), nil
119119
}
120-
body, err := requiredParam[string](request, "body")
120+
body, err := RequiredParam[string](request, "body")
121121
if err != nil {
122122
return mcp.NewToolResultError(err.Error()), nil
123123
}
@@ -159,7 +159,7 @@ func SearchIssues(getClient GetClientFn, t translations.TranslationHelperFunc) (
159159
mcp.WithDescription(t("TOOL_SEARCH_ISSUES_DESCRIPTION", "Search for issues in GitHub repositories.")),
160160
mcp.WithToolAnnotation(mcp.ToolAnnotation{
161161
Title: t("TOOL_SEARCH_ISSUES_USER_TITLE", "Search issues"),
162-
ReadOnlyHint: toBoolPtr(true),
162+
ReadOnlyHint: ToBoolPtr(true),
163163
}),
164164
mcp.WithString("q",
165165
mcp.Required(),
@@ -188,7 +188,7 @@ func SearchIssues(getClient GetClientFn, t translations.TranslationHelperFunc) (
188188
WithPagination(),
189189
),
190190
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
191-
query, err := requiredParam[string](request, "q")
191+
query, err := RequiredParam[string](request, "q")
192192
if err != nil {
193193
return mcp.NewToolResultError(err.Error()), nil
194194
}
@@ -247,7 +247,7 @@ func CreateIssue(getClient GetClientFn, t translations.TranslationHelperFunc) (t
247247
mcp.WithDescription(t("TOOL_CREATE_ISSUE_DESCRIPTION", "Create a new issue in a GitHub repository.")),
248248
mcp.WithToolAnnotation(mcp.ToolAnnotation{
249249
Title: t("TOOL_CREATE_ISSUE_USER_TITLE", "Open new issue"),
250-
ReadOnlyHint: toBoolPtr(false),
250+
ReadOnlyHint: ToBoolPtr(false),
251251
}),
252252
mcp.WithString("owner",
253253
mcp.Required(),
@@ -285,15 +285,15 @@ func CreateIssue(getClient GetClientFn, t translations.TranslationHelperFunc) (t
285285
),
286286
),
287287
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
288-
owner, err := requiredParam[string](request, "owner")
288+
owner, err := RequiredParam[string](request, "owner")
289289
if err != nil {
290290
return mcp.NewToolResultError(err.Error()), nil
291291
}
292-
repo, err := requiredParam[string](request, "repo")
292+
repo, err := RequiredParam[string](request, "repo")
293293
if err != nil {
294294
return mcp.NewToolResultError(err.Error()), nil
295295
}
296-
title, err := requiredParam[string](request, "title")
296+
title, err := RequiredParam[string](request, "title")
297297
if err != nil {
298298
return mcp.NewToolResultError(err.Error()), nil
299299
}
@@ -369,7 +369,7 @@ func ListIssues(getClient GetClientFn, t translations.TranslationHelperFunc) (to
369369
mcp.WithDescription(t("TOOL_LIST_ISSUES_DESCRIPTION", "List issues in a GitHub repository.")),
370370
mcp.WithToolAnnotation(mcp.ToolAnnotation{
371371
Title: t("TOOL_LIST_ISSUES_USER_TITLE", "List issues"),
372-
ReadOnlyHint: toBoolPtr(true),
372+
ReadOnlyHint: ToBoolPtr(true),
373373
}),
374374
mcp.WithString("owner",
375375
mcp.Required(),
@@ -405,11 +405,11 @@ func ListIssues(getClient GetClientFn, t translations.TranslationHelperFunc) (to
405405
WithPagination(),
406406
),
407407
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
408-
owner, err := requiredParam[string](request, "owner")
408+
owner, err := RequiredParam[string](request, "owner")
409409
if err != nil {
410410
return mcp.NewToolResultError(err.Error()), nil
411411
}
412-
repo, err := requiredParam[string](request, "repo")
412+
repo, err := RequiredParam[string](request, "repo")
413413
if err != nil {
414414
return mcp.NewToolResultError(err.Error()), nil
415415
}
@@ -491,7 +491,7 @@ func UpdateIssue(getClient GetClientFn, t translations.TranslationHelperFunc) (t
491491
mcp.WithDescription(t("TOOL_UPDATE_ISSUE_DESCRIPTION", "Update an existing issue in a GitHub repository.")),
492492
mcp.WithToolAnnotation(mcp.ToolAnnotation{
493493
Title: t("TOOL_UPDATE_ISSUE_USER_TITLE", "Edit issue"),
494-
ReadOnlyHint: toBoolPtr(false),
494+
ReadOnlyHint: ToBoolPtr(false),
495495
}),
496496
mcp.WithString("owner",
497497
mcp.Required(),
@@ -536,11 +536,11 @@ func UpdateIssue(getClient GetClientFn, t translations.TranslationHelperFunc) (t
536536
),
537537
),
538538
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
539-
owner, err := requiredParam[string](request, "owner")
539+
owner, err := RequiredParam[string](request, "owner")
540540
if err != nil {
541541
return mcp.NewToolResultError(err.Error()), nil
542542
}
543-
repo, err := requiredParam[string](request, "repo")
543+
repo, err := RequiredParam[string](request, "repo")
544544
if err != nil {
545545
return mcp.NewToolResultError(err.Error()), nil
546546
}
@@ -637,7 +637,7 @@ func GetIssueComments(getClient GetClientFn, t translations.TranslationHelperFun
637637
mcp.WithDescription(t("TOOL_GET_ISSUE_COMMENTS_DESCRIPTION", "Get comments for a specific issue in a GitHub repository.")),
638638
mcp.WithToolAnnotation(mcp.ToolAnnotation{
639639
Title: t("TOOL_GET_ISSUE_COMMENTS_USER_TITLE", "Get issue comments"),
640-
ReadOnlyHint: toBoolPtr(true),
640+
ReadOnlyHint: ToBoolPtr(true),
641641
}),
642642
mcp.WithString("owner",
643643
mcp.Required(),
@@ -659,11 +659,11 @@ func GetIssueComments(getClient GetClientFn, t translations.TranslationHelperFun
659659
),
660660
),
661661
func(ctx context.Context, request mcp.CallToolRequest) (*mcp.CallToolResult, error) {
662-
owner, err := requiredParam[string](request, "owner")
662+
owner, err := RequiredParam[string](request, "owner")
663663
if err != nil {
664664
return mcp.NewToolResultError(err.Error()), nil
665665
}
666-
repo, err := requiredParam[string](request, "repo")
666+
repo, err := RequiredParam[string](request, "repo")
667667
if err != nil {
668668
return mcp.NewToolResultError(err.Error()), nil
669669
}
@@ -759,8 +759,8 @@ func AssignCopilotToIssue(getGQLClient GetGQLClientFn, t translations.Translatio
759759
mcp.WithDescription(t("TOOL_ASSIGN_COPILOT_TO_ISSUE_DESCRIPTION", description.String())),
760760
mcp.WithToolAnnotation(mcp.ToolAnnotation{
761761
Title: t("TOOL_ASSIGN_COPILOT_TO_ISSUE_USER_TITLE", "Assign Copilot to issue"),
762-
ReadOnlyHint: toBoolPtr(false),
763-
IdempotentHint: toBoolPtr(true),
762+
ReadOnlyHint: ToBoolPtr(false),
763+
IdempotentHint: ToBoolPtr(true),
764764
}),
765765
mcp.WithString("owner",
766766
mcp.Required(),

0 commit comments

Comments
 (0)