|
1 | | -# Stripe Testing tools MCP Server |
| 1 | +# Stripe Testing Tools MCP Server |
2 | 2 |
|
3 | | -Simply testing helpers for your stripe integrations |
| 3 | +A Model Context Protocol (MCP) server that provides testing and debugging tools for Stripe integrations. This server enables developers to efficiently test Stripe workflows, manage test data, and simulate time-based scenarios using Stripe's test helpers. |
4 | 4 |
|
5 | | -This is a TypeScript-based MCP server that implements a simple notes system. It demonstrates core MCP concepts by providing: |
| 5 | +## Features |
6 | 6 |
|
7 | | -- Resources representing text notes with URIs and metadata |
8 | | -- Tools for creating new notes |
9 | | -- Prompts for generating summaries of notes |
| 7 | +### Time Simulation Tools |
10 | 8 |
|
11 | | -## Features |
| 9 | +- **Test Clock Management** - Create and advance Stripe test clocks for time-based testing |
| 10 | +- **Subscription Testing** - Test billing cycles and subscription renewals by controlling time |
12 | 11 |
|
13 | | -### Resources |
| 12 | +### Customer Management |
14 | 13 |
|
15 | | -- List and access notes via `note://` URIs |
16 | | -- Each note has a title, content and metadata |
17 | | -- Plain text mime type for simple content access |
| 14 | +- **Bulk Customer Creation** - Create multiple test customers with customizable properties |
| 15 | +- **Customer Cleanup** - Delete test customers to maintain clean test environments |
| 16 | +- **Test Clock Association** - Link customers to test clocks for time-controlled testing |
18 | 17 |
|
19 | | -### Tools |
| 18 | +### Product Management |
20 | 19 |
|
21 | | -- `create_note` - Create new text notes |
22 | | - - Takes title and content as required parameters |
23 | | - - Stores note in server state |
| 20 | +- **Product Archiving** - Archive test products by ID or URL |
| 21 | +- **Product Deletion** - Permanently delete test products to clean up test data |
24 | 22 |
|
25 | | -### Prompts |
| 23 | +### Subscription Testing |
26 | 24 |
|
27 | | -- `summarize_notes` - Generate a summary of all stored notes |
28 | | - - Includes all note contents as embedded resources |
29 | | - - Returns structured prompt for LLM summarization |
| 25 | +- **Test Subscription Creation** - Create subscriptions with configurable proration behavior |
| 26 | +- **Time-based Testing** - Test subscription billing cycles using test clocks |
30 | 27 |
|
31 | | -## Development |
| 28 | +## Available Tools |
| 29 | + |
| 30 | +### Test Clock Tools |
| 31 | + |
| 32 | +#### `create_stripe_test_clock` |
| 33 | +Creates a new Stripe test clock for time simulation. |
| 34 | + |
| 35 | +**Parameters:** |
| 36 | +- `frozen_time` (required): Unix timestamp for the initial frozen time |
| 37 | +- `name` (optional): Name for the test clock |
| 38 | + |
| 39 | +**Example:** |
| 40 | +``` |
| 41 | +Create a test clock starting at January 1, 2024: |
| 42 | +frozen_time: 1704067200 |
| 43 | +name: "New Year Test Clock" |
| 44 | +``` |
| 45 | + |
| 46 | +#### `advance_stripe_test_clock` |
| 47 | +Advances an existing test clock to a new time. |
| 48 | + |
| 49 | +**Parameters:** |
| 50 | +- `test_clock_id` (required): The ID of the test clock to advance |
| 51 | +- `frozen_time` (required): Unix timestamp to advance the clock to |
| 52 | + |
| 53 | +### Customer Management Tools |
| 54 | + |
| 55 | +#### `create_stripe_test_customers` |
| 56 | +Creates one or more test customers. |
| 57 | + |
| 58 | +**Parameters:** |
| 59 | +- `number` (optional, default: 1): Number of customers to create |
| 60 | +- `payment_method_id` (optional): Payment method to associate with customers |
| 61 | +- `name` (optional): Name for the customers |
| 62 | +- `email` (optional): Email for the customers |
| 63 | +- `description` (optional): Description for the customers |
| 64 | +- `test_clock` (optional): Test clock ID to associate with customers (max 3 customers per clock) |
| 65 | + |
| 66 | +#### `delete_stripe_test_customers` |
| 67 | +Deletes test customers by their IDs. |
32 | 68 |
|
33 | | -Install dependencies: |
| 69 | +**Parameters:** |
| 70 | +- `customer_ids` (required): Array of customer IDs to delete |
34 | 71 |
|
| 72 | +### Product Management Tools |
| 73 | + |
| 74 | +#### `archive_stripe_test_products` |
| 75 | +Archives test products (sets active: false). |
| 76 | + |
| 77 | +**Parameters:** |
| 78 | +- `product_ids` (optional): Array of product IDs to archive |
| 79 | +- `urls` (optional): Array of product URLs to archive |
| 80 | + |
| 81 | +#### `delete_stripe_test_products` |
| 82 | +Permanently deletes test products. |
| 83 | + |
| 84 | +**Parameters:** |
| 85 | +- `product_ids` (optional): Array of product IDs to delete |
| 86 | +- `urls` (optional): Array of product URLs to delete |
| 87 | + |
| 88 | +### Subscription Tools |
| 89 | + |
| 90 | +#### `create_stripe_test_subscription` |
| 91 | +Creates a test subscription for a customer. |
| 92 | + |
| 93 | +**Parameters:** |
| 94 | +- `customer` (required): Customer ID to create the subscription for |
| 95 | +- `items` (required): Array of subscription items with price and quantity |
| 96 | +- `proration_behavior` (optional): How to handle prorations (`create_prorations`, `none`, `always_invoice`) |
| 97 | + |
| 98 | +## Setup |
| 99 | + |
| 100 | +### Prerequisites |
| 101 | + |
| 102 | +1. A Stripe account with test mode enabled |
| 103 | +2. Node.js and npm installed |
| 104 | +3. Claude Desktop or another MCP-compatible client |
| 105 | + |
| 106 | +### Installation |
| 107 | + |
| 108 | +1. Clone this repository: |
35 | 109 | ```bash |
36 | | -npm install |
| 110 | +git clone <repository-url> |
| 111 | +cd stripe-testing-tools |
37 | 112 | ``` |
38 | 113 |
|
39 | | -Build the server: |
| 114 | +2. Install dependencies: |
| 115 | +```bash |
| 116 | +npm install |
| 117 | +``` |
40 | 118 |
|
| 119 | +3. Build the server: |
41 | 120 | ```bash |
42 | 121 | npm run build |
43 | 122 | ``` |
44 | 123 |
|
45 | | -For development with auto-rebuild: |
| 124 | +### Configuration |
| 125 | + |
| 126 | +#### Environment Variables |
| 127 | + |
| 128 | +Set your Stripe test API key as an environment variable: |
46 | 129 |
|
47 | 130 | ```bash |
48 | | -npm run watch |
| 131 | +export STRIPE_API_KEY=sk_test_your_test_key_here |
49 | 132 | ``` |
50 | 133 |
|
51 | | -## Installation |
| 134 | +**Important:** Only test keys are allowed. The server will reject live API keys for security. |
| 135 | + |
| 136 | +#### Claude Desktop Configuration |
52 | 137 |
|
53 | | -To use with Claude Desktop, add the server config: |
| 138 | +Add the server to your Claude Desktop configuration: |
54 | 139 |
|
55 | | -On MacOS: `~/Library/Application Support/Claude/claude_desktop_config.json` |
56 | | -On Windows: `%APPDATA%/Claude/claude_desktop_config.json` |
| 140 | +**MacOS:** `~/Library/Application Support/Claude/claude_desktop_config.json` |
| 141 | +**Windows:** `%APPDATA%/Claude/claude_desktop_config.json` |
57 | 142 |
|
58 | 143 | ```json |
59 | 144 | { |
60 | 145 | "mcpServers": { |
61 | | - "Stripe Testing tools": { |
62 | | - "command": "/path/to/Stripe Testing tools/build/index.js" |
| 146 | + "stripe-testing-tools": { |
| 147 | + "command": "node", |
| 148 | + "args": ["/path/to/stripe-testing-tools/build/index.js"], |
| 149 | + "env": { |
| 150 | + "STRIPE_API_KEY": "sk_test_your_test_key_here" |
| 151 | + } |
63 | 152 | } |
64 | 153 | } |
65 | 154 | } |
66 | 155 | ``` |
67 | 156 |
|
| 157 | +## Usage Examples |
| 158 | + |
| 159 | +### Time-based Subscription Testing |
| 160 | + |
| 161 | +1. **Create a test clock:** |
| 162 | + ``` |
| 163 | + Use create_stripe_test_clock with frozen_time: 1704067200 (Jan 1, 2024) |
| 164 | + ``` |
| 165 | + |
| 166 | +2. **Create customers associated with the test clock:** |
| 167 | + ``` |
| 168 | + Use create_stripe_test_customers with test_clock: clock_id_from_step_1 |
| 169 | + ``` |
| 170 | + |
| 171 | +3. **Create subscriptions for the customers:** |
| 172 | + ``` |
| 173 | + Use create_stripe_test_subscription with customer IDs and subscription items |
| 174 | + ``` |
| 175 | + |
| 176 | +4. **Advance time to trigger billing:** |
| 177 | + ``` |
| 178 | + Use advance_stripe_test_clock to move forward by billing cycle periods |
| 179 | + ``` |
| 180 | + |
| 181 | +### Clean Up Test Data |
| 182 | + |
| 183 | +1. **Delete test customers:** |
| 184 | + ``` |
| 185 | + Use delete_stripe_test_customers with customer IDs |
| 186 | + ``` |
| 187 | + |
| 188 | +2. **Archive test products:** |
| 189 | + ``` |
| 190 | + Use archive_stripe_test_products with product IDs or URLs |
| 191 | + ``` |
| 192 | + |
| 193 | +## Development |
| 194 | + |
| 195 | +For development with auto-rebuild: |
| 196 | + |
| 197 | +```bash |
| 198 | +npm run watch |
| 199 | +``` |
| 200 | + |
68 | 201 | ### Debugging |
69 | 202 |
|
70 | | -Since MCP servers communicate over stdio, debugging can be challenging. We recommend using the [MCP Inspector](https://github.com/modelcontextprotocol/inspector), which is available as a package script: |
| 203 | +Since MCP servers communicate over stdio, debugging can be challenging. Use the MCP Inspector: |
71 | 204 |
|
72 | 205 | ```bash |
73 | 206 | npm run inspector |
74 | 207 | ``` |
75 | 208 |
|
76 | | -The Inspector will provide a URL to access debugging tools in your browser. |
| 209 | +The Inspector provides a web interface for testing and debugging MCP tools. |
| 210 | + |
| 211 | +## Security |
| 212 | + |
| 213 | +- Only Stripe test API keys are accepted |
| 214 | +- Live API keys are rejected to prevent accidental charges |
| 215 | +- All operations are performed in Stripe's test mode |
| 216 | + |
| 217 | +## Error Handling |
| 218 | + |
| 219 | +- Missing API keys will throw descriptive error messages |
| 220 | +- Live API keys are blocked with security warnings |
| 221 | +- Test clock customer limits are enforced (max 3 customers per clock) |
| 222 | +- Invalid parameters are validated using Zod schemas |
0 commit comments