@@ -604,76 +604,95 @@ func ParseArgument(request CallToolRequest, key string, defaultVal any) any {
604
604
}
605
605
}
606
606
607
+ // ParseBoolean extracts and converts a boolean parameter from a CallToolRequest.
608
+ // If the key is not found in the Arguments map, the defaultValue is returned.
609
+ // The function uses cast.ToBool for conversion which handles various string representations
610
+ // such as "true", "yes", "1", etc.
607
611
func ParseBoolean (request CallToolRequest , key string , defaultValue bool ) bool {
608
612
v := ParseArgument (request , key , defaultValue )
609
613
return cast .ToBool (v )
610
614
}
611
615
616
+ // ParseInt64 extracts and converts an int64 parameter from a CallToolRequest.
617
+ // If the key is not found in the Arguments map, the defaultValue is returned.
612
618
func ParseInt64 (request CallToolRequest , key string , defaultValue int64 ) int64 {
613
619
v := ParseArgument (request , key , defaultValue )
614
620
return cast .ToInt64 (v )
615
621
}
616
622
623
+ // ParseInt32 extracts and converts an int32 parameter from a CallToolRequest.
617
624
func ParseInt32 (request CallToolRequest , key string , defaultValue int32 ) int32 {
618
625
v := ParseArgument (request , key , defaultValue )
619
626
return cast .ToInt32 (v )
620
627
}
621
628
629
+ // ParseInt16 extracts and converts an int16 parameter from a CallToolRequest.
622
630
func ParseInt16 (request CallToolRequest , key string , defaultValue int16 ) int16 {
623
631
v := ParseArgument (request , key , defaultValue )
624
632
return cast .ToInt16 (v )
625
633
}
626
634
635
+ // ParseInt8 extracts and converts an int8 parameter from a CallToolRequest.
627
636
func ParseInt8 (request CallToolRequest , key string , defaultValue int8 ) int8 {
628
637
v := ParseArgument (request , key , defaultValue )
629
638
return cast .ToInt8 (v )
630
639
}
631
640
641
+ // ParseInt extracts and converts an int parameter from a CallToolRequest.
632
642
func ParseInt (request CallToolRequest , key string , defaultValue int ) int {
633
643
v := ParseArgument (request , key , defaultValue )
634
644
return cast .ToInt (v )
635
645
}
636
646
647
+ // ParseUInt extracts and converts an uint parameter from a CallToolRequest.
637
648
func ParseUInt (request CallToolRequest , key string , defaultValue uint ) uint {
638
649
v := ParseArgument (request , key , defaultValue )
639
650
return cast .ToUint (v )
640
651
}
641
652
653
+ // ParseUInt64 extracts and converts an uint64 parameter from a CallToolRequest.
642
654
func ParseUInt64 (request CallToolRequest , key string , defaultValue uint64 ) uint64 {
643
655
v := ParseArgument (request , key , defaultValue )
644
656
return cast .ToUint64 (v )
645
657
}
646
658
659
+ // ParseUInt32 extracts and converts an uint32 parameter from a CallToolRequest.
647
660
func ParseUInt32 (request CallToolRequest , key string , defaultValue uint32 ) uint32 {
648
661
v := ParseArgument (request , key , defaultValue )
649
662
return cast .ToUint32 (v )
650
663
}
651
664
665
+ // ParseUInt16 extracts and converts an uint16 parameter from a CallToolRequest.
652
666
func ParseUInt16 (request CallToolRequest , key string , defaultValue uint16 ) uint16 {
653
667
v := ParseArgument (request , key , defaultValue )
654
668
return cast .ToUint16 (v )
655
669
}
656
670
671
+ // ParseUInt8 extracts and converts an uint8 parameter from a CallToolRequest.
657
672
func ParseUInt8 (request CallToolRequest , key string , defaultValue uint8 ) uint8 {
658
673
v := ParseArgument (request , key , defaultValue )
659
674
return cast .ToUint8 (v )
660
675
}
661
676
677
+ // ParseFloat32 extracts and converts a float32 parameter from a CallToolRequest.
662
678
func ParseFloat32 (request CallToolRequest , key string , defaultValue float32 ) float32 {
663
679
v := ParseArgument (request , key , defaultValue )
664
680
return cast .ToFloat32 (v )
665
681
}
666
682
683
+ // ParseFloat64 extracts and converts a float64 parameter from a CallToolRequest.
667
684
func ParseFloat64 (request CallToolRequest , key string , defaultValue float64 ) float64 {
668
685
v := ParseArgument (request , key , defaultValue )
669
686
return cast .ToFloat64 (v )
670
687
}
671
688
689
+ // ParseString extracts and converts a string parameter from a CallToolRequest.
672
690
func ParseString (request CallToolRequest , key string , defaultValue string ) string {
673
691
v := ParseArgument (request , key , defaultValue )
674
692
return cast .ToString (v )
675
693
}
676
694
695
+ // ParseStringMap extracts and converts a string map parameter from a CallToolRequest.
677
696
func ParseStringMap (request CallToolRequest , key string , defaultValue map [string ]any ) map [string ]any {
678
697
v := ParseArgument (request , key , defaultValue )
679
698
return cast .ToStringMap (v )
0 commit comments