@@ -96,26 +96,37 @@ func GetMe(getClient GetClientFn, t translations.TranslationHelperFunc) (mcp.Too
96
96
func GetMyTeams (getClient GetClientFn , getGQLClient GetGQLClientFn , t translations.TranslationHelperFunc ) (mcp.Tool , server.ToolHandlerFunc ) {
97
97
tool := mcp .NewTool ("get_my_teams" ,
98
98
mcp .WithDescription (t ("TOOL_GET_MY_TEAMS_DESCRIPTION" , "Get details of the teams the authenticated user is a member of." )),
99
+ mcp .WithString ("user" ,
100
+ mcp .Description (t ("TOOL_GET_MY_TEAMS_USER_DESCRIPTION" , "Username to get teams for. If not provided, uses the authenticated user." )),
101
+ ),
99
102
mcp .WithToolAnnotation (mcp.ToolAnnotation {
100
103
Title : t ("TOOL_GET_MY_TEAMS_TITLE" , "Get my teams" ),
101
104
ReadOnlyHint : ToBoolPtr (true ),
102
105
}),
103
106
)
104
107
105
- type args struct {}
106
- handler := mcp .NewTypedToolHandler (func (ctx context.Context , _ mcp.CallToolRequest , _ args ) (* mcp.CallToolResult , error ) {
107
- client , err := getClient (ctx )
108
- if err != nil {
109
- return mcp .NewToolResultErrorFromErr ("failed to get GitHub client" , err ), nil
110
- }
111
-
112
- user , res , err := client .Users .Get (ctx , "" )
113
- if err != nil {
114
- return ghErrors .NewGitHubAPIErrorResponse (ctx ,
115
- "failed to get user" ,
116
- res ,
117
- err ,
118
- ), nil
108
+ type args struct {
109
+ User * string `json:"user,omitempty"`
110
+ }
111
+ handler := mcp .NewTypedToolHandler (func (ctx context.Context , _ mcp.CallToolRequest , a args ) (* mcp.CallToolResult , error ) {
112
+ var username string
113
+ if a .User != nil && * a .User != "" {
114
+ username = * a .User
115
+ } else {
116
+ client , err := getClient (ctx )
117
+ if err != nil {
118
+ return mcp .NewToolResultErrorFromErr ("failed to get GitHub client" , err ), nil
119
+ }
120
+
121
+ user , res , err := client .Users .Get (ctx , "" )
122
+ if err != nil {
123
+ return ghErrors .NewGitHubAPIErrorResponse (ctx ,
124
+ "failed to get user" ,
125
+ res ,
126
+ err ,
127
+ ), nil
128
+ }
129
+ username = user .GetLogin ()
119
130
}
120
131
121
132
gqlClient , err := getGQLClient (ctx )
@@ -140,7 +151,7 @@ func GetMyTeams(getClient GetClientFn, getGQLClient GetGQLClientFn, t translatio
140
151
} `graphql:"user(login: $login)"`
141
152
}
142
153
vars := map [string ]interface {}{
143
- "login" : githubv4 .String (user . GetLogin () ),
154
+ "login" : githubv4 .String (username ),
144
155
}
145
156
if err := gqlClient .Query (ctx , & q , vars ); err != nil {
146
157
return mcp .NewToolResultError (err .Error ()), nil
0 commit comments