Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
16 changes: 6 additions & 10 deletions pkg/inventory/registry_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func testToolsetMetadataWithDefault(id string, isDefault bool) ToolsetMetadata {

// mockToolWithDefault creates a mock tool with a default toolset flag
func mockToolWithDefault(name string, toolsetID string, readOnly bool, isDefault bool) ServerTool {
return NewServerToolFromHandler(
return NewServerToolWithRawContextHandler(
mcp.Tool{
Name: name,
Annotations: &mcp.ToolAnnotations{
Expand All @@ -37,17 +37,15 @@ func mockToolWithDefault(name string, toolsetID string, readOnly bool, isDefault
InputSchema: json.RawMessage(`{"type":"object","properties":{}}`),
},
testToolsetMetadataWithDefault(toolsetID, isDefault),
func(_ any) mcp.ToolHandler {
return func(_ context.Context, _ *mcp.CallToolRequest) (*mcp.CallToolResult, error) {
return nil, nil
}
func(_ context.Context, _ *mcp.CallToolRequest) (*mcp.CallToolResult, error) {
return nil, nil
},
)
}

// mockTool creates a minimal ServerTool for testing
func mockTool(name string, toolsetID string, readOnly bool) ServerTool {
return NewServerToolFromHandler(
return NewServerToolWithRawContextHandler(
mcp.Tool{
Name: name,
Annotations: &mcp.ToolAnnotations{
Expand All @@ -56,10 +54,8 @@ func mockTool(name string, toolsetID string, readOnly bool) ServerTool {
InputSchema: json.RawMessage(`{"type":"object","properties":{}}`),
},
testToolsetMetadata(toolsetID),
func(_ any) mcp.ToolHandler {
return func(_ context.Context, _ *mcp.CallToolRequest) (*mcp.CallToolResult, error) {
return nil, nil
}
func(_ context.Context, _ *mcp.CallToolRequest) (*mcp.CallToolResult, error) {
return nil, nil
},
)
}
Expand Down
9 changes: 0 additions & 9 deletions pkg/inventory/server_tool.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,15 +163,6 @@ func NewServerToolWithContextHandler[In any, Out any](tool mcp.Tool, toolset Too
}
}

// NewServerToolFromHandler creates a ServerTool from a tool definition, toolset metadata, and a raw handler function.
// Use this when you have a handler that already conforms to mcp.ToolHandler.
//
// Deprecated: This creates closures at registration time. For better performance in
// per-request server scenarios, use NewServerToolWithRawContextHandler instead.
func NewServerToolFromHandler(tool mcp.Tool, toolset ToolsetMetadata, handlerFn func(deps any) mcp.ToolHandler) ServerTool {
return ServerTool{Tool: tool, Toolset: toolset, HandlerFunc: handlerFn}
}

// NewServerToolWithRawContextHandler creates a ServerTool with a raw handler that receives deps via context.
// This is the preferred approach for tools that use mcp.ToolHandler directly because it doesn't
// create closures at registration time.
Expand Down
Loading