package mcp

import (
	
	
)

// TypedToolHandlerFunc is a function that handles a tool call with typed arguments
type TypedToolHandlerFunc[ any] func(ctx context.Context, request CallToolRequest, args ) (*CallToolResult, error)

// StructuredToolHandlerFunc is a function that handles a tool call with typed arguments and returns structured output
type StructuredToolHandlerFunc[ any,  any] func(ctx context.Context, request CallToolRequest, args ) (, error)

// NewTypedToolHandler creates a ToolHandlerFunc that automatically binds arguments to a typed struct
func [ any]( TypedToolHandlerFunc[]) func( context.Context,  CallToolRequest) (*CallToolResult, error) {
	return func( context.Context,  CallToolRequest) (*CallToolResult, error) {
		var  
		if  := .BindArguments(&);  != nil {
			return NewToolResultError(fmt.Sprintf("failed to bind arguments: %v", )), nil
		}
		return (, , )
	}
}

// NewStructuredToolHandler creates a ToolHandlerFunc that automatically binds arguments to a typed struct
// and returns structured output. It automatically creates both structured and
// text content (from the structured output) for backwards compatibility.
func [ any,  any]( StructuredToolHandlerFunc[, ]) func( context.Context,  CallToolRequest) (*CallToolResult, error) {
	return func( context.Context,  CallToolRequest) (*CallToolResult, error) {
		var  
		if  := .BindArguments(&);  != nil {
			return NewToolResultError(fmt.Sprintf("failed to bind arguments: %v", )), nil
		}

		,  := (, , )
		if  != nil {
			return NewToolResultError(fmt.Sprintf("tool execution failed: %v", )), nil
		}

		return NewToolResultStructuredOnly(), nil
	}
}