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

Commitf197a9f

Browse files
omgitsadsalmaleksiaSamMorrowDrums
authored
Add Tool Handler shim to RegisterFunc (#1536)
* Add tool handler shim to use server.AddTool instead of mcp.AddTool---Co-authored-by: Ksenia Bobrova <almaleksia@github.com>Co-authored-by: Sam Morrow <SamMorrowDrums@github.com>
1 parent8dac9b1 commitf197a9f

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

‎pkg/github/__toolsnaps__/get_me.snap‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
"title":"Get my user profile"
55
},
66
"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.",
7-
"inputSchema":null,
7+
"inputSchema": {
8+
"type":"object"
9+
},
810
"name":"get_me"
911
}

‎pkg/github/context_tools.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ func GetMe(getClient GetClientFn, t translations.TranslationHelperFunc) (mcp.Too
4343
Title:t("TOOL_GET_ME_USER_TITLE","Get my user profile"),
4444
ReadOnlyHint:true,
4545
},
46+
InputSchema:&jsonschema.Schema{
47+
Type:"object",
48+
},
4649
},
4750
mcp.ToolHandlerFor[map[string]any,any](func(ctx context.Context,_*mcp.CallToolRequest,_map[string]any) (*mcp.CallToolResult,any,error) {
4851
client,err:=getClient(ctx)

‎pkg/toolsets/toolsets.go‎

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package toolsets
22

33
import (
4+
"context"
5+
"encoding/json"
46
"fmt"
57
"os"
68
"strings"
@@ -35,9 +37,20 @@ type ServerTool struct {
3537
RegisterFuncfunc(s*mcp.Server)
3638
}
3739

38-
funcNewServerTool[In,Outany](tool mcp.Tool,handler mcp.ToolHandlerFor[In,Out])ServerTool {
40+
funcNewServerTool[Inany,Outany](tool mcp.Tool,handler mcp.ToolHandlerFor[In,Out])ServerTool {
3941
returnServerTool{Tool:tool,RegisterFunc:func(s*mcp.Server) {
40-
mcp.AddTool(s,&tool,handler)
42+
th:=func(ctx context.Context,req*mcp.CallToolRequest) (*mcp.CallToolResult,error) {
43+
varargumentsIn
44+
iferr:=json.Unmarshal(req.Params.Arguments,&arguments);err!=nil {
45+
returnnil,err
46+
}
47+
48+
resp,_,err:=handler(ctx,req,arguments)
49+
50+
returnresp,err
51+
}
52+
53+
s.AddTool(&tool,th)
4154
}}
4255
}
4356

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp