Back to Articles
Tutorials6 minJanuary 15, 2025

Cursor Rules for MoneyGraph: MDC Configuration Deep Dive

Deep dive into MoneyGraph's Cursor rules file. Learn how our MDC configuration teaches Cursor the SDK patterns, namespace hierarchy, and compliance requirements.

By MoneyGraph Team

Cursor is the AI-first IDE that's taken the developer world by storm. MoneyGraph SDK has supported Cursor since v1.0, but with v2.2, we've completely rewritten our rules for the new v2.1+ namespace structure.

What's in Our MDC File

The .cursor/rules/moneygraph.mdc file uses Cursor's MDC format with frontmatter and rules that apply to all TypeScript and JavaScript files.

Critical Rules

Our rules file defines four non-negotiable patterns:

RuleWhat Cursor Enforces
Never Use Raw FetchAlways use SDK methods, not direct API calls
Quote & Confirm PatternFollow Quote → Confirm → Payout sequence
KYC Before PayoutCheck verification status before sending money
Environment VariablesNever hardcode API keys or secrets

#### 1. Never Use Raw Fetch

// ❌ Cursor won't generate this
const response = await fetch('https://api.moneygraph.ai/v1/payouts');

// Cursor generates this import { MoneyGraph } from '@moneygraph/sdk'; const mg = new MoneyGraph({ apiKey: process.env.MONEYGRAPH_API_KEY }); ```

#### 2. Quote & Confirm Pattern

// Cursor always follows this sequence
const quote = await mg.fx.quote({ from: 'USD', to: 'NGN', amount: 100 });
await mg.fx.confirm(quote.id);
const payout = await mg.payouts.create({ quote_id: quote.id, ... });

#### 3. KYC Before Payout

// Cursor adds this check automatically
const status = await mg.customers.kyc.canPayout(customerId);
if (!status.allowed) {
  throw new Error(`KYC not approved: ${status.status}`);
}

#### 4. Environment Variables

// Cursor never hardcodes API keys
const mg = new MoneyGraph({ apiKey: process.env.MONEYGRAPH_API_KEY });

The Golden Path

Our rules include a complete "Golden Path" example that Cursor references when generating payment flows:

// 1. Create customer
const customer = await mg.customers.create({ ... });

// 2. Submit KYC await mg.customers.kyc.submit(customer.id, { ... });

// 3. Verify KYC approved const status = await mg.customers.kyc.canPayout(customer.id);

// 4. Quote → Confirm → Payout const quote = await mg.fx.quote({ from: 'USD', to: 'NGN', amount: 100 }); await mg.fx.confirm(quote.id); const payout = await mg.payouts.create({ ... }); ```

Setup

Installation: ``bash npm install @moneygraph/sdk ``

How It Works: Cursor automatically reads .cursor/rules/moneygraph.mdc from your project's node_modules/@moneygraph/sdk folder. Rules are applied to all TypeScript and JavaScript files.

Quick Start Prompt

Add this comment in your editor and press Tab:

// Create a payout function that sends $500 USD to a Nigerian bank account
// using MoneyGraph SDK. Include KYC check, FX quote, and proper error handling

Cursor will autocomplete with compliant, production-ready code!

Pro Tips

TipHow to Use
**Use Cursor Chat**Ask questions like "What's the difference between mg.payouts.create and mg.payouts.swift.create?" or "How do I handle QUOTE_EXPIRED errors?"
**Prime with Comments**Add `// Use MoneyGraph to send payout to Nigeria` above your code to guide Cursor's suggestions
**Leverage Autocomplete**Type `mg.` and let Cursor show you all available namespaces with inline documentation
**Ask for Examples**Request "Show me how to create a virtual card" and Cursor will generate complete, compliant code

Why Cursor + MoneyGraph Works So Well

Cursor excels at understanding complex codebases. Our SDK's clean namespace hierarchy (mg.module.submodule.method) maps perfectly to how Cursor analyzes code structure.

The Result: Cursor becomes a fintech expert that understands compliance, rate locking, and multi-rail payments automatically.

Next Steps:

Ready to Get Started?

Install MoneyGraph SDK and start building AI-native payment applications today