mcp-server-razorpay
<div align="center">
# mcp-server-razorpay
**A [Model Context Protocol (MCP)](https://modelcontextprotocol.io) server that exposes [Razorpay](https://razorpay.com) APIs to AI agents.**
Enable AI assistants to create orders, process payments, handle refunds, manage subscriptions, and generate payment links โ autonomously.
[](https://www.typescriptlang.org/)
[](https://github.com/modelcontextprotocol/typescript-sdk)
[](https://opensource.org/licenses/MIT)
[](https://razorpay.com/docs/api/)
</div>
---
## ๐ค What Can an AI Agent Do With This?
Once connected, your AI assistant can handle real payment operations via natural language:
- *"Create an order for โน999 and send a payment link to john@example.com"*
- *"Refund payment pay_abc123 with optimum speed"*
- *"List all payments from the last 7 days"*
- *"Cancel subscription sub_xyz at the end of the current billing cycle"*
- *"Create a customer for Riya Sharma with contact +919876543210"*
---
## ๐ ๏ธ Tools
### ๐ฆ Orders
| Tool | Description |
|---|---|
| `create_order` | Create a new order (amount in paise, e.g. 50000 = โน500) |
| `fetch_order` | Fetch order details by order ID |
| `list_orders` | List orders with filters (count, date range, status) |
### ๐ณ Payments
| Tool | Description |
|---|---|
| `fetch_payment` | Fetch payment details by payment ID |
| `capture_payment` | Capture an authorized payment |
| `list_payments` | List payments with date and count filters |
### ๐ Refunds
| Tool | Description |
|---|---|
| `create_refund` | Full or partial refund with normal/optimum speed |
| `fetch_refund` | Fetch a specific refund by refund ID |
| `list_refunds_for_payment` | List all refunds on a payment |
### ๐ค Customers
| Tool | Description |
|---|---|
| `create_customer` | Create a new Razorpay customer |
| `fetch_customer` | Fetch customer details by customer ID |
### ๐ Subscriptions
| Tool | Description |
|---|---|
| `create_subscription` | Create a recurring subscription for a plan |
| `fetch_subscription` | Fetch subscription status and details |
| `cancel_subscription` | Cancel immediately or at end of billing cycle |
### ๐ Payment Links
| Tool | Description |
|---|---|
| `create_payment_link` | Generate a shareable payment link with optional SMS/email delivery |
| `fetch_payment_link` | Fetch payment link details and status |
| `deactivate_payment_link` | Expire a payment link immediately |
---
## โก Quickstart
### 1. Get Razorpay API Keys
Sign up at [dashboard.razorpay.com](https://dashboard.razorpay.com/app/keys) โ Settings โ API Keys.
Use **Test Mode** keys during development.
### 2. Clone & Install
```bash
git clone https://github.com/YOUR_USERNAME/mcp-server-razorpay.git
cd mcp-server-razorpay
npm install
```
### 3. Configure Environment
```bash
cp .env.example .env
```
Edit `.env`:
```env
RAZORPAY_KEY_ID=rzp_test_xxxxxxxxxxxxxx
RAZORPAY_KEY_SECRET=xxxxxxxxxxxxxxxxxxxxxxxx
```
### 4. Build
```bash
npm run build
```
---
## ๐ Connect to Claude Desktop
Edit your `claude_desktop_config.json`:
**macOS:** `~/Library/Application Support/Claude/claude_desktop_config.json`
**Windows:** `%APPDATA%\Claude\claude_desktop_config.json`
```json
{
"mcpServers": {
"razorpay": {
"command": "node",
"args": ["/absolute/path/to/mcp-server-razorpay/dist/index.js"],
"env": {
"RAZORPAY_KEY_ID": "rzp_test_xxxxxxxxxxxxxx",
"RAZORPAY_KEY_SECRET": "xxxxxxxxxxxxxxxxxxxxxxxx"
}
}
}
}
```
Restart Claude Desktop โ you'll see the ๐จ tools icon appear.
---
## ๐ Connect to Cursor
Go to `Settings โ Tools & Integrations โ New MCP Server` and add:
```json
{
"razorpay": {
"command": "node",
"args": ["/absolute/path/to/mcp-server-razorpay/dist/index.js"],
"env": {
"RAZORPAY_KEY_ID": "rzp_test_xxxxxxxxxxxxxx",
"RAZORPAY_KEY_SECRET": "xxxxxxxxxxxxxxxxxxxxxxxx"
}
}
}
```
---
## ๐งช Debug with MCP Inspector
```bash
npm run inspector
```
Opens a browser UI where you can test every tool interactively before connecting to a client.
---
## ๐ Project Structure
```
mcp-server-razorpay/
โโโ src/
โ โโโ index.ts # Entry point & server init
โ โโโ client.ts # Razorpay axios instance + Basic Auth
โ โโโ tools/
โ โโโ orders.ts # Order management tools
โ โโโ payments.ts # Payment tools
โ โโโ refunds.ts # Refund tools
โ โโโ customers.ts # Customer tools
โ โโโ subscriptions.ts # Subscription tools
โ โโโ paymentLinks.ts # Payment link tools
โโโ .env.example
โโโ package.json
โโโ tsconfig.json
```
---
## ๐ Security Notes
- Never commit your `.env` file โ it's in `.gitignore`
- Use **Test Mode** keys during development; switch to Live keys only in production
- The server runs locally โ your API keys never leave your machine
---
## ๐ค Contributing
PRs welcome! If you'd like to add tools (e.g. Payouts, Settlements, Webhooks), open an issue first to discuss.
---
## ๐ License
MIT โ free for personal and commercial use.
TDQS
Scored across 17 tools
Each tool pairs a distinct verb with a distinct Razorpay resource (order, payment, refund, customer, subscription, payment link), so no two tools overlap in purpose. Edge cases like fetch_refund versus list_refunds_for_payment are clearly separated by identifier requirements and singular/plural semantics in the descriptions.
All 17 tools follow a strict snake_case verb_noun pattern (fetch_order, create_refund, cancel_subscription, deactivate_payment_link). The one outlier, list_refunds_for_payment, still conforms to the same verb_noun convention with a clarifying resource qualifier.
17 tools spanning six resources is reasonable for a payments API, with roughly three operations per resource. It is slightly on the heavy side of the ideal band, but no tool appears redundant or filler.
Core flows (create/fetch/list orders, capture payments, refund, subscriptions, payment links) are covered, but read coverage is uneven: customers, subscriptions, and payment links have no list or update operations, and there is no fetch/list of all refunds or any customer deletion. Agents can work around these via IDs they already hold, but discovery-style workflows will hit dead ends.