Dodo Payments MCP server

Provides a bridge to the Dodo Payments API for processing payments, managing subscriptions, and handling licensing through over 40 specialized tools for customer and product management.
Back to servers
Setup instructions
Provider
Dodo Payments
Release date
Apr 07, 2025
Language
TypeScript
Stats
15 stars

The Dodo Payments Node API Library provides convenient access to the Dodo Payments REST API for server-side TypeScript or JavaScript applications. It offers a comprehensive set of tools for processing payments and managing transactions.

Installation

Install the Dodo Payments library using npm:

npm install dodopayments

Basic Usage

import DodoPayments from 'dodopayments';

const client = new DodoPayments({
  bearerToken: process.env['DODO_PAYMENTS_API_KEY'], // This is the default and can be omitted
  environment: 'test_mode', // defaults to 'live_mode'
});

const payment = await client.payments.create({
  billing: { city: 'city', country: 'AF', state: 'state', street: 'street', zipcode: 'zipcode' },
  customer: { customer_id: 'customer_id' },
  product_cart: [{ product_id: 'product_id', quantity: 0 }],
});

console.log(payment.payment_id);

Using TypeScript

The library includes TypeScript definitions for all request parameters and response fields:

import DodoPayments from 'dodopayments';

const client = new DodoPayments({
  bearerToken: process.env['DODO_PAYMENTS_API_KEY'],
  environment: 'test_mode',
});

const params: DodoPayments.PaymentCreateParams = {
  billing: { city: 'city', country: 'AF', state: 'state', street: 'street', zipcode: 'zipcode' },
  customer: { customer_id: 'customer_id' },
  product_cart: [{ product_id: 'product_id', quantity: 0 }],
};
const payment: DodoPayments.PaymentCreateResponse = await client.payments.create(params);

Error Handling

The library throws appropriate error types based on API responses:

const payment = await client.payments
  .create({
    billing: { city: 'city', country: 'AF', state: 'state', street: 'street', zipcode: 'zipcode' },
    customer: { customer_id: 'customer_id' },
    product_cart: [{ product_id: 'product_id', quantity: 0 }],
  })
  .catch(async (err) => {
    if (err instanceof DodoPayments.APIError) {
      console.log(err.status); // 400
      console.log(err.name); // BadRequestError
      console.log(err.headers); // {server: 'nginx', ...}
    } else {
      throw err;
    }
  });

Error Types

Status Code Error Type
400 BadRequestError
401 AuthenticationError
403 PermissionDeniedError
404 NotFoundError
422 UnprocessableEntityError
429 RateLimitError
>=500 InternalServerError
N/A APIConnectionError

Configuring Retries

The library automatically retries certain errors:

// Configure the default for all requests:
const client = new DodoPayments({
  maxRetries: 0, // default is 2
});

// Or, configure per-request:
await client.payments.create(
  { 
    billing: { city: 'city', country: 'AF', state: 'state', street: 'street', zipcode: 'zipcode' }, 
    customer: { customer_id: 'customer_id' }, 
    product_cart: [{ product_id: 'product_id', quantity: 0 }] 
  }, 
  {
    maxRetries: 5,
  }
);

Setting Timeouts

Configure request timeouts:

// Configure the default for all requests:
const client = new DodoPayments({
  timeout: 20 * 1000, // 20 seconds (default is 1 minute)
});

// Override per-request:
await client.payments.create(
  { 
    billing: { city: 'city', country: 'AF', state: 'state', street: 'street', zipcode: 'zipcode' }, 
    customer: { customer_id: 'customer_id' }, 
    product_cart: [{ product_id: 'product_id', quantity: 0 }] 
  }, 
  {
    timeout: 5 * 1000,
  }
);

Pagination

For paginated endpoints, you can use auto-pagination with modern JavaScript:

async function fetchAllPaymentListResponses(params) {
  const allPaymentListResponses = [];
  // Automatically fetches more pages as needed
  for await (const paymentListResponse of client.payments.list()) {
    allPaymentListResponses.push(paymentListResponse);
  }
  return allPaymentListResponses;
}

Or handle pagination manually:

let page = await client.payments.list();
for (const paymentListResponse of page.items) {
  console.log(paymentListResponse);
}

// Convenience methods for manual pagination
while (page.hasNextPage()) {
  page = await page.getNextPage();
  // Process page...
}

Advanced Usage

Accessing Raw Response Data

const client = new DodoPayments();

// Get the raw Response object
const response = await client.payments
  .create({
    billing: { city: 'city', country: 'AF', state: 'state', street: 'street', zipcode: 'zipcode' },
    customer: { customer_id: 'customer_id' },
    product_cart: [{ product_id: 'product_id', quantity: 0 }],
  })
  .asResponse();
console.log(response.headers.get('X-My-Header'));

// Get both the parsed data and the raw response
const { data: payment, response: raw } = await client.payments
  .create({
    billing: { city: 'city', country: 'AF', state: 'state', street: 'street', zipcode: 'zipcode' },
    customer: { customer_id: 'customer_id' },
    product_cart: [{ product_id: 'product_id', quantity: 0 }],
  })
  .withResponse();

Custom HTTP Client Configuration

For proxy support or other custom networking needs:

import { HttpsProxyAgent } from 'https-proxy-agent';

// Configure a proxy for all requests
const client = new DodoPayments({
  httpAgent: new HttpsProxyAgent(process.env.PROXY_URL),
});

Custom Logging and Middleware

Implement request/response logging or other middleware:

import { fetch } from 'undici';
import DodoPayments from 'dodopayments';

const client = new DodoPayments({
  fetch: async (url: RequestInfo, init?: RequestInit): Promise<Response> => {
    console.log('About to make a request', url, init);
    const response = await fetch(url, init);
    console.log('Got response', response);
    return response;
  },
});

How to install this MCP server

For Claude Code

To add this MCP server to Claude Code, run this command in your terminal:

claude mcp add-json "dodopayments" '{"command":"npx","args":["-y","dodopayments"]}'

See the official Claude Code MCP documentation for more details.

For Cursor

There are two ways to add an MCP server to Cursor. The most common way is to add the server globally in the ~/.cursor/mcp.json file so that it is available in all of your projects.

If you only need the server in a single project, you can add it to the project instead by creating or adding it to the .cursor/mcp.json file.

Adding an MCP server to Cursor globally

To add a global MCP server go to Cursor Settings > Tools & Integrations and click "New MCP Server".

When you click that button the ~/.cursor/mcp.json file will be opened and you can add your server like this:

{
    "mcpServers": {
        "dodopayments": {
            "command": "npx",
            "args": [
                "-y",
                "dodopayments"
            ]
        }
    }
}

Adding an MCP server to a project

To add an MCP server to a project you can create a new .cursor/mcp.json file or add it to the existing one. This will look exactly the same as the global MCP server example above.

How to use the MCP server

Once the server is installed, you might need to head back to Settings > MCP and click the refresh button.

The Cursor agent will then be able to see the available tools the added MCP server has available and will call them when it needs to.

You can also explicitly ask the agent to use the tool by mentioning the tool name and describing what the function does.

For Claude Desktop

To add this MCP server to Claude Desktop:

1. Find your configuration file:

  • macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows: %APPDATA%\Claude\claude_desktop_config.json
  • Linux: ~/.config/Claude/claude_desktop_config.json

2. Add this to your configuration file:

{
    "mcpServers": {
        "dodopayments": {
            "command": "npx",
            "args": [
                "-y",
                "dodopayments"
            ]
        }
    }
}

3. Restart Claude Desktop for the changes to take effect

Want to 10x your AI skills?

Get a free account and learn to code + market your apps using AI (with or without vibes!).

Nah, maybe later