Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 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
4 changes: 3 additions & 1 deletion pkg/github/__toolsnaps__/get_me.snap
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"title": "Get my user profile"
},
"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.",
"inputSchema": null,
"inputSchema": {
"type": "object"
},
"name": "get_me"
}
3 changes: 3 additions & 0 deletions pkg/github/context_tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ func GetMe(getClient GetClientFn, t translations.TranslationHelperFunc) (mcp.Too
Title: t("TOOL_GET_ME_USER_TITLE", "Get my user profile"),
ReadOnlyHint: true,
},
InputSchema: &jsonschema.Schema{
Type: "object",
},
},
mcp.ToolHandlerFor[map[string]any, any](func(ctx context.Context, _ *mcp.CallToolRequest, _ map[string]any) (*mcp.CallToolResult, any, error) {
client, err := getClient(ctx)
Expand Down
20 changes: 18 additions & 2 deletions pkg/toolsets/toolsets.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package toolsets

import (
"context"
"encoding/json"
"fmt"
"os"
"strings"
Expand Down Expand Up @@ -35,9 +37,23 @@ type ServerTool struct {
RegisterFunc func(s *mcp.Server)
}

func NewServerTool[In, Out any](tool mcp.Tool, handler mcp.ToolHandlerFor[In, Out]) ServerTool {
func NewServerTool[In any, Out any](tool mcp.Tool, handler mcp.ToolHandlerFor[In, Out]) ServerTool {
return ServerTool{Tool: tool, RegisterFunc: func(s *mcp.Server) {
mcp.AddTool(s, &tool, handler)
th := func(ctx context.Context, req *mcp.CallToolRequest) (*mcp.CallToolResult, error) {
var arguments In
if err := json.Unmarshal(req.Params.Arguments, &arguments); err != nil {
return nil, err
}

resp, _, err := handler(ctx, req, arguments)
if err != nil {
return nil, err
}

return resp, err
}

s.AddTool(&tool, th)
}}
}

Expand Down