Commit b2b2257
Adam Bloomston
feat: add optional strict parameter to registerTool for Zod validation
Add strict parameter to registerTool config that defaults to false for
backward compatibility. When strict=true, applies .strict() to Zod
schema creation for tool input validation to throw errors on unknown
parameters instead of silently ignoring them.
- Add strict?: boolean to registerTool config interface
- Modify _createRegisteredTool to accept and use strict parameter
- Apply z.object(inputSchema).strict() when strict=true
- Update legacy tool() method to pass strict=false (backward compatibility)
- Update test to verify strict validation rejects unknown parameters
- All existing tests continue to pass (no breaking changes)
This fixes the issue where parameter name typos are silently dropped,
leading to confusing behavior where tools execute with missing data.1 parent 5e2dbcd commit b2b2257
2 files changed
+46
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4125 | 4125 | | |
4126 | 4126 | | |
4127 | 4127 | | |
| 4128 | + | |
| 4129 | + | |
| 4130 | + | |
| 4131 | + | |
| 4132 | + | |
| 4133 | + | |
| 4134 | + | |
| 4135 | + | |
| 4136 | + | |
| 4137 | + | |
| 4138 | + | |
| 4139 | + | |
| 4140 | + | |
| 4141 | + | |
| 4142 | + | |
| 4143 | + | |
| 4144 | + | |
| 4145 | + | |
| 4146 | + | |
| 4147 | + | |
| 4148 | + | |
| 4149 | + | |
| 4150 | + | |
| 4151 | + | |
| 4152 | + | |
| 4153 | + | |
| 4154 | + | |
| 4155 | + | |
| 4156 | + | |
| 4157 | + | |
| 4158 | + | |
| 4159 | + | |
| 4160 | + | |
| 4161 | + | |
| 4162 | + | |
| 4163 | + | |
| 4164 | + | |
| 4165 | + | |
| 4166 | + | |
| 4167 | + | |
4128 | 4168 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
647 | 647 | | |
648 | 648 | | |
649 | 649 | | |
| 650 | + | |
650 | 651 | | |
651 | 652 | | |
652 | 653 | | |
653 | 654 | | |
654 | 655 | | |
655 | 656 | | |
656 | | - | |
| 657 | + | |
657 | 658 | | |
658 | 659 | | |
659 | 660 | | |
| |||
780 | 781 | | |
781 | 782 | | |
782 | 783 | | |
783 | | - | |
| 784 | + | |
784 | 785 | | |
785 | 786 | | |
786 | 787 | | |
| |||
794 | 795 | | |
795 | 796 | | |
796 | 797 | | |
| 798 | + | |
797 | 799 | | |
798 | 800 | | |
799 | 801 | | |
| |||
802 | 804 | | |
803 | 805 | | |
804 | 806 | | |
805 | | - | |
| 807 | + | |
806 | 808 | | |
807 | 809 | | |
808 | 810 | | |
| |||
811 | 813 | | |
812 | 814 | | |
813 | 815 | | |
| 816 | + | |
814 | 817 | | |
815 | 818 | | |
816 | 819 | | |
| |||
0 commit comments