UNPKG

@chinchillaenterprises/mcp-stripe

Version:

Multi-tenant Stripe MCP server with account management and credential persistence

29 lines 1.41 kB
import { McpError, ErrorCode } from "@modelcontextprotocol/sdk/types.js"; import { z } from "zod"; export function handleError(error, context) { console.error(`Error in ${context}:`, error); if (error instanceof McpError) { throw error; } if (error instanceof z.ZodError) { throw new McpError(ErrorCode.InvalidParams, `Invalid parameters: ${error.errors.map(e => `${e.path.join('.')}: ${e.message}`).join(', ')}`); } if (error instanceof Error) { // Check for specific Stripe errors if ('type' in error) { const stripeError = error; if (stripeError.type === 'StripeAuthenticationError') { throw new McpError(ErrorCode.InvalidRequest, "Invalid Stripe API key. Please check your credentials."); } if (stripeError.type === 'StripeAPIError') { throw new McpError(ErrorCode.InternalError, `Stripe API error: ${stripeError.message}`); } if (stripeError.type === 'StripeInvalidRequestError') { throw new McpError(ErrorCode.InvalidParams, `Invalid request: ${stripeError.message}`); } } throw new McpError(ErrorCode.InternalError, `${context} failed: ${error.message}`); } throw new McpError(ErrorCode.InternalError, `${context} failed with unknown error`); } //# sourceMappingURL=error-handler.js.map