Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.23.7

require (
github.com/google/go-github/v69 v69.2.0
github.com/mark3labs/mcp-go v0.11.2
github.com/mark3labs/mcp-go v0.13.0
github.com/sirupsen/logrus v1.9.3
github.com/spf13/cobra v1.9.1
github.com/spf13/viper v1.19.0
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0V
github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0=
github.com/mark3labs/mcp-go v0.11.2 h1:mCxWFUTrcXOtJIn9t7F8bxAL8rpE/ZZTTnx3PU/VNdA=
github.com/mark3labs/mcp-go v0.11.2/go.mod h1:cjMlBU0cv/cj9kjlgmRhoJ5JREdS7YX83xeIG9Ko/jE=
github.com/mark3labs/mcp-go v0.13.0 h1:HP+cJaE9KjWufUF9FxN/XgcXE6LVSebFZLiZYPmFbGU=
github.com/mark3labs/mcp-go v0.13.0/go.mod h1:cjMlBU0cv/cj9kjlgmRhoJ5JREdS7YX83xeIG9Ko/jE=
github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY=
github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo=
github.com/pelletier/go-toml/v2 v2.2.2 h1:aYUidT7k73Pcl9nb2gScu7NSrKCSHIDE89b3+6Wq+LM=
Expand Down
48 changes: 48 additions & 0 deletions pkg/github/prompts.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package github

import (
"context"
"encoding/json"
"fmt"

"github.com/google/go-github/v69/github"
"github.com/mark3labs/mcp-go/mcp"
"github.com/mark3labs/mcp-go/server"
)

func NewMePrompt(client *github.Client) (mcp.Prompt, server.PromptHandlerFunc) {
prompt := mcp.NewPrompt("github_me", mcp.WithPromptDescription("GitHub Prompt"))
prompt.Arguments = []mcp.PromptArgument{}

return prompt, func(ctx context.Context, request mcp.GetPromptRequest) (*mcp.GetPromptResult, error) {
user, resp, err := client.Users.Get(ctx, "")
if err != nil {
return nil, fmt.Errorf("failed to get user: %w", err)
}
defer func() { _ = resp.Body.Close() }()

if resp.StatusCode != 200 {
return nil, fmt.Errorf("failed to read response body: %w", err)
}

r, err := json.Marshal(user)
if err != nil {
return nil, fmt.Errorf("failed to marshal user: %w", err)
}

return &mcp.GetPromptResult{
Description: "Your GitHub Identity",
Messages: []mcp.PromptMessage{
{
Role: mcp.RoleUser,
Content: mcp.TextContent{
Type: "text",
Text: string(r),
},
},
},
}, nil

}

}
6 changes: 6 additions & 0 deletions pkg/github/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ func NewServer(client *github.Client) *server.MCPServer {
"github-mcp-server",
"0.0.1",
server.WithResourceCapabilities(true, true),
server.WithPromptCapabilities(true),
server.WithToolCapabilities(true),
server.WithLogging())

// Add GitHub tools - Issues
Expand Down Expand Up @@ -51,6 +53,10 @@ func NewServer(client *github.Client) *server.MCPServer {
// Add GitHub tools - Users
s.AddTool(getMe(client))

// Add github_me prompt handler
prompt, handler := NewMePrompt(client)
s.AddPrompt(prompt, handler)

return s
}

Expand Down