Skip to main content
Glama
mcp-server-razorpay

mcp-server-razorpay

by bugmagnet28
README.md
<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.

[![TypeScript](https://img.shields.io/badge/TypeScript-5.7-blue?logo=typescript)](https://www.typescriptlang.org/)
[![MCP SDK](https://img.shields.io/badge/MCP%20SDK-1.10.2-green)](https://github.com/modelcontextprotocol/typescript-sdk)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Razorpay](https://img.shields.io/badge/Razorpay-API%20v1-072654?logo=razorpay)](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

B3.3/5.0

Scored across 17 tools

Disambiguation5/5

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.

Naming Consistency5/5

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.

Tool Count4/5

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.

Completeness3/5

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.

Maintenance

ActivityInactive
ResponsivenessNo recent community issues