import { stripeMcpSetupMessage, callStripeMcp, firstArray } from './mcp.ts'
type Input = { limit?: number }
/**
* List Stripe customers through the connected Stripe MCP server.
* @param input - Optional helper arguments (query, limit, filters).
* @returns Structured helper result for agents.
* @example
* import listCustomers from 'kody:@kody/stripe-mcp/list-customers'
* const result = await listCustomers()
* // => { ... }
*/
export default async function listCustomers(input: Input = {}) {
const mcp = await callStripeMcp(
[
"list_customers",
"listCustomers",
"customers_list"
],
{ limit: input.limit ?? 10 },
)
if (!mcp) {
throw new Error(stripeMcpSetupMessage())
}
return {
via: 'mcp',
tool: mcp.tool,
customers: firstArray(mcp.result) ?? mcp.result,
}
}