You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: multi validation errors handling for MCP tools (#15)
* ref: convert float64 to int64 instead of int to prevent precision loss and ensure consistent behavior across platforms
* feat: collect validation errors for tools
* chore: improve error handling and code formatting
* chore: revert int to int64 conversion
* ref: implement fluent validation pattern for razorpay tools
* fix: lint errors
* ref: improve validation error handling pattern across API tools
* fix: define the error handler func
Copy file name to clipboardExpand all lines: .cursor/rules/new-tool-from-docs.mdc
+27-14
Original file line number
Diff line number
Diff line change
@@ -59,10 +59,10 @@ Upon receiving this rule invocation:
59
59
60
60
Before the implementation use the documentation URL provided to figure out the request contract, required parameters, descriptions of the parameters, and the response contract.
61
61
62
-
Now follow the detailed implementation guide in [pkg/razorpay/README.md](../pkg/razorpay/README.md) for creating tools and start making code changes.
62
+
Now follow the detailed implementation guide in [pkg/razorpay/README.md](mdc:../pkg/razorpay/README.md) for creating tools and start making code changes.
63
63
64
64
Other guidelines:
65
-
1. [Razorpay Go SDK Constants](https://github.com/razorpay/razorpay-go/blob/master/constants/url.go) - Use these constants for specifying the api endpoints while writing the tests.
65
+
1. [Razorpay Go SDK Constants](mdc:https:/github.com/razorpay/razorpay-go/blob/master/constants/url.go) - Use these constants for specifying the api endpoints while writing the tests.
66
66
2. Use the payload and response from the docs provided to write the positive test case for the tool.
67
67
68
68
STYLE:
@@ -72,7 +72,7 @@ IMPORTANT: You **MUST** ALWAYS go through the Post Implementation steps once the
72
72
73
73
## Implementation References
74
74
75
-
For detailed code patterns and examples, refer to the following sections in the [pkg/razorpay/README.md](../pkg/razorpay/README.md):
75
+
For detailed code patterns and examples, refer to the following sections in the [pkg/razorpay/README.md](mdc:../pkg/razorpay/README.md):
76
76
77
77
- **Tool Structure**: See the "Tool Structure" section for the function template
78
78
- **Parameter Definition**: See the "Parameter Definition" section for defining parameters
@@ -160,7 +160,7 @@ If any checklist items remain unchecked, complete them before proceeding. The im
160
160
Your tests MUST include:
161
161
- Positive test case with all parameters
162
162
- Negative test case for EACH required parameter
163
-
- Negative test case for validation failures (e.g., wrong types)
163
+
- Negative test case for multiple validation failures (e.g., wrong types)
164
164
- Any edge cases specific to this tool
165
165
166
166
## ⚠️ Required Verification Steps ⚠️
@@ -192,16 +192,29 @@ Contains all Razorpay API tool implementations, including:
192
192
- Parameter validation functions
193
193
- Request/response handling
194
194
195
-
### `pkg/razorpay/server.go` - Core Utilities
196
-
197
-
**Path:** `pkg/razorpay/server.go`
198
-
199
-
Contains essential utility functions used by all tools:
Copy file name to clipboardExpand all lines: pkg/razorpay/README.md
+55-51
Original file line number
Diff line number
Diff line change
@@ -79,32 +79,31 @@ Available parameter types:
79
79
80
80
### Parameter Validation
81
81
82
-
Inside the handler function, use the helper functions for fetching the parameters and also enforcing the mandatory parameters:
82
+
Inside the handler function, use the fluent validator pattern for parameter validation. This provides cleaner, more readable code through method chaining:
83
83
84
84
```go
85
-
// Required parameters
86
-
id, err:=RequiredParam[string](r, "id")
87
-
ifresult, err:=HandleValidationError(err); result != nil {
0 commit comments