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

Commit6c97ac4

Browse files
committed
fixup! add WithCleanContext middleware func
1 parent7226330 commit6c97ac4

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

‎cli/exp_mcp.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -713,8 +713,8 @@ func mcpFromSDK(sdkTool toolsdk.Tool[any, any], tb toolsdk.Deps) server.ServerTo
713713
Required:sdkTool.Schema.Required,
714714
},
715715
},
716-
Handler:func(_ context.Context,request mcp.CallToolRequest) (*mcp.CallToolResult,error) {
717-
result,err:=sdkTool.Handler(tb,request.Params.Arguments)
716+
Handler:func(ctx context.Context,request mcp.CallToolRequest) (*mcp.CallToolResult,error) {
717+
result,err:=sdkTool.Handler(ctx,tb,request.Params.Arguments)
718718
iferr!=nil {
719719
returnnil,err
720720
}

‎codersdk/toolsdk/toolsdk.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ type Deps struct {
2121
}
2222

2323
// HandlerFunc is a function that handles a tool call.
24-
typeHandlerFunc[Arg,Retany]func(tbDeps,argsArg) (Ret,error)
24+
typeHandlerFunc[Arg,Retany]func(context.Context,Deps,Arg) (Ret,error)
2525

2626
typeTool[Arg,Retany]struct {
2727
aisdk.Tool
@@ -32,12 +32,12 @@ type Tool[Arg, Ret any] struct {
3232
func (tTool[Arg,Ret])Generic()Tool[any,any] {
3333
returnTool[any,any]{
3434
Tool:t.Tool,
35-
Handler:func(tbDeps,argsany) (any,error) {
35+
Handler:func(ctx context.Context,tbDeps,argsany) (any,error) {
3636
typedArg,ok:=args.(Arg)
3737
if!ok {
3838
returnnil,xerrors.Errorf("developer error: invalid argument type for tool %s",t.Tool.Name)
3939
}
40-
returnt.Handler(tb,typedArg)
40+
returnt.Handler(ctx,tb,typedArg)
4141
},
4242
}
4343
}
@@ -165,7 +165,7 @@ func wrapAll(mw func(HandlerFunc[any, any]) HandlerFunc[any, any], tools ...Tool
165165
var (
166166
// All is a list of all tools that can be used in the Coder CLI.
167167
// When you add a new tool, be sure to include it here!
168-
All=wrapAll(WithRecover,
168+
All=wrapAll(WithCleanContext,wrapAll(WithRecover,
169169
CreateTemplate.Generic(),
170170
CreateTemplateVersion.Generic(),
171171
CreateWorkspace.Generic(),
@@ -182,7 +182,7 @@ var (
182182
ReportTask.Generic(),
183183
UploadTarFile.Generic(),
184184
UpdateTemplateActiveVersion.Generic(),
185-
)
185+
)...)
186186

187187
ReportTask=Tool[ReportTaskArgs,string]{
188188
Tool: aisdk.Tool{

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp