Skip to content

Commit 1286e06

Browse files
committed
just return the tool & handler
1 parent b1ac345 commit 1286e06

File tree

1 file changed

+48
-51
lines changed

1 file changed

+48
-51
lines changed

pkg/github/context_tools.go

Lines changed: 48 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -36,61 +36,58 @@ type UserDetails struct {
3636

3737
// GetMe creates a tool to get details of the authenticated user.
3838
func GetMe(getClient GetClientFn, t translations.TranslationHelperFunc) (mcp.Tool, mcp.ToolHandlerFor[map[string]any, any]) {
39-
tool := mcp.Tool{
40-
Name: "get_me",
41-
Description: t("TOOL_GET_ME_DESCRIPTION", "Get details of the authenticated GitHub user. Use this when a request is about the user's own profile for GitHub. Or when information is missing to build other tool calls."),
42-
Annotations: &mcp.ToolAnnotations{
43-
Title: t("TOOL_GET_ME_USER_TITLE", "Get my user profile"),
44-
ReadOnlyHint: true,
39+
return mcp.Tool{
40+
Name: "get_me",
41+
Description: t("TOOL_GET_ME_DESCRIPTION", "Get details of the authenticated GitHub user. Use this when a request is about the user's own profile for GitHub. Or when information is missing to build other tool calls."),
42+
Annotations: &mcp.ToolAnnotations{
43+
Title: t("TOOL_GET_ME_USER_TITLE", "Get my user profile"),
44+
ReadOnlyHint: true,
45+
},
4546
},
46-
}
47-
48-
handler := mcp.ToolHandlerFor[map[string]any, any](func(ctx context.Context, _ *mcp.CallToolRequest, _ map[string]any) (*mcp.CallToolResult, any, error) {
49-
client, err := getClient(ctx)
50-
if err != nil {
51-
return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, err
52-
}
53-
54-
user, res, err := client.Users.Get(ctx, "")
55-
if err != nil {
56-
return ghErrors.NewGitHubAPIErrorResponse(ctx,
57-
"failed to get user",
58-
res,
59-
err,
60-
), nil, err
61-
}
47+
mcp.ToolHandlerFor[map[string]any, any](func(ctx context.Context, _ *mcp.CallToolRequest, _ map[string]any) (*mcp.CallToolResult, any, error) {
48+
client, err := getClient(ctx)
49+
if err != nil {
50+
return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, err
51+
}
6252

63-
// Create minimal user representation instead of returning full user object
64-
minimalUser := MinimalUser{
65-
Login: user.GetLogin(),
66-
ID: user.GetID(),
67-
ProfileURL: user.GetHTMLURL(),
68-
AvatarURL: user.GetAvatarURL(),
69-
Details: &UserDetails{
70-
Name: user.GetName(),
71-
Company: user.GetCompany(),
72-
Blog: user.GetBlog(),
73-
Location: user.GetLocation(),
74-
Email: user.GetEmail(),
75-
Hireable: user.GetHireable(),
76-
Bio: user.GetBio(),
77-
TwitterUsername: user.GetTwitterUsername(),
78-
PublicRepos: user.GetPublicRepos(),
79-
PublicGists: user.GetPublicGists(),
80-
Followers: user.GetFollowers(),
81-
Following: user.GetFollowing(),
82-
CreatedAt: user.GetCreatedAt().Time,
83-
UpdatedAt: user.GetUpdatedAt().Time,
84-
PrivateGists: user.GetPrivateGists(),
85-
TotalPrivateRepos: user.GetTotalPrivateRepos(),
86-
OwnedPrivateRepos: user.GetOwnedPrivateRepos(),
87-
},
88-
}
53+
user, res, err := client.Users.Get(ctx, "")
54+
if err != nil {
55+
return ghErrors.NewGitHubAPIErrorResponse(ctx,
56+
"failed to get user",
57+
res,
58+
err,
59+
), nil, err
60+
}
8961

90-
return MarshalledTextResult(minimalUser), nil, nil
91-
})
62+
// Create minimal user representation instead of returning full user object
63+
minimalUser := MinimalUser{
64+
Login: user.GetLogin(),
65+
ID: user.GetID(),
66+
ProfileURL: user.GetHTMLURL(),
67+
AvatarURL: user.GetAvatarURL(),
68+
Details: &UserDetails{
69+
Name: user.GetName(),
70+
Company: user.GetCompany(),
71+
Blog: user.GetBlog(),
72+
Location: user.GetLocation(),
73+
Email: user.GetEmail(),
74+
Hireable: user.GetHireable(),
75+
Bio: user.GetBio(),
76+
TwitterUsername: user.GetTwitterUsername(),
77+
PublicRepos: user.GetPublicRepos(),
78+
PublicGists: user.GetPublicGists(),
79+
Followers: user.GetFollowers(),
80+
Following: user.GetFollowing(),
81+
CreatedAt: user.GetCreatedAt().Time,
82+
UpdatedAt: user.GetUpdatedAt().Time,
83+
PrivateGists: user.GetPrivateGists(),
84+
TotalPrivateRepos: user.GetTotalPrivateRepos(),
85+
OwnedPrivateRepos: user.GetOwnedPrivateRepos(),
86+
},
87+
}
9288

93-
return tool, handler
89+
return MarshalledTextResult(minimalUser), nil, nil
90+
})
9491
}
9592

9693
type TeamInfo struct {

0 commit comments

Comments
 (0)