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

Migrate gists toolset to modelcontextprotocol/go-sdk#1431

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
omgitsads merged 9 commits intoomgitsads/go-sdkfromcopilot/migrate-gists-toolset
Nov 19, 2025
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletioncmd/github-mcp-server/generate_docs.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -225,8 +225,12 @@ func generateToolDoc(tool mcp.Tool) string {
lines = append(lines, fmt.Sprintf("- **%s** - %s", tool.Name, tool.Annotations.Title))

// Parameters
if tool.InputSchema == nil {
lines = append(lines, " - No parameters required")
return strings.Join(lines, "\n")
}
schema, ok := tool.InputSchema.(*jsonschema.Schema)
if !ok {
if !ok|| schema == nil{
lines = append(lines, " - No parameters required")
return strings.Join(lines, "\n")
}
Expand Down
33 changes: 33 additions & 0 deletionspkg/github/__toolsnaps__/create_gist.snap
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
{
"annotations": {
"title": "Create Gist"
},
"description": "Create a new gist",
"inputSchema": {
"type": "object",
"required": [
"filename",
"content"
],
"properties": {
"content": {
"type": "string",
"description": "Content for simple single-file gist creation"
},
"description": {
"type": "string",
"description": "Description of the gist"
},
"filename": {
"type": "string",
"description": "Filename for simple single-file gist creation"
},
"public": {
"type": "boolean",
"description": "Whether the gist is public",
"default": false
}
}
},
"name": "create_gist"
}
20 changes: 20 additions & 0 deletionspkg/github/__toolsnaps__/get_gist.snap
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
{
"annotations": {
"readOnlyHint": true,
"title": "Get Gist Content"
},
"description": "Get gist content of a particular gist, by gist ID",
"inputSchema": {
"type": "object",
"required": [
"gist_id"
],
"properties": {
"gist_id": {
"type": "string",
"description": "The ID of the gist"
}
}
},
"name": "get_gist"
}
32 changes: 32 additions & 0 deletionspkg/github/__toolsnaps__/list_gists.snap
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
{
"annotations": {
"readOnlyHint": true,
"title": "List Gists"
},
"description": "List gists for a user",
"inputSchema": {
"type": "object",
"properties": {
"page": {
"type": "number",
"description": "Page number for pagination (min 1)",
"minimum": 1
},
"perPage": {
"type": "number",
"description": "Results per page for pagination (min 1, max 100)",
"minimum": 1,
"maximum": 100
},
"since": {
"type": "string",
"description": "Only gists updated after this time (ISO 8601 timestamp)"
},
"username": {
"type": "string",
"description": "GitHub username (omit for authenticated user's gists)"
}
}
},
"name": "list_gists"
}
33 changes: 33 additions & 0 deletionspkg/github/__toolsnaps__/update_gist.snap
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
{
"annotations": {
"title": "Update Gist"
},
"description": "Update an existing gist",
"inputSchema": {
"type": "object",
"required": [
"gist_id",
"filename",
"content"
],
"properties": {
"content": {
"type": "string",
"description": "Content for the file"
},
"description": {
"type": "string",
"description": "Updated description of the gist"
},
"filename": {
"type": "string",
"description": "Filename to update or create"
},
"gist_id": {
"type": "string",
"description": "ID of the gist to update"
}
}
},
"name": "update_gist"
}
99 changes: 48 additions & 51 deletionspkg/github/context_tools.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -36,61 +36,58 @@ type UserDetails struct {

// GetMe creates a tool to get details of the authenticated user.
func GetMe(getClient GetClientFn, t translations.TranslationHelperFunc) (mcp.Tool, mcp.ToolHandlerFor[map[string]any, any]) {
tool := mcp.Tool{
Name: "get_me",
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."),
Annotations: &mcp.ToolAnnotations{
Title: t("TOOL_GET_ME_USER_TITLE", "Get my user profile"),
ReadOnlyHint: true,
return mcp.Tool{
Name: "get_me",
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."),
Annotations: &mcp.ToolAnnotations{
Title: t("TOOL_GET_ME_USER_TITLE", "Get my user profile"),
ReadOnlyHint: true,
},
},
}

handler := mcp.ToolHandlerFor[map[string]any, any](func(ctx context.Context, _ *mcp.CallToolRequest, _ map[string]any) (*mcp.CallToolResult, any, error) {
client, err := getClient(ctx)
if err != nil {
return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, err
}

user, res, err := client.Users.Get(ctx, "")
if err != nil {
return ghErrors.NewGitHubAPIErrorResponse(ctx,
"failed to get user",
res,
err,
), nil, err
}
mcp.ToolHandlerFor[map[string]any, any](func(ctx context.Context, _ *mcp.CallToolRequest, _ map[string]any) (*mcp.CallToolResult, any, error) {
client, err := getClient(ctx)
if err != nil {
return utils.NewToolResultErrorFromErr("failed to get GitHub client", err), nil, err
}

// Create minimal user representation instead of returning full user object
minimalUser := MinimalUser{
Login: user.GetLogin(),
ID: user.GetID(),
ProfileURL: user.GetHTMLURL(),
AvatarURL: user.GetAvatarURL(),
Details: &UserDetails{
Name: user.GetName(),
Company: user.GetCompany(),
Blog: user.GetBlog(),
Location: user.GetLocation(),
Email: user.GetEmail(),
Hireable: user.GetHireable(),
Bio: user.GetBio(),
TwitterUsername: user.GetTwitterUsername(),
PublicRepos: user.GetPublicRepos(),
PublicGists: user.GetPublicGists(),
Followers: user.GetFollowers(),
Following: user.GetFollowing(),
CreatedAt: user.GetCreatedAt().Time,
UpdatedAt: user.GetUpdatedAt().Time,
PrivateGists: user.GetPrivateGists(),
TotalPrivateRepos: user.GetTotalPrivateRepos(),
OwnedPrivateRepos: user.GetOwnedPrivateRepos(),
},
}
user, res, err := client.Users.Get(ctx, "")
if err != nil {
return ghErrors.NewGitHubAPIErrorResponse(ctx,
"failed to get user",
res,
err,
), nil, err
}

return MarshalledTextResult(minimalUser), nil, nil
})
// Create minimal user representation instead of returning full user object
minimalUser := MinimalUser{
Login: user.GetLogin(),
ID: user.GetID(),
ProfileURL: user.GetHTMLURL(),
AvatarURL: user.GetAvatarURL(),
Details: &UserDetails{
Name: user.GetName(),
Company: user.GetCompany(),
Blog: user.GetBlog(),
Location: user.GetLocation(),
Email: user.GetEmail(),
Hireable: user.GetHireable(),
Bio: user.GetBio(),
TwitterUsername: user.GetTwitterUsername(),
PublicRepos: user.GetPublicRepos(),
PublicGists: user.GetPublicGists(),
Followers: user.GetFollowers(),
Following: user.GetFollowing(),
CreatedAt: user.GetCreatedAt().Time,
UpdatedAt: user.GetUpdatedAt().Time,
PrivateGists: user.GetPrivateGists(),
TotalPrivateRepos: user.GetTotalPrivateRepos(),
OwnedPrivateRepos: user.GetOwnedPrivateRepos(),
},
}

return tool, handler
return MarshalledTextResult(minimalUser), nil, nil
})
}

type TeamInfo struct {
Expand Down
Loading
Loading

[8]ページ先頭

©2009-2025 Movatter.jp