Skip to content

Commit 6308b1e

Browse files
Remove deprecated NewServerToolFromHandler function
- Removed NewServerToolFromHandler function from pkg/inventory/server_tool.go - Updated test helper functions (mockTool and mockToolWithDefault) to use NewServerToolWithRawContextHandler - All tests pass successfully Co-authored-by: SamMorrowDrums <4811358+SamMorrowDrums@users.noreply.github.com>
1 parent 1c06ad5 commit 6308b1e

File tree

2 files changed

+6
-19
lines changed

2 files changed

+6
-19
lines changed

pkg/inventory/registry_test.go

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func testToolsetMetadataWithDefault(id string, isDefault bool) ToolsetMetadata {
2828

2929
// mockToolWithDefault creates a mock tool with a default toolset flag
3030
func mockToolWithDefault(name string, toolsetID string, readOnly bool, isDefault bool) ServerTool {
31-
return NewServerToolFromHandler(
31+
return NewServerToolWithRawContextHandler(
3232
mcp.Tool{
3333
Name: name,
3434
Annotations: &mcp.ToolAnnotations{
@@ -37,17 +37,15 @@ func mockToolWithDefault(name string, toolsetID string, readOnly bool, isDefault
3737
InputSchema: json.RawMessage(`{"type":"object","properties":{}}`),
3838
},
3939
testToolsetMetadataWithDefault(toolsetID, isDefault),
40-
func(_ any) mcp.ToolHandler {
41-
return func(_ context.Context, _ *mcp.CallToolRequest) (*mcp.CallToolResult, error) {
42-
return nil, nil
43-
}
40+
func(_ context.Context, _ *mcp.CallToolRequest) (*mcp.CallToolResult, error) {
41+
return nil, nil
4442
},
4543
)
4644
}
4745

4846
// mockTool creates a minimal ServerTool for testing
4947
func mockTool(name string, toolsetID string, readOnly bool) ServerTool {
50-
return NewServerToolFromHandler(
48+
return NewServerToolWithRawContextHandler(
5149
mcp.Tool{
5250
Name: name,
5351
Annotations: &mcp.ToolAnnotations{
@@ -56,10 +54,8 @@ func mockTool(name string, toolsetID string, readOnly bool) ServerTool {
5654
InputSchema: json.RawMessage(`{"type":"object","properties":{}}`),
5755
},
5856
testToolsetMetadata(toolsetID),
59-
func(_ any) mcp.ToolHandler {
60-
return func(_ context.Context, _ *mcp.CallToolRequest) (*mcp.CallToolResult, error) {
61-
return nil, nil
62-
}
57+
func(_ context.Context, _ *mcp.CallToolRequest) (*mcp.CallToolResult, error) {
58+
return nil, nil
6359
},
6460
)
6561
}

pkg/inventory/server_tool.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -163,15 +163,6 @@ func NewServerToolWithContextHandler[In any, Out any](tool mcp.Tool, toolset Too
163163
}
164164
}
165165

166-
// NewServerToolFromHandler creates a ServerTool from a tool definition, toolset metadata, and a raw handler function.
167-
// Use this when you have a handler that already conforms to mcp.ToolHandler.
168-
//
169-
// Deprecated: This creates closures at registration time. For better performance in
170-
// per-request server scenarios, use NewServerToolWithRawContextHandler instead.
171-
func NewServerToolFromHandler(tool mcp.Tool, toolset ToolsetMetadata, handlerFn func(deps any) mcp.ToolHandler) ServerTool {
172-
return ServerTool{Tool: tool, Toolset: toolset, HandlerFunc: handlerFn}
173-
}
174-
175166
// NewServerToolWithRawContextHandler creates a ServerTool with a raw handler that receives deps via context.
176167
// This is the preferred approach for tools that use mcp.ToolHandler directly because it doesn't
177168
// create closures at registration time.

0 commit comments

Comments
 (0)