NewServerTool creates a ServerTool with a raw handler that receives deps via context. This is the preferred constructor for tools that use mcp.ToolHandler directly because it doesn't create closures at registration time, which is critical for performance in servers that create a new instance per req
(tool mcp.Tool, toolset ToolsetMetadata, handler mcp.ToolHandler)
| 156 | // The handler function is stored directly without wrapping in a deps closure. |
| 157 | // Dependencies should be injected into context before calling tool handlers. |
| 158 | func NewServerTool(tool mcp.Tool, toolset ToolsetMetadata, handler mcp.ToolHandler) ServerTool { |
| 159 | return ServerTool{ |
| 160 | Tool: tool, |
| 161 | Toolset: toolset, |
| 162 | // HandlerFunc ignores deps - deps are retrieved from context at call time |
| 163 | HandlerFunc: func(_ any) mcp.ToolHandler { |
| 164 | return handler |
| 165 | }, |
| 166 | } |
| 167 | } |
no outgoing calls