@@ -3,6 +3,7 @@ package github
33import (
44 "context"
55 "encoding/base64"
6+ "errors"
67 "mime"
78 "path/filepath"
89 "strings"
@@ -60,30 +61,41 @@ func getRepositoryResourcePrContent(client *github.Client, t translations.Transl
6061
6162func repositoryResourceContentsHandler (client * github.Client ) func (ctx context.Context , request mcp.ReadResourceRequest ) ([]mcp.ResourceContents , error ) {
6263 return func (ctx context.Context , request mcp.ReadResourceRequest ) ([]mcp.ResourceContents , error ) {
64+ // the matcher will give []string with one elemenent
65+ // https://github.com/mark3labs/mcp-go/pull/54
66+ o , ok := request .Params .Arguments ["owner" ].([]string )
67+ if ! ok || len (o ) == 0 {
68+ return nil , errors .New ("owner is required" )
69+ }
70+ owner := o [0 ]
71+
72+ r , ok := request .Params .Arguments ["repo" ].([]string )
73+ if ! ok || len (r ) == 0 {
74+ return nil , errors .New ("repo is required" )
75+ }
76+ repo := r [0 ]
6377
64- owner := request .Params .Arguments ["owner" ].([]string )[0 ]
65- repo := request .Params .Arguments ["repo" ].([]string )[0 ]
6678 // path should be a joined list of the path parts
6779 path := strings .Join (request .Params .Arguments ["path" ].([]string ), "/" )
6880
6981 opts := & github.RepositoryContentGetOptions {}
7082
7183 sha , ok := request .Params .Arguments ["sha" ].([]string )
72- if ok {
84+ if ok && len ( sha ) > 0 {
7385 opts .Ref = sha [0 ]
7486 }
7587
7688 branch , ok := request .Params .Arguments ["branch" ].([]string )
77- if ok {
89+ if ok && len ( branch ) > 0 {
7890 opts .Ref = "refs/heads/" + branch [0 ]
7991 }
8092
8193 tag , ok := request .Params .Arguments ["tag" ].([]string )
82- if ok {
94+ if ok && len ( tag ) > 0 {
8395 opts .Ref = "refs/tags/" + tag [0 ]
8496 }
8597 prNumber , ok := request .Params .Arguments ["pr_number" ].([]string )
86- if ok {
98+ if ok && len ( prNumber ) > 0 {
8799 opts .Ref = "refs/pull/" + prNumber [0 ] + "/head"
88100 }
89101
0 commit comments