@@ -11,7 +11,6 @@ import (
1111 "github.com/github/github-mcp-server/pkg/scopes"
1212 "github.com/github/github-mcp-server/pkg/translations"
1313 "github.com/github/github-mcp-server/pkg/utils"
14- "github.com/go-viper/mapstructure/v2"
1514 "github.com/google/go-github/v89/github"
1615 "github.com/google/jsonschema-go/jsonschema"
1716 "github.com/modelcontextprotocol/go-sdk/mcp"
@@ -313,15 +312,19 @@ func GetDiscussion(t translations.TranslationHelperFunc) inventory.ServerTool {
313312 },
314313 []scopes.Scope {scopes .Repo },
315314 func (ctx context.Context , deps ToolDependencies , _ * mcp.CallToolRequest , args map [string ]any ) (* mcp.CallToolResult , any , error ) {
316- // Decode params
317- var params struct {
318- Owner string
319- Repo string
320- DiscussionNumber int32
315+ owner , err := RequiredParam [string ](args , "owner" )
316+ if err != nil {
317+ return utils .NewToolResultError (err .Error ()), nil , nil
321318 }
322- if err := mapstructure .WeakDecode (args , & params ); err != nil {
319+ repo , err := RequiredParam [string ](args , "repo" )
320+ if err != nil {
323321 return utils .NewToolResultError (err .Error ()), nil , nil
324322 }
323+ discussionNumber , err := RequiredInt (args , "discussionNumber" )
324+ if err != nil {
325+ return utils .NewToolResultError (err .Error ()), nil , nil
326+ }
327+
325328 client , err := deps .GetGQLClient (ctx )
326329 if err != nil {
327330 return utils .NewToolResultError (fmt .Sprintf ("failed to get GitHub GQL client: %v" , err )), nil , nil
@@ -345,9 +348,9 @@ func GetDiscussion(t translations.TranslationHelperFunc) inventory.ServerTool {
345348 } `graphql:"repository(owner: $owner, name: $repo)"`
346349 }
347350 vars := map [string ]any {
348- "owner" : githubv4 .String (params . Owner ),
349- "repo" : githubv4 .String (params . Repo ),
350- "discussionNumber" : githubv4 .Int (params . DiscussionNumber ),
351+ "owner" : githubv4 .String (owner ),
352+ "repo" : githubv4 .String (repo ),
353+ "discussionNumber" : githubv4 .Int (discussionNumber ),
351354 }
352355 if err := client .Query (ctx , & q , vars ); err != nil {
353356 return utils .NewToolResultError (err .Error ()), nil , nil
@@ -384,7 +387,7 @@ func GetDiscussion(t translations.TranslationHelperFunc) inventory.ServerTool {
384387 result := utils .NewToolResultText (string (out ))
385388 // Discussion content is user-authored (untrusted); confidentiality
386389 // follows repo visibility.
387- result = attachRepoVisibilityIFCLabelLazy (ctx , deps , params . Owner , params . Repo , result , ifc .LabelRepoUserContent )
390+ result = attachRepoVisibilityIFCLabelLazy (ctx , deps , owner , repo , result , ifc .LabelRepoUserContent )
388391 return result , nil , nil
389392 },
390393 )
@@ -425,13 +428,16 @@ func GetDiscussionComments(t translations.TranslationHelperFunc) inventory.Serve
425428 },
426429 []scopes.Scope {scopes .Repo },
427430 func (ctx context.Context , deps ToolDependencies , _ * mcp.CallToolRequest , args map [string ]any ) (* mcp.CallToolResult , any , error ) {
428- // Decode params
429- var params struct {
430- Owner string
431- Repo string
432- DiscussionNumber int32
431+ owner , err := RequiredParam [string ](args , "owner" )
432+ if err != nil {
433+ return utils .NewToolResultError (err .Error ()), nil , nil
434+ }
435+ repo , err := RequiredParam [string ](args , "repo" )
436+ if err != nil {
437+ return utils .NewToolResultError (err .Error ()), nil , nil
433438 }
434- if err := mapstructure .WeakDecode (args , & params ); err != nil {
439+ discussionNumber , err := RequiredInt (args , "discussionNumber" )
440+ if err != nil {
435441 return utils .NewToolResultError (err .Error ()), nil , nil
436442 }
437443
@@ -467,9 +473,9 @@ func GetDiscussionComments(t translations.TranslationHelperFunc) inventory.Serve
467473 }
468474
469475 vars := map [string ]any {
470- "owner" : githubv4 .String (params . Owner ),
471- "repo" : githubv4 .String (params . Repo ),
472- "discussionNumber" : githubv4 .Int (params . DiscussionNumber ),
476+ "owner" : githubv4 .String (owner ),
477+ "repo" : githubv4 .String (repo ),
478+ "discussionNumber" : githubv4 .Int (discussionNumber ),
473479 "first" : githubv4 .Int (* paginationParams .First ),
474480 }
475481 if paginationParams .After != nil {
@@ -592,7 +598,7 @@ func GetDiscussionComments(t translations.TranslationHelperFunc) inventory.Serve
592598 result := utils .NewToolResultText (string (out ))
593599 // Discussion comments are user-authored (untrusted); confidentiality
594600 // follows repo visibility.
595- result = attachRepoVisibilityIFCLabelLazy (ctx , deps , params . Owner , params . Repo , result , ifc .LabelRepoUserContent )
601+ result = attachRepoVisibilityIFCLabelLazy (ctx , deps , owner , repo , result , ifc .LabelRepoUserContent )
596602 return result , nil , nil
597603 },
598604 )
0 commit comments