Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite43fca1

Browse files
LuluBeatsonSamMorrowDrums
authored andcommitted
embed optional UserDetails in MinimalUser
1 parent1d057c9 commite43fca1

File tree

3 files changed

+69
-13
lines changed

3 files changed

+69
-13
lines changed

‎pkg/github/context_tools.go

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,36 @@ package github
22

33
import (
44
"context"
5+
"time"
56

67
ghErrors"github.com/github/github-mcp-server/pkg/errors"
78
"github.com/github/github-mcp-server/pkg/translations"
89
"github.com/mark3labs/mcp-go/mcp"
910
"github.com/mark3labs/mcp-go/server"
1011
)
1112

13+
// UserDetails contains additional fields about a GitHub user not already
14+
// present in MinimalUser. Used by get_me context tool but omitted from search_users.
15+
typeUserDetailsstruct {
16+
Namestring`json:"name,omitempty"`
17+
Companystring`json:"company,omitempty"`
18+
Blogstring`json:"blog,omitempty"`
19+
Locationstring`json:"location,omitempty"`
20+
Emailstring`json:"email,omitempty"`
21+
Hireablebool`json:"hireable,omitempty"`
22+
Biostring`json:"bio,omitempty"`
23+
TwitterUsernamestring`json:"twitter_username,omitempty"`
24+
PublicReposint`json:"public_repos"`
25+
PublicGistsint`json:"public_gists"`
26+
Followersint`json:"followers"`
27+
Followingint`json:"following"`
28+
CreatedAt time.Time`json:"created_at"`
29+
UpdatedAt time.Time`json:"updated_at"`
30+
PrivateGistsint`json:"private_gists,omitempty"`
31+
TotalPrivateReposint64`json:"total_private_repos,omitempty"`
32+
OwnedPrivateReposint64`json:"owned_private_repos,omitempty"`
33+
}
34+
1235
// GetMe creates a tool to get details of the authenticated user.
1336
funcGetMe(getClientGetClientFn,t translations.TranslationHelperFunc) (mcp.Tool, server.ToolHandlerFunc) {
1437
tool:=mcp.NewTool("get_me",
@@ -44,6 +67,25 @@ func GetMe(getClient GetClientFn, t translations.TranslationHelperFunc) (mcp.Too
4467
ID:user.GetID(),
4568
ProfileURL:user.GetHTMLURL(),
4669
AvatarURL:user.GetAvatarURL(),
70+
Details:&UserDetails{
71+
Name:user.GetName(),
72+
Company:user.GetCompany(),
73+
Blog:user.GetBlog(),
74+
Location:user.GetLocation(),
75+
Email:user.GetEmail(),
76+
Hireable:user.GetHireable(),
77+
Bio:user.GetBio(),
78+
TwitterUsername:user.GetTwitterUsername(),
79+
PublicRepos:user.GetPublicRepos(),
80+
PublicGists:user.GetPublicGists(),
81+
Followers:user.GetFollowers(),
82+
Following:user.GetFollowing(),
83+
CreatedAt:user.GetCreatedAt().Time,
84+
UpdatedAt:user.GetUpdatedAt().Time,
85+
PrivateGists:user.GetPrivateGists(),
86+
TotalPrivateRepos:user.GetTotalPrivateRepos(),
87+
OwnedPrivateRepos:user.GetOwnedPrivateRepos(),
88+
},
4789
}
4890

4991
returnMarshalledTextResult(minimalUser),nil

‎pkg/github/context_tools_test.go

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,17 @@ func Test_GetMe(t *testing.T) {
2626

2727
// Setup mock user response
2828
mockUser:=&github.User{
29-
Login:github.Ptr("testuser"),
30-
Name:github.Ptr("Test User"),
31-
Email:github.Ptr("test@example.com"),
32-
Bio:github.Ptr("GitHub user for testing"),
33-
Company:github.Ptr("Test Company"),
34-
Location:github.Ptr("Test Location"),
35-
HTMLURL:github.Ptr("https://github.com/testuser"),
36-
CreatedAt:&github.Timestamp{Time:time.Now().Add(-365*24*time.Hour)},
37-
Type:github.Ptr("User"),
29+
Login:github.Ptr("testuser"),
30+
Name:github.Ptr("Test User"),
31+
Email:github.Ptr("test@example.com"),
32+
Bio:github.Ptr("GitHub user for testing"),
33+
Company:github.Ptr("Test Company"),
34+
Location:github.Ptr("Test Location"),
35+
HTMLURL:github.Ptr("https://github.com/testuser"),
36+
CreatedAt:&github.Timestamp{Time:time.Now().Add(-365*24*time.Hour)},
37+
Type:github.Ptr("User"),
38+
Hireable:github.Ptr(true),
39+
TwitterUsername:github.Ptr("testuser_twitter"),
3840
Plan:&github.Plan{
3941
Name:github.Ptr("pro"),
4042
},
@@ -124,6 +126,16 @@ func Test_GetMe(t *testing.T) {
124126
// Verify minimal user details
125127
assert.Equal(t,*tc.expectedUser.Login,returnedUser.Login)
126128
assert.Equal(t,*tc.expectedUser.HTMLURL,returnedUser.ProfileURL)
129+
130+
// Verify user details
131+
require.NotNil(t,returnedUser.Details)
132+
assert.Equal(t,*tc.expectedUser.Name,returnedUser.Details.Name)
133+
assert.Equal(t,*tc.expectedUser.Email,returnedUser.Details.Email)
134+
assert.Equal(t,*tc.expectedUser.Bio,returnedUser.Details.Bio)
135+
assert.Equal(t,*tc.expectedUser.Company,returnedUser.Details.Company)
136+
assert.Equal(t,*tc.expectedUser.Location,returnedUser.Details.Location)
137+
assert.Equal(t,*tc.expectedUser.Hireable,returnedUser.Details.Hireable)
138+
assert.Equal(t,*tc.expectedUser.TwitterUsername,returnedUser.Details.TwitterUsername)
127139
})
128140
}
129141
}

‎pkg/github/search.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,13 @@ func SearchCode(getClient GetClientFn, t translations.TranslationHelperFunc) (to
155155
}
156156
}
157157

158+
// MinimalUser is the output type for user and organization search results.
158159
typeMinimalUserstruct {
159-
Loginstring`json:"login"`
160-
IDint64`json:"id,omitempty"`
161-
ProfileURLstring`json:"profile_url,omitempty"`
162-
AvatarURLstring`json:"avatar_url,omitempty"`
160+
Loginstring`json:"login"`
161+
IDint64`json:"id,omitempty"`
162+
ProfileURLstring`json:"profile_url,omitempty"`
163+
AvatarURLstring`json:"avatar_url,omitempty"`
164+
Details*UserDetails`json:"details,omitempty"`// Optional field for additional user details
163165
}
164166

165167
typeMinimalSearchUsersResultstruct {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp