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
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
+
62
+
Now follow the detailed implementation guide in [pkg/razorpay/README.md](../pkg/razorpay/README.md) for creating tools and start making code changes.
63
+
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.
66
+
2. Use the payload and response from the docs provided to write the positive test case for the tool.
67
+
68
+
STYLE:
69
+
Look at the linters and linter settings in the .golangci.yaml file and make sure to follow the same style while coding.
70
+
71
+
IMPORTANT: You **MUST** ALWAYS go through the Post Implementation steps once the code changes are done.
72
+
73
+
## Implementation References
74
+
75
+
For detailed code patterns and examples, refer to the following sections in the [pkg/razorpay/README.md](../pkg/razorpay/README.md):
76
+
77
+
- **Tool Structure**: See the "Tool Structure" section for the function template
78
+
- **Parameter Definition**: See the "Parameter Definition" section for defining parameters
79
+
- **Parameter Validation**: See the "Parameter Validation" section for validation examples
80
+
- **Example GET/POST Endpoints**: See the example sections for complete implementation patterns
81
+
- **Unit Testing**: See the "Writing Unit Tests" section for test patterns and best practices
82
+
83
+
## ⚠️ Common Issues & Troubleshooting ⚠️
84
+
85
+
### 1. Query Parameters in Mock Tests
86
+
87
+
The `mock.Endpoint` struct does NOT have a queryParams field:
88
+
89
+
```go
90
+
type Endpoint struct {
91
+
Path string
92
+
Method string
93
+
Response interface{}
94
+
}
95
+
```
96
+
97
+
### 1. Query Parameter Limitations in Mock Tests
98
+
99
+
The mock server doesn't validate query parameters. When testing endpoints with query parameters:
100
+
101
+
```go
102
+
// DOESN'T WORK - Gorilla Mux treats this as a literal path ❌
103
+
mock.Endpoint{
104
+
Path: apiPath + "?count=2&from=123&skip=1",
105
+
Method: "GET",
106
+
Response: successResponse,
107
+
}
108
+
109
+
// WORKS - Use only the base path ✅
110
+
mock.Endpoint{
111
+
Path: apiPath, // Only the base path without query parameters
112
+
Method: "GET",
113
+
Response: successResponse,
114
+
}
115
+
```
116
+
117
+
### 2. Line Length Linter Errors
118
+
119
+
When encountering line length errors ("The line is X characters long, which exceeds the maximum of Y characters"):
120
+
121
+
1. Option 1: Add `//nolint:lll` comment at the end of the line:
122
+
```go
123
+
return mcpgo.NewTool(
124
+
"tool_name",
125
+
"This is a very long description that exceeds the line length limit", //nolint:lll
126
+
parameters,
127
+
handler,
128
+
)
129
+
```
130
+
131
+
2. Option 2: Break the string into multiple concatenated lines:
132
+
```go
133
+
return mcpgo.NewTool(
134
+
"tool_name",
135
+
"This is a very long description " +
136
+
"that exceeds the line length limit",
137
+
parameters,
138
+
handler,
139
+
)
140
+
```
141
+
142
+
3. Option 3: For comments, split into multiple comment lines:
143
+
```go
144
+
// This is a very long comment that would exceed the line length limit
145
+
// so it's split into multiple lines.
146
+
func ToolName() {}
147
+
```
148
+
149
+
### 3. Missing Steps in the Implementation Checklist
150
+
151
+
IMPORTANT: The Implementation Checklist MUST be complete before submitting. Pay particular attention to these required steps:
152
+
153
+
- [ ] Run linter and fix errors if any (REQUIRED)
154
+
- [ ] Run tests and fix errors if any (REQUIRED)
155
+
156
+
If any checklist items remain unchecked, complete them before proceeding. The implementation is considered incomplete until all required steps are addressed.
157
+
158
+
## Test Coverage Requirements
159
+
160
+
Your tests MUST include:
161
+
- Positive test case with all parameters
162
+
- Negative test case for EACH required parameter
163
+
- Negative test case for validation failures (e.g., wrong types)
164
+
- Any edge cases specific to this tool
165
+
166
+
## ⚠️ Required Verification Steps ⚠️
167
+
168
+
After implementing code changes, ALWAYS perform these verification steps:
169
+
170
+
1. You **MUST** run the linter to ensure code quality:
171
+
```
172
+
run_terminal_cmd golangci-lint run
173
+
```
174
+
Fix any issues reported by the linter. Try at least two iterations of fixes for the errors before giving up.
175
+
176
+
2. You **MUST** run tests to verify functionality:
177
+
```
178
+
run_terminal_cmd go test ./...
179
+
```
180
+
Ensure all tests pass. If any tests fail, investigate the failures and fix the issues. Try at least two iterations of fixes for the errors before giving up.
181
+
182
+
## Key Packages and Functionality
183
+
184
+
Use this section as a reference for the key packages incase you get lost.
185
+
186
+
### `pkg/razorpay` - Main Implementation Package
187
+
188
+
**Path:** `pkg/razorpay/`
189
+
190
+
Contains all Razorpay API tool implementations, including:
191
+
- Tool function definitions (by resource type)
192
+
- Parameter validation functions
193
+
- Request/response handling
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:
0 commit comments