Skip to content

Commit c555f1e

Browse files
Merge branch 'main' of https://github.com/razorpay/razorpay-mcp-server into chiragchiranjib/add-mcpgo-uts
2 parents d21d91f + b113e72 commit c555f1e

30 files changed

+7652
-472
lines changed

.cursor/rules/new-tool-from-docs.mdc

+27-14
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,10 @@ Upon receiving this rule invocation:
5959

6060
Before the implementation use the documentation URL provided to figure out the request contract, required parameters, descriptions of the parameters, and the response contract.
6161

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.
6363

6464
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.
6666
2. Use the payload and response from the docs provided to write the positive test case for the tool.
6767

6868
STYLE:
@@ -72,7 +72,7 @@ IMPORTANT: You **MUST** ALWAYS go through the Post Implementation steps once the
7272

7373
## Implementation References
7474

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):
7676

7777
- **Tool Structure**: See the "Tool Structure" section for the function template
7878
- **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
160160
Your tests MUST include:
161161
- Positive test case with all parameters
162162
- 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)
164164
- Any edge cases specific to this tool
165165

166166
## ⚠️ Required Verification Steps ⚠️
@@ -192,16 +192,29 @@ Contains all Razorpay API tool implementations, including:
192192
- Parameter validation functions
193193
- Request/response handling
194194

195-
### `pkg/razorpay/server.go` - Core Utilities
196-
197-
**Path:** `pkg/razorpay/server.go`
198-
199-
Contains essential utility functions used by all tools:
200-
- `RequiredParam[T]` - Type-safe required parameter extraction
201-
- `OptionalParam[T]` - Type-safe optional parameter extraction
202-
- `RequiredInt` - Integer parameter extraction
203-
- `OptionalInt` - Optional integer parameter extraction
204-
- `HandleValidationError` - Common validation error handling
195+
### `pkg/razorpay/tools_params.go` - Fluent Validator
196+
197+
**Path:** `pkg/razorpay/tools_params.go`
198+
199+
Contains the fluent validator implementation for parameter validation:
200+
- `Validator` - Type that provides a fluent interface for validation
201+
- `NewValidator` - Creates a new validator for a request
202+
- `HasErrors` - Checks if validation errors exist
203+
- `HandleErrorsIfAny` - Formats all errors into a tool result
204+
- `ValidateAndAddRequiredString` - Validates required string parameters
205+
- `ValidateAndAddOptionalString` - Validates optional string parameters
206+
- `ValidateAndAddRequiredInt` - Validates required integer parameters
207+
- `ValidateAndAddOptionalInt` - Validates optional integer parameters
208+
- `ValidateAndAddRequiredFloat` - Validates required float parameters
209+
- `ValidateAndAddOptionalFloat` - Validates optional float parameters
210+
- `ValidateAndAddRequiredBool` - Validates required boolean parameters
211+
- `ValidateAndAddOptionalBool` - Validates optional boolean parameters
212+
- `ValidateAndAddRequiredMap` - Validates required map parameters
213+
- `ValidateAndAddOptionalMap` - Validates optional map parameters
214+
- `ValidateAndAddRequiredArray` - Validates required array parameters
215+
- `ValidateAndAddOptionalArray` - Validates optional array parameters
216+
- `ValidateAndAddPagination` - Validates and adds pagination parameters
217+
- `ValidateAndAddExpand` - Validates and adds expand parameters
205218

206219
### `pkg/razorpay/test_helpers.go` - Testing Utilities
207220

.github/workflows/assign.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,5 +18,5 @@ jobs:
1818
issue_number: context.issue.number,
1919
owner: context.repo.owner,
2020
repo: context.repo.repo,
21-
assignees: ['KarthikBoddeda', 'stuckinforloop', 'alok87']
21+
assignees: ['KarthikBoddeda', 'ChiragChiranjib', 'stuckinforloop', 'alok87']
2222
})

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
/bin
33
/.go
44
/logs
5-
/vendor
5+
/vendor
6+
razorpay-mcp-server

CONTRIBUTING.md

+14
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,18 @@ Thank you for your interest in contributing to the Razorpay MCP Server! This doc
66

77
Please be respectful and considerate of others when contributing to this project. We strive to maintain a welcoming and inclusive environment for all contributors.
88

9+
## TLDR;
10+
11+
```
12+
make test
13+
make fmt
14+
make lint
15+
make build
16+
make run
17+
```
18+
19+
We use Cursor to contribute - our AI developer. Look at `~/.cusor/rules`. It understands the standards we have defined and codes with that.
20+
921
## Development Process
1022

1123
We use a fork-based workflow for all contributions:
@@ -95,6 +107,8 @@ We use a fork-based workflow for all contributions:
95107

96108
### Running the Server Locally
97109

110+
There are `make` commands also available now for the below, refer TLDR; above.
111+
98112
To run the server in development mode:
99113

100114
```bash

Makefile

+93
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
# Build variables
2+
VERSION ?= $(shell git describe --tags --always --dirty --match="v*" 2> /dev/null || echo "dev")
3+
BUILD_DATE = $(shell date -u '+%Y-%m-%d')
4+
COMMIT = $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
5+
LDFLAGS = -ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.buildDate=$(BUILD_DATE)"
6+
7+
# Go variables
8+
GO = go
9+
GOBIN = $(shell $(GO) env GOPATH)/bin
10+
11+
# Docker variables
12+
IMAGE = razorpay-mcp-server
13+
TAG ?= latest
14+
15+
# Default target
16+
all: verify fmt test lint build
17+
18+
# Build docker image
19+
build:
20+
docker build -t $(IMAGE):$(TAG) .
21+
22+
# Run docker container
23+
run:
24+
docker run -it --rm \
25+
-e RAZORPAY_KEY_ID=your_key_id \
26+
-e RAZORPAY_KEY_SECRET=your_key_secret \
27+
$(IMAGE):$(TAG)
28+
29+
# Run the application
30+
local-run:
31+
$(GO) run ./cmd/razorpay-mcp-server
32+
33+
local-build:
34+
$(GO) build -v ./cmd/razorpay-mcp-server
35+
36+
# Verify dependencies
37+
verify:
38+
$(GO) mod verify
39+
$(GO) mod download
40+
41+
# Format code
42+
fmt:
43+
$(GO) fmt ./...
44+
$(GO) mod tidy
45+
46+
# Run tests
47+
test:
48+
$(GO) test -race ./...
49+
50+
# Run tests with coverage
51+
test-coverage:
52+
$(GO) test -race -coverprofile=coverage.out -covermode=atomic ./pkg/...
53+
$(GO) tool cover -html=coverage.out -o coverage.html
54+
55+
# Install golangci-lint
56+
install-lint:
57+
@LINT_VERSION=1.64.8; \
58+
if ! command -v golangci-lint > /dev/null 2>&1; then \
59+
echo "Installing golangci-lint v$$LINT_VERSION..."; \
60+
curl -fsSL https://github.com/golangci/golangci-lint/releases/download/v$$LINT_VERSION/golangci-lint-$$LINT_VERSION-$$($(GO) env GOOS)-$$($(GO) env GOARCH).tar.gz | \
61+
tar xz --strip-components 1 --wildcards \*/golangci-lint; \
62+
mkdir -p bin && mv golangci-lint bin/; \
63+
echo "golangci-lint installed to bin/golangci-lint"; \
64+
fi
65+
66+
# Run linter
67+
lint: install-lint
68+
@if [ -f ./bin/golangci-lint ]; then \
69+
./bin/golangci-lint run --out-format=colored-line-number --timeout=3m; \
70+
else \
71+
golangci-lint run --out-format=colored-line-number --timeout=3m; \
72+
fi
73+
74+
# Clean build artifacts
75+
clean:
76+
rm -rf bin/
77+
rm -f coverage.out coverage.html
78+
79+
# Help
80+
help:
81+
@echo "Available targets:"
82+
@echo " all - Run verify, fmt, test, lint, and build (default)"
83+
@echo " build - Build Docker image"
84+
@echo " run - Run Docker container"
85+
@echo " local-build - Build the application"
86+
@echo " local-run - Run the application"
87+
@echo " verify - Verify dependencies"
88+
@echo " fmt - Format code"
89+
@echo " test - Run tests"
90+
@echo " test-coverage - Run tests with coverage"
91+
@echo " lint - Run linter"
92+
@echo " clean - Clean build artifacts"
93+
@echo " help - Show this help message"

README.md

+39-7
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,45 @@ The Razorpay MCP Server is a [Model Context Protocol (MCP)](https://modelcontext
66

77
Currently, the Razorpay MCP Server provides the following tools:
88

9-
| Tool | Description |
10-
|-----------------------|---------------------------------------|
11-
| `fetch_payment` | Fetch payment details |
12-
| `create_payment_link` | Creates a new payment link |
13-
| `fetch_payment_link` | Fetch details of a payment link |
14-
| `create_order` | Creates an order |
15-
| `fetch_order` | Fetch order details |
9+
| Tool | Description | API
10+
|:-------------------------------------|:-------------------------------------------------------|:-----------------------------------
11+
| `capture_payment` | Change the payment status from authorized to captured. | [Payment](https://razorpay.com/docs/api/payments/capture)
12+
| `fetch_payment` | Fetch payment details with ID | [Payment](https://razorpay.com/docs/api/payments/fetch-with-id)
13+
| `fetch_payment_card_details` | Fetch card details used for a payment | [Payment](https://razorpay.com/docs/api/payments/fetch-payment-expanded-card)
14+
| `fetch_all_payments` | Fetch all payments with filtering and pagination | [Payment](https://razorpay.com/docs/api/payments/fetch-all-payments)
15+
| `update_payment` | Update the notes field of a payment | [Payment](https://razorpay.com/docs/api/payments/update)|
16+
| `create_payment_link` | Creates a new payment link (standard) | [Payment Link](https://razorpay.com/docs/api/payments/payment-links/create-standard)
17+
| `create_payment_link_upi` | Creates a new UPI payment link | [Payment Link](https://razorpay.com/docs/api/payments/payment-links/create-upi)
18+
| `fetch_all_payment_links` | Fetch all the payment links | [Payment Link](https://razorpay.com/docs/api/payments/payment-links/fetch-all-standard)
19+
| `fetch_payment_link` | Fetch details of a payment link | [Payment Link](https://razorpay.com/docs/api/payments/payment-links/fetch-id-standard/)
20+
| `send_payment_link` | Send a payment link via SMS or email. | [Payment Link](https://razorpay.com/docs/api/payments/payment-links/resend)
21+
| `update_payment_link` | Updates a new standard payment link | [Payment Link](https://razorpay.com/docs/api/payments/payment-links/update-standard)
22+
| `create_order` | Creates an order | [Order](https://razorpay.com/docs/api/orders/create/)
23+
| `fetch_order` | Fetch order with ID | [Order](https://razorpay.com/docs/api/orders/fetch-with-id)
24+
| `fetch_all_orders` | Fetch all orders | [Order](https://razorpay.com/docs/api/orders/fetch-all)
25+
| `update_order` | Update an order | [Order](https://razorpay.com/docs/api/orders/update)
26+
| `fetch_order_payments` | Fetch all payments for an order | [Order](https://razorpay.com/docs/api/orders/fetch-payments/)
27+
| `create_refund` | Creates a refund | [Refund](https://razorpay.com/docs/api/refunds/create-instant/)
28+
| `fetch_refund` | Fetch refund details with ID | [Refund](https://razorpay.com/docs/api/refunds/fetch-with-id/)
29+
| `fetch_all_refunds` | Fetch all refunds | [Refund](https://razorpay.com/docs/api/refunds/fetch-all)
30+
| `update_refund` | Update refund notes with ID | [Refund](https://razorpay.com/docs/api/refunds/update/)
31+
| `fetch_multiple_refunds_for_payment` | Fetch multiple refunds for a payment | [Refund](https://razorpay.com/docs/api/refunds/fetch-multiple-refund-payment/)
32+
| `fetch_specific_refund_for_payment` | Fetch a specific refund for a payment | [Refund](https://razorpay.com/docs/api/refunds/fetch-specific-refund-payment/)
33+
| `create_qr_code` | Creates a QR Code | [QR Code](https://razorpay.com/docs/api/qr-codes/create/)
34+
| `fetch_qr_code` | Fetch QR Code with ID | [QR Code](https://razorpay.com/docs/api/qr-codes/fetch-with-id/)
35+
| `fetch_all_qr_codes` | Fetch all QR Codes | [QR Code](https://razorpay.com/docs/api/qr-codes/fetch-all/)
36+
| `fetch_qr_codes_by_customer_id` | Fetch QR Codes with Customer ID | [QR Code](https://razorpay.com/docs/api/qr-codes/fetch-customer-id/)
37+
| `fetch_qr_codes_by_payment_id` | Fetch QR Codes with Payment ID | [QR Code](https://razorpay.com/docs/api/qr-codes/fetch-payment-id/)
38+
| `fetch_payments_for_qr_code` | Fetch Payments for a QR Code | [QR Code](https://razorpay.com/docs/api/qr-codes/fetch-payments/)
39+
| `close_qr_code` | Closes a QR Code | [QR Code](https://razorpay.com/docs/api/qr-codes/close/)
40+
| `fetch_all_settlements` | Fetch all settlements | [Settlement](https://razorpay.com/docs/api/settlements/fetch-all)
41+
| `fetch_settlement_with_id` | Fetch settlement details | [Settlement](https://razorpay.com/docs/api/settlements/fetch-with-id)
42+
| `fetch_settlement_recon_details` | Fetch settlement reconciliation report | [Settlement](https://razorpay.com/docs/api/settlements/fetch-recon)
43+
| `create_instant_settlement` | Create an instant settlement | [Settlement](https://razorpay.com/docs/api/settlements/instant/create)
44+
| `fetch_all_instant_settlements` | Fetch all instant settlements | [Settlement](https://razorpay.com/docs/api/settlements/instant/fetch-all)
45+
| `fetch_instant_settlement_with_id` | Fetch instant settlement with ID | [Settlement](https://razorpay.com/docs/api/settlements/instant/fetch-with-id)
46+
| `fetch_all_payouts` | Fetch all payout details with A/c number | [Payout](https://razorpay.com/docs/api/x/payouts/fetch-all/)
47+
| `fetch_payout_by_id` | Fetch the payout details with payout ID | [Payout](https://razorpay.com/docs/api/x/payouts/fetch-with-id)
1648

1749

1850
## Use Cases

SECURITY.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Security
2+
3+
Razorpay takes the security of our software products and services seriously, including all of the open source code repositories managed through our Razorpay organizations and looks forward to working with the security community to find vulnerabilities and protect our businesses and customers. We are dedicated to responsibly resolving any security concerns.
4+
5+
Our [open source repositories are outside of the scope of our bug bounty program](https://hackerone.com/razorpay) and therefore not eligible for bounty rewards. However, we will ensure that your finding (if valid), is accepted and gets passed along to the appropriate maintainers for remediation.
6+
7+
## Reporting Security Issues
8+
9+
If you believe you have found a security vulnerability in any Razorpay owned repository, please report it to us through our [Hackerone program](https://hackerone.com/razorpay).
10+
11+
Please refrain from disclosing vulnerabilities via public channels such as issues, discussions, or pull requests.
12+
13+
All vulnerability reports must be submitted via our [Hackerone program](https://hackerone.com/razorpay).
14+
15+
Please include as much of the information listed below as you can to help us better understand and resolve the issue:
16+
17+
- The type of issue (e.g., buffer overflow, SQL injection, or cross-site scripting)
18+
- Full paths of source file(s) related to the manifestation of the issue
19+
- The location of the affected source code (tag/branch/commit or direct URL)
20+
- Any special configuration required to reproduce the issue
21+
- Step-by-step instructions to reproduce the issue
22+
- Proof-of-concept or exploit code (if possible)
23+
- Impact of the issue, including how an attacker might exploit the issue
24+
25+
This information will help us triage your report more quickly.

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ require (
66
github.com/go-test/deep v1.1.1
77
github.com/gorilla/mux v1.8.1
88
github.com/mark3labs/mcp-go v0.23.1
9-
github.com/razorpay/razorpay-go v1.3.2
9+
github.com/razorpay/razorpay-go v1.3.3
1010
github.com/spf13/cobra v1.9.1
1111
github.com/spf13/viper v1.20.1
1212
github.com/stretchr/testify v1.10.0

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ github.com/pelletier/go-toml/v2 v2.2.4 h1:mye9XuhQ6gvn5h28+VilKrrPoQVanw5PMw/TB0
2828
github.com/pelletier/go-toml/v2 v2.2.4/go.mod h1:2gIqNv+qfxSVS7cM2xJQKtLSTLUE9V8t9Stt+h56mCY=
2929
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
3030
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
31-
github.com/razorpay/razorpay-go v1.3.2 h1:6368QznCNkoQNi7bBbxdHUu7lJJW4UxN7W3WftrbFZg=
32-
github.com/razorpay/razorpay-go v1.3.2/go.mod h1:VcljkUylUJAUEvFfGVv/d5ht1to1dUgF4H1+3nv7i+Q=
31+
github.com/razorpay/razorpay-go v1.3.3 h1:htVhJPI8SXx7X9POcoGg2uMVzbn8hzv7UP9VvbMYYdw=
32+
github.com/razorpay/razorpay-go v1.3.3/go.mod h1:VcljkUylUJAUEvFfGVv/d5ht1to1dUgF4H1+3nv7i+Q=
3333
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
3434
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
3535
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=

0 commit comments

Comments
 (0)