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
25 stars

The Dodo Payments TypeScript API Library provides a convenient way to access the Dodo Payments REST API from server-side TypeScript or JavaScript applications. This library simplifies integration with payment processing functionality through a clean, typed interface.

Installation

Install the library using npm:

npm install dodopayments

Basic Usage

To use the Dodo Payments API, first create a client instance:

import DodoPayments from 'dodopayments';

const client = new DodoPayments({
  bearerToken: process.env['DODO_PAYMENTS_API_KEY'], // Your API key
  environment: 'test_mode', // defaults to 'live_mode'
});

// Create a checkout session
const checkoutSessionResponse = await client.checkoutSessions.create({
  product_cart: [{ product_id: 'product_id', quantity: 1 }],
});

console.log(checkoutSessionResponse.session_id);

TypeScript Support

The library includes full 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',
});

// Use type definitions for parameters and responses
const params: DodoPayments.CheckoutSessionCreateParams = {
  product_cart: [{ product_id: 'product_id', quantity: 1 }],
};

const checkoutSessionResponse: DodoPayments.CheckoutSessionResponse = 
  await client.checkoutSessions.create(params);

Error Handling

The library throws specific error types based on API responses:

const checkoutSessionResponse = await client.checkoutSessions
  .create({ product_cart: [{ product_id: 'product_id', quantity: 1 }] })
  .catch(async (err) => {
    if (err instanceof DodoPayments.APIError) {
      console.log(err.status); // HTTP status code (e.g., 400)
      console.log(err.name);   // Error type (e.g., BadRequestError)
      console.log(err.headers); // Response headers
    } 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

Configuration Options

Retries

By default, certain errors are automatically retried:

// Disable retries globally
const client = new DodoPayments({
  maxRetries: 0, // default is 2
});

// Or configure per-request
await client.checkoutSessions.create(
  { product_cart: [{ product_id: 'product_id', quantity: 1 }] }, 
  { maxRetries: 5 }
);

Timeouts

Configure request timeouts to control how long to wait for responses:

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

// Override for a specific request
await client.checkoutSessions.create(
  { product_cart: [{ product_id: 'product_id', quantity: 1 }] },
  { timeout: 5 * 1000 } // 5 seconds
);

Pagination

For API endpoints that return paginated results, you can use the built-in pagination helpers:

// Automatically fetch all pages
async function fetchAllPayments() {
  const allPayments = [];
  for await (const payment of client.payments.list()) {
    allPayments.push(payment);
  }
  return allPayments;
}

// Or manually paginate
let page = await client.payments.list();
for (const payment of page.items) {
  console.log(payment);
}

// Navigate to the next page when needed
while (page.hasNextPage()) {
  page = await page.getNextPage();
  // Process new page...
}

Advanced Features

Access Raw Response Data

When you need access to response headers or other metadata:

// Get only the raw response
const response = await client.checkoutSessions
  .create({ product_cart: [{ product_id: 'product_id', quantity: 1 }] })
  .asResponse();

console.log(response.headers.get('X-My-Header'));

// Or get both parsed data and raw response
const { data, response: raw } = await client.checkoutSessions
  .create({ product_cart: [{ product_id: 'product_id', quantity: 1 }] })
  .withResponse();

console.log(raw.headers.get('X-My-Header'));
console.log(data.session_id);

Logging

Control the library's logging behavior:

import DodoPayments from 'dodopayments';

// Configure log level
const client = new DodoPayments({
  logLevel: 'debug', // Show all log messages (debug, info, warn, error)
});

// Or use a custom logger
import pino from 'pino';
const logger = pino();

const clientWithCustomLogger = new DodoPayments({
  logger: logger.child({ name: 'DodoPayments' }),
  logLevel: 'info',
});

Available log levels from most to least verbose: debug, info, warn, error, and off.

Custom Fetch Configuration

Configure proxy settings or other fetch options:

import DodoPayments from 'dodopayments';

// For Node.js
import * as undici from 'undici';
const proxyAgent = new undici.ProxyAgent('http://localhost:8888');

const client = new DodoPayments({
  fetchOptions: {
    dispatcher: proxyAgent,
    // Other fetch options as needed
  }
});

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