MCPcopy Index your code
hub / github.com/github/github-mcp-server / GetMe

Function GetMe

pkg/github/context_tools.go:45–113  ·  view source on GitHub ↗

GetMe creates a tool to get details of the authenticated user.

(t translations.TranslationHelperFunc)

Source from the content-addressed store, hash-verified

43
44// GetMe creates a tool to get details of the authenticated user.
45func GetMe(t translations.TranslationHelperFunc) inventory.ServerTool {
46 return NewTool(
47 ToolsetMetadataContext,
48 mcp.Tool{
49 Name: "get_me",
50 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."),
51 Annotations: &mcp.ToolAnnotations{
52 Title: t("TOOL_GET_ME_USER_TITLE", "Get my user profile"),
53 ReadOnlyHint: true,
54 },
55 // Use json.RawMessage to ensure "properties" is included even when empty.
56 // OpenAI strict mode requires the properties field to be present.
57 InputSchema: json.RawMessage(`{"type":"object","properties":{}}`),
58 Meta: mcp.Meta{
59 "ui": map[string]any{
60 "resourceUri": GetMeUIResourceURI,
61 "visibility": []string{"model", "app"},
62 },
63 },
64 },
65 nil,
66 func(ctx context.Context, deps ToolDependencies, _ *mcp.CallToolRequest, _ map[string]any) (*mcp.CallToolResult, any, error) {
67 client, err := deps.GetClient(ctx)
68 if err != nil {
69 return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, nil
70 }
71
72 user, res, err := client.Users.Get(ctx, "")
73 if err != nil {
74 return ghErrors.NewGitHubAPIErrorResponse(ctx,
75 "failed to get user",
76 res,
77 err,
78 ), nil, nil
79 }
80
81 // Create minimal user representation instead of returning full user object
82 minimalUser := MinimalUser{
83 Login: user.GetLogin(),
84 ID: user.GetID(),
85 ProfileURL: user.GetHTMLURL(),
86 AvatarURL: user.GetAvatarURL(),
87 Details: &UserDetails{
88 Name: user.GetName(),
89 Company: user.GetCompany(),
90 Blog: user.GetBlog(),
91 Location: user.GetLocation(),
92 Email: user.GetEmail(),
93 Hireable: user.GetHireable(),
94 Bio: user.GetBio(),
95 TwitterUsername: user.GetTwitterUsername(),
96 PublicRepos: user.GetPublicRepos(),
97 PublicGists: user.GetPublicGists(),
98 Followers: user.GetFollowers(),
99 Following: user.GetFollowing(),
100 CreatedAt: user.GetCreatedAt().Time,
101 UpdatedAt: user.GetUpdatedAt().Time,
102 PrivateGists: user.GetPrivateGists(),

Callers 3

AllToolsFunction · 0.85
Test_GetMeFunction · 0.85

Calls 6

LabelGetMeFunction · 0.92
NewToolFunction · 0.85
MarshalledTextResultFunction · 0.85
attachStaticIFCLabelFunction · 0.85
GetClientMethod · 0.65

Tested by 2

Test_GetMeFunction · 0.68