@mupag/mcp-server 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -0
- package/dist/chunk-ZGVY3GVY.js +1100 -0
- package/dist/chunk-ZGVY3GVY.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/dist/server.d.ts +60 -0
- package/dist/server.js +13 -0
- package/dist/server.js.map +1 -0
- package/package.json +63 -0
- package/server.json +37 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/server.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\nimport { isIP } from 'node:net';\n\nimport { Server } from '@modelcontextprotocol/sdk/server/index.js';\nimport {\n CallToolRequestSchema,\n ListToolsRequestSchema,\n type CallToolResult,\n type Tool\n} from '@modelcontextprotocol/sdk/types.js';\nimport { MuPag, MuPagError } from 'mupag-sdk';\n\nconst MAX_API_KEY_LENGTH = 512;\nconst MAX_IDEMPOTENCY_KEY_LENGTH = 128;\nconst MAX_IDENTIFIER_LENGTH = 128;\nconst MAX_CURSOR_LENGTH = 256;\nconst MAX_TEXT_LENGTH = 500;\nconst MAX_INPUT_BYTES = 64 * 1024;\nconst MAX_OUTPUT_BYTES = 64 * 1024;\nconst MAX_RESPONSE_BYTES = 2 * 1024 * 1024;\nconst MAX_MONEY_CENTS = 9_000_000_000_000_000;\nconst MAX_IN_FLIGHT_MUTATIONS = 1_000;\nconst IDENTIFIER_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:-]{0,127}$/;\nconst APPROVAL_REFERENCE_PATTERN = /^[A-Za-z0-9][A-Za-z0-9._:/-]{0,127}$/;\nconst SAFE_ERROR_CODE_PATTERN = /^[a-z0-9][a-z0-9_.-]{0,63}$/;\n\nconst MUTATION_GUARD_PROPERTIES = {\n idempotency_key: {\n type: 'string',\n minLength: 1,\n maxLength: MAX_IDEMPOTENCY_KEY_LENGTH,\n pattern: '^[\\\\x21-\\\\x7E]+$',\n description: 'Chave explícita e estável para repetição segura da mesma intenção.'\n },\n approval_reference: {\n type: 'string',\n minLength: 1,\n maxLength: MAX_IDENTIFIER_LENGTH,\n pattern: '^[A-Za-z0-9][A-Za-z0-9._:/-]*$',\n description: 'Referência não sensível da aprovação humana ou do workflow autorizado.'\n },\n confirm_financial_effect: {\n type: 'boolean',\n const: true,\n description: 'Deve ser true para confirmar conscientemente a mutação.'\n }\n} as const;\n\nconst MUTATION_REQUIRED = [\n 'idempotency_key',\n 'approval_reference',\n 'confirm_financial_effect'\n];\n\n/**\n * Catálogo deliberadamente pequeno. Cada mutação exige confirmação e chave fornecidas\n * pelo chamador; o servidor nunca inventa uma intenção financeira nem uma chave por ele.\n */\nexport const TOOL_DEFINITIONS: Tool[] = [\n {\n name: 'create_charge',\n description: 'Cria uma cobrança PIX ou cartão B2B direto no ambiente sandbox MuPag.',\n inputSchema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n amount_cents: {\n type: 'integer',\n minimum: 100,\n maximum: MAX_MONEY_CENTS,\n description: 'Valor inteiro em centavos; mínimo de R$ 1,00.'\n },\n payment_method: { type: 'string', enum: ['pix', 'credit_card'] },\n customer: {\n type: 'object',\n additionalProperties: false,\n properties: {\n id: { type: 'string', minLength: 1, maxLength: MAX_IDENTIFIER_LENGTH },\n name: { type: 'string', minLength: 1, maxLength: 200 },\n email: { type: 'string', minLength: 3, maxLength: 254 },\n tax_id: { type: 'string', pattern: '^(?:[0-9]{11}|[0-9]{14})$' }\n },\n required: ['name', 'email', 'tax_id']\n },\n payer_ip: {\n type: 'string',\n minLength: 2,\n maxLength: 45,\n description: 'IP literal do pagador, atestado pelo merchant; obrigatório para cartão.'\n },\n card_token_id: {\n type: 'string',\n minLength: 1,\n maxLength: MAX_IDENTIFIER_LENGTH,\n description: 'Somente token opaco do PSP; PAN e CVV não são aceitos.'\n },\n installments: { type: 'integer', minimum: 1, maximum: 1 },\n description: { type: 'string', minLength: 1, maxLength: MAX_TEXT_LENGTH },\n ...MUTATION_GUARD_PROPERTIES\n },\n required: [\n 'amount_cents',\n 'payment_method',\n 'customer',\n ...MUTATION_REQUIRED\n ]\n },\n annotations: {\n title: 'Criar cobrança',\n destructiveHint: true,\n idempotentHint: true,\n openWorldHint: true\n }\n },\n {\n name: 'create_checkout_session',\n description: 'Cria uma sessão real de checkout hospedado PIX-only no sandbox MuPag.',\n inputSchema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n items: {\n type: 'array',\n minItems: 1,\n maxItems: 100,\n items: {\n type: 'object',\n additionalProperties: false,\n properties: {\n name: { type: 'string', minLength: 1, maxLength: 200 },\n quantity: { type: 'integer', minimum: 1, maximum: 100_000 },\n unit_amount_cents: {\n type: 'integer',\n minimum: 100,\n maximum: MAX_MONEY_CENTS\n }\n },\n required: ['name', 'quantity', 'unit_amount_cents']\n }\n },\n success_url: { type: 'string', minLength: 1, maxLength: 2_048 },\n cancel_url: { type: 'string', minLength: 1, maxLength: 2_048 },\n customer_id: { type: 'string', minLength: 1, maxLength: MAX_IDENTIFIER_LENGTH },\n customer_data: {\n type: 'object',\n additionalProperties: false,\n properties: {\n name: { type: 'string', minLength: 1, maxLength: 200 },\n email: { type: 'string', minLength: 3, maxLength: 254 },\n document: { type: 'string', pattern: '^(?:[0-9]{11}|[0-9]{14})$' },\n phone: { type: 'string', minLength: 8, maxLength: 20 }\n },\n minProperties: 1\n },\n allowed_payment_methods: {\n type: 'array',\n minItems: 1,\n maxItems: 1,\n uniqueItems: true,\n items: { type: 'string', enum: ['pix'] }\n },\n expires_in_minutes: { type: 'integer', minimum: 1, maximum: 1_440 },\n ...MUTATION_GUARD_PROPERTIES\n },\n required: ['items', 'success_url', 'cancel_url', ...MUTATION_REQUIRED]\n },\n annotations: {\n title: 'Criar sessão de checkout',\n destructiveHint: true,\n idempotentHint: true,\n openWorldHint: true\n }\n },\n {\n name: 'create_subscription',\n description: 'Cria uma assinatura recorrente no ambiente sandbox MuPag.',\n inputSchema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n customer_id: { type: 'string', minLength: 1, maxLength: MAX_IDENTIFIER_LENGTH },\n plan_id: { type: 'string', minLength: 1, maxLength: MAX_IDENTIFIER_LENGTH },\n payment_method: { type: 'string', enum: ['pix', 'credit_card'] },\n card_token_id: {\n type: 'string',\n minLength: 1,\n maxLength: MAX_IDENTIFIER_LENGTH,\n description: 'Somente token opaco do PSP; PAN e CVV não são aceitos.'\n },\n trial_days: { type: 'integer', minimum: 0, maximum: 365 },\n external_reference: {\n type: 'string',\n minLength: 1,\n maxLength: MAX_IDENTIFIER_LENGTH\n },\n ...MUTATION_GUARD_PROPERTIES\n },\n required: ['customer_id', 'plan_id', 'payment_method', ...MUTATION_REQUIRED]\n },\n annotations: {\n title: 'Criar assinatura',\n destructiveHint: true,\n idempotentHint: true,\n openWorldHint: true\n }\n },\n {\n name: 'cancel_subscription',\n description: 'Cancela uma assinatura no sandbox, imediatamente ou ao fim do período.',\n inputSchema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n subscription_id: {\n type: 'string',\n minLength: 1,\n maxLength: MAX_IDENTIFIER_LENGTH\n },\n mode: { type: 'string', enum: ['immediate', 'end_of_period'] },\n reason: { type: 'string', minLength: 1, maxLength: MAX_TEXT_LENGTH },\n ...MUTATION_GUARD_PROPERTIES\n },\n required: ['subscription_id', 'mode', ...MUTATION_REQUIRED]\n },\n annotations: {\n title: 'Cancelar assinatura',\n destructiveHint: true,\n idempotentHint: true,\n openWorldHint: true\n }\n },\n {\n name: 'refund_charge',\n description: 'Solicita estorno total explícito ou parcial de uma cobrança no sandbox.',\n inputSchema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n charge_id: { type: 'string', minLength: 1, maxLength: MAX_IDENTIFIER_LENGTH },\n amount_cents: {\n type: 'integer',\n minimum: 1,\n maximum: MAX_MONEY_CENTS\n },\n full: {\n type: 'boolean',\n const: true,\n description: 'Use true para estorno total; não combine com amount_cents.'\n },\n reason: { type: 'string', minLength: 1, maxLength: MAX_TEXT_LENGTH },\n ...MUTATION_GUARD_PROPERTIES\n },\n required: ['charge_id', ...MUTATION_REQUIRED],\n oneOf: [{ required: ['amount_cents'] }, { required: ['full'] }]\n },\n annotations: {\n title: 'Estornar cobrança',\n destructiveHint: true,\n idempotentHint: true,\n openWorldHint: true\n }\n },\n {\n name: 'list_charges',\n description: 'Lista cobranças do merchant autenticado com filtros e paginação limitada.',\n inputSchema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n status: { type: 'string', minLength: 1, maxLength: 64 },\n customer_id: { type: 'string', minLength: 1, maxLength: MAX_IDENTIFIER_LENGTH },\n payment_method: { type: 'string', enum: ['pix', 'credit_card'] },\n created_at_from: { type: 'string', minLength: 1, maxLength: 64 },\n created_at_to: { type: 'string', minLength: 1, maxLength: 64 },\n limit: { type: 'integer', minimum: 1, maximum: 100 },\n cursor: { type: 'string', minLength: 1, maxLength: MAX_CURSOR_LENGTH }\n }\n },\n annotations: {\n title: 'Listar cobranças',\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: true\n }\n },\n {\n name: 'get_refund',\n description: 'Consulta um estorno pelo ID no escopo do merchant autenticado.',\n inputSchema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n refund_id: { type: 'string', minLength: 1, maxLength: MAX_IDENTIFIER_LENGTH }\n },\n required: ['refund_id']\n },\n annotations: {\n title: 'Consultar estorno',\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: true\n }\n },\n {\n name: 'list_charge_refunds',\n description: 'Lista os estornos existentes de uma cobrança no merchant autenticado.',\n inputSchema: {\n type: 'object',\n additionalProperties: false,\n properties: {\n charge_id: { type: 'string', minLength: 1, maxLength: MAX_IDENTIFIER_LENGTH },\n limit: { type: 'integer', minimum: 1, maximum: 100 },\n cursor: { type: 'string', minLength: 1, maxLength: MAX_CURSOR_LENGTH }\n },\n required: ['charge_id']\n },\n annotations: {\n title: 'Listar estornos da cobrança',\n readOnlyHint: true,\n destructiveHint: false,\n idempotentHint: true,\n openWorldHint: true\n }\n }\n];\n\nexport type McpConfig = {\n apiKey: string;\n env: 'test';\n baseUrl: string | undefined;\n};\n\nexport type AuditEntry = {\n tool: string;\n approvalReference: string;\n idempotencyKeyHash: string;\n payloadHash: string;\n timestamp: string;\n};\n\nexport type AuditSink = (entry: AuditEntry) => void | Promise<void>;\n\ntype RequestOptions = { idempotencyKey: string };\n\n/** Subconjunto mínimo do SDK utilizado pelas ferramentas; facilita testes sem rede. */\nexport type PaymentSdk = {\n charges: {\n create(params: Record<string, unknown>, options: RequestOptions): Promise<unknown>;\n list(params: Record<string, unknown>): Promise<unknown>;\n };\n checkoutSessions: {\n create(params: Record<string, unknown>, options: RequestOptions): Promise<unknown>;\n };\n subscriptions: {\n create(params: Record<string, unknown>, options: RequestOptions): Promise<unknown>;\n cancel(\n id: string,\n params: Record<string, unknown>,\n options: RequestOptions\n ): Promise<unknown>;\n };\n refunds: {\n create(\n chargeId: string,\n params: Record<string, unknown>,\n options: RequestOptions\n ): Promise<unknown>;\n get(refundId: string): Promise<unknown>;\n listByCharge(chargeId: string, params?: Record<string, unknown>): Promise<unknown>;\n };\n};\n\ntype PreparedMutation = {\n kind: 'mutation';\n idempotencyKey: string;\n approvalReference: string;\n fingerprintPayload: unknown;\n invoke: () => Promise<unknown>;\n};\n\ntype PreparedRead = {\n kind: 'read';\n invoke: () => Promise<unknown>;\n};\n\ntype PreparedCall = PreparedMutation | PreparedRead;\n\ntype InFlightMutation = {\n fingerprint: string;\n result: Promise<CallToolResult>;\n};\n\n/**\n * Lê configuração sem defaults perigosos. Prd é rejeitado de propósito: este\n * servidor só é habilitado enquanto o produto está no ciclo sandbox.\n */\nexport function readConfig(\n environment: Readonly<Record<string, string | undefined>>\n): McpConfig {\n const apiKey = environment.MUPAG_API_KEY;\n if (apiKey === undefined || apiKey.length === 0) {\n throw new Error('MUPAG_API_KEY é obrigatória.');\n }\n if (\n apiKey.length > MAX_API_KEY_LENGTH ||\n apiKey.trim() !== apiKey ||\n hasControlCharacter(apiKey)\n ) {\n throw new Error('MUPAG_API_KEY inválida.');\n }\n\n const configuredEnvironment = environment.MUPAG_ENV;\n if (configuredEnvironment === undefined || configuredEnvironment.length === 0) {\n throw new Error('MUPAG_ENV é obrigatória.');\n }\n if (configuredEnvironment === 'prd') {\n throw new Error('O MCP está habilitado somente para sandbox; prd não está disponível.');\n }\n if (configuredEnvironment !== 'test') {\n throw new Error('MUPAG_ENV deve selecionar explicitamente o ambiente test.');\n }\n if (!apiKey.startsWith('sk_test_')) {\n throw new Error('MUPAG_API_KEY não corresponde ao ambiente test.');\n }\n\n const rawBaseUrl = environment.MUPAG_API_URL;\n const baseUrl = rawBaseUrl === undefined ? undefined : validateBaseUrl(rawBaseUrl);\n return { apiKey, env: 'test', baseUrl };\n}\n\n/** Cria o servidor MCP usando exclusivamente o SDK oficial endurecido. */\nexport function createMuPagServer(\n config: McpConfig,\n options: { sdk?: PaymentSdk; auditSink?: AuditSink } = {}\n): Server {\n const sdk =\n options.sdk ??\n (new MuPag({\n apiKey: config.apiKey,\n env: config.env,\n baseUrl: config.baseUrl,\n timeoutMs: 15_000,\n maxResponseBytes: MAX_RESPONSE_BYTES,\n retry: {\n maxRetries: 2,\n initialDelayMs: 250,\n maxDelayMs: 2_000\n }\n }) as unknown as PaymentSdk);\n const executor = createToolExecutor(sdk, options.auditSink ?? writeAuditEntry);\n const server = new Server(\n { name: 'mupag-mcp-server', version: '0.1.0' },\n {\n capabilities: { tools: {} },\n instructions:\n 'Servidor MuPag exclusivo de sandbox. Mutações exigem aprovação explícita e Idempotency-Key estável.'\n }\n );\n\n server.setRequestHandler(ListToolsRequestSchema, async () => ({\n tools: TOOL_DEFINITIONS\n }));\n server.setRequestHandler(CallToolRequestSchema, async (request) =>\n executor(request.params.name, request.params.arguments)\n );\n return server;\n}\n\n/**\n * Executor isolado e testável. Valida integralmente antes da chamada, coalesce\n * concorrência idêntica e rejeita reuso conflitante da mesma chave localmente.\n */\nexport function createToolExecutor(\n sdk: PaymentSdk,\n auditSink: AuditSink = () => undefined\n): (name: string, args: unknown) => Promise<CallToolResult> {\n const inFlight = new Map<string, InFlightMutation>();\n\n return async (name: string, args: unknown): Promise<CallToolResult> => {\n let prepared: PreparedCall;\n try {\n assertInputBudget(args);\n prepared = prepareCall(name, args, sdk);\n } catch (error) {\n return toolError(error instanceof UnknownToolError ? 'tool_not_found' : 'entrada_invalida');\n }\n\n if (prepared.kind === 'read') {\n return invokeAndSerialize(prepared.invoke);\n }\n\n const mapKey = `${name}:${prepared.idempotencyKey}`;\n const fingerprint = sha256(stableStringify(prepared.fingerprintPayload));\n const existing = inFlight.get(mapKey);\n if (existing !== undefined) {\n if (existing.fingerprint !== fingerprint) {\n return toolError('idempotency_conflict');\n }\n return existing.result;\n }\n if (inFlight.size >= MAX_IN_FLIGHT_MUTATIONS) {\n return toolError('server_busy');\n }\n\n let result: Promise<CallToolResult>;\n result = runMutation(\n name,\n prepared,\n fingerprint,\n auditSink\n ).finally(() => {\n if (inFlight.get(mapKey)?.result === result) {\n inFlight.delete(mapKey);\n }\n });\n inFlight.set(mapKey, { fingerprint, result });\n return result;\n };\n}\n\nasync function runMutation(\n name: string,\n prepared: PreparedMutation,\n fingerprint: string,\n auditSink: AuditSink\n): Promise<CallToolResult> {\n try {\n await auditSink({\n tool: name,\n approvalReference: prepared.approvalReference,\n idempotencyKeyHash: sha256(prepared.idempotencyKey),\n payloadHash: fingerprint,\n timestamp: new Date().toISOString()\n });\n } catch {\n return toolError('audit_unavailable');\n }\n return invokeAndSerialize(prepared.invoke);\n}\n\nasync function invokeAndSerialize(invoke: () => Promise<unknown>): Promise<CallToolResult> {\n try {\n return serializeResult(await invoke());\n } catch (error) {\n return safeSdkError(error);\n }\n}\n\nfunction prepareCall(name: string, args: unknown, sdk: PaymentSdk): PreparedCall {\n switch (name) {\n case 'create_charge':\n return prepareCreateCharge(args, sdk);\n case 'create_checkout_session':\n return prepareCheckoutSession(args, sdk);\n case 'create_subscription':\n return prepareCreateSubscription(args, sdk);\n case 'cancel_subscription':\n return prepareCancelSubscription(args, sdk);\n case 'refund_charge':\n return prepareRefund(args, sdk);\n case 'list_charges':\n return prepareListCharges(args, sdk);\n case 'get_refund':\n return prepareGetRefund(args, sdk);\n case 'list_charge_refunds':\n return prepareListChargeRefunds(args, sdk);\n default:\n throw new UnknownToolError();\n }\n}\n\nfunction prepareCreateCharge(args: unknown, sdk: PaymentSdk): PreparedMutation {\n const input = strictObject(args, [\n 'amount_cents',\n 'payment_method',\n 'customer',\n 'payer_ip',\n 'card_token_id',\n 'installments',\n 'description',\n ...MUTATION_REQUIRED\n ]);\n const guards = mutationGuards(input);\n const amount = integer(input.amount_cents, 100, MAX_MONEY_CENTS);\n const paymentMethod = enumValue(input.payment_method, ['pix', 'credit_card'] as const);\n const customer = chargeCustomer(input.customer);\n const payerIp = optionalIpLiteral(input.payer_ip);\n const description = optionalPanSafeText(input.description, MAX_TEXT_LENGTH);\n const cardTokenId = optionalCardTokenIdentifier(input.card_token_id);\n const installments = optionalInteger(input.installments, 1, 1);\n\n if (paymentMethod === 'credit_card' && (cardTokenId === undefined || payerIp === undefined)) {\n throw new ValidationFailure();\n }\n if (paymentMethod === 'pix' && (cardTokenId !== undefined || installments !== undefined)) {\n throw new ValidationFailure();\n }\n\n const params: Record<string, unknown> = {\n amount_cents: amount,\n payment_method: paymentMethod,\n customer\n };\n addDefined(params, 'payer_ip', payerIp);\n addDefined(params, 'card_token_id', cardTokenId);\n addDefined(params, 'installments', installments);\n addDefined(params, 'description', description);\n\n return mutation(\n guards,\n { params },\n () => sdk.charges.create(params, { idempotencyKey: guards.idempotencyKey })\n );\n}\n\nfunction prepareCheckoutSession(args: unknown, sdk: PaymentSdk): PreparedMutation {\n const input = strictObject(args, [\n 'items',\n 'success_url',\n 'cancel_url',\n 'customer_id',\n 'customer_data',\n 'allowed_payment_methods',\n 'expires_in_minutes',\n ...MUTATION_REQUIRED\n ]);\n const guards = mutationGuards(input);\n if (!Array.isArray(input.items) || input.items.length < 1 || input.items.length > 100) {\n throw new ValidationFailure();\n }\n\n let total = 0;\n const items = input.items.map((rawItem) => {\n const item = strictObject(rawItem, ['name', 'quantity', 'unit_amount_cents']);\n requireOwn(item, ['name', 'quantity', 'unit_amount_cents']);\n const name = panSafeText(requiredText(item.name, 200));\n const quantity = integer(item.quantity, 1, 100_000);\n const unitAmount = integer(item.unit_amount_cents, 100, MAX_MONEY_CENTS);\n const lineTotal = quantity * unitAmount;\n if (!Number.isSafeInteger(lineTotal) || lineTotal > MAX_MONEY_CENTS - total) {\n throw new ValidationFailure();\n }\n total += lineTotal;\n return { name, quantity, unit_amount_cents: unitAmount };\n });\n\n const successUrl = redirectUrl(input.success_url);\n const cancelUrl = redirectUrl(input.cancel_url);\n const customerId = optionalPanSafeIdentifier(input.customer_id);\n const customerData = optionalCheckoutCustomer(input.customer_data);\n if (customerId !== undefined && customerData !== undefined) {\n throw new ValidationFailure();\n }\n const allowedPaymentMethods = optionalPaymentMethods(input.allowed_payment_methods);\n const expiresInMinutes = optionalInteger(input.expires_in_minutes, 1, 1_440);\n\n const params: Record<string, unknown> = {\n items,\n success_url: successUrl,\n cancel_url: cancelUrl\n };\n addDefined(params, 'customer_id', customerId);\n addDefined(params, 'customer_data', customerData);\n addDefined(params, 'allowed_payment_methods', allowedPaymentMethods);\n addDefined(params, 'expires_in_minutes', expiresInMinutes);\n\n return mutation(\n guards,\n { params },\n () => sdk.checkoutSessions.create(params, { idempotencyKey: guards.idempotencyKey })\n );\n}\n\nfunction prepareCreateSubscription(args: unknown, sdk: PaymentSdk): PreparedMutation {\n const input = strictObject(args, [\n 'customer_id',\n 'plan_id',\n 'payment_method',\n 'card_token_id',\n 'trial_days',\n 'external_reference',\n ...MUTATION_REQUIRED\n ]);\n const guards = mutationGuards(input);\n const customerId = panSafeText(identifier(input.customer_id));\n const planId = identifier(input.plan_id);\n const paymentMethod = enumValue(input.payment_method, ['pix', 'credit_card'] as const);\n const cardTokenId = optionalCardTokenIdentifier(input.card_token_id);\n const trialDays = optionalInteger(input.trial_days, 0, 365);\n const externalReference = optionalPanSafeIdentifier(input.external_reference);\n if (paymentMethod === 'credit_card' && cardTokenId === undefined) {\n throw new ValidationFailure();\n }\n if (paymentMethod === 'pix' && cardTokenId !== undefined) {\n throw new ValidationFailure();\n }\n\n const params: Record<string, unknown> = {\n customer_id: customerId,\n plan_id: planId,\n payment_method: paymentMethod\n };\n addDefined(params, 'card_token_id', cardTokenId);\n addDefined(params, 'trial_days', trialDays);\n addDefined(params, 'external_reference', externalReference);\n\n return mutation(\n guards,\n { params },\n () => sdk.subscriptions.create(params, { idempotencyKey: guards.idempotencyKey })\n );\n}\n\nfunction prepareCancelSubscription(args: unknown, sdk: PaymentSdk): PreparedMutation {\n const input = strictObject(args, [\n 'subscription_id',\n 'mode',\n 'reason',\n ...MUTATION_REQUIRED\n ]);\n const guards = mutationGuards(input);\n const subscriptionId = panSafeText(identifier(input.subscription_id));\n const mode = enumValue(input.mode, ['immediate', 'end_of_period'] as const);\n const reason = optionalPanSafeText(input.reason, MAX_TEXT_LENGTH);\n const params: Record<string, unknown> = { mode };\n addDefined(params, 'reason', reason);\n\n return mutation(\n guards,\n { subscription_id: subscriptionId, params },\n () =>\n sdk.subscriptions.cancel(subscriptionId, params, {\n idempotencyKey: guards.idempotencyKey\n })\n );\n}\n\nfunction prepareRefund(args: unknown, sdk: PaymentSdk): PreparedMutation {\n const input = strictObject(args, [\n 'charge_id',\n 'amount_cents',\n 'full',\n 'reason',\n ...MUTATION_REQUIRED\n ]);\n const guards = mutationGuards(input);\n const chargeId = panSafeText(identifier(input.charge_id));\n const amount = optionalInteger(input.amount_cents, 1, MAX_MONEY_CENTS);\n const full = input.full;\n if ((amount === undefined && full !== true) || (amount !== undefined && full !== undefined)) {\n throw new ValidationFailure();\n }\n const reason = optionalPanSafeText(input.reason, MAX_TEXT_LENGTH);\n const params: Record<string, unknown> = {};\n if (amount === undefined) {\n params.full = true;\n } else {\n params.amount_cents = amount;\n }\n addDefined(params, 'reason', reason);\n\n return mutation(\n guards,\n { charge_id: chargeId, params },\n () => sdk.refunds.create(chargeId, params, { idempotencyKey: guards.idempotencyKey })\n );\n}\n\nfunction prepareListCharges(args: unknown, sdk: PaymentSdk): PreparedRead {\n const input = strictObject(args ?? {}, [\n 'status',\n 'customer_id',\n 'payment_method',\n 'created_at_from',\n 'created_at_to',\n 'limit',\n 'cursor'\n ]);\n const params: Record<string, unknown> = {};\n addDefined(params, 'status', optionalSlug(input.status, 64));\n addDefined(params, 'customer_id', optionalPanSafeIdentifier(input.customer_id));\n addDefined(\n params,\n 'payment_method',\n optionalEnumValue(input.payment_method, ['pix', 'credit_card'] as const)\n );\n const createdAtFrom = optionalTimestamp(input.created_at_from);\n const createdAtTo = optionalTimestamp(input.created_at_to);\n if (\n createdAtFrom !== undefined &&\n createdAtTo !== undefined &&\n Date.parse(createdAtFrom) > Date.parse(createdAtTo)\n ) {\n throw new ValidationFailure();\n }\n addDefined(params, 'created_at_from', createdAtFrom);\n addDefined(params, 'created_at_to', createdAtTo);\n addDefined(params, 'limit', optionalInteger(input.limit, 1, 100));\n addDefined(params, 'cursor', optionalVisibleAscii(input.cursor, MAX_CURSOR_LENGTH));\n return { kind: 'read', invoke: () => sdk.charges.list(params) };\n}\n\nfunction prepareGetRefund(args: unknown, sdk: PaymentSdk): PreparedRead {\n const input = strictObject(args, ['refund_id']);\n requireOwn(input, ['refund_id']);\n const refundId = panSafeText(identifier(input.refund_id));\n return { kind: 'read', invoke: () => sdk.refunds.get(refundId) };\n}\n\nfunction prepareListChargeRefunds(args: unknown, sdk: PaymentSdk): PreparedRead {\n const input = strictObject(args, ['charge_id', 'limit', 'cursor']);\n requireOwn(input, ['charge_id']);\n const chargeId = panSafeText(identifier(input.charge_id));\n const params: Record<string, unknown> = {};\n addDefined(params, 'limit', optionalInteger(input.limit, 1, 100));\n addDefined(params, 'cursor', optionalVisibleAscii(input.cursor, MAX_CURSOR_LENGTH));\n return { kind: 'read', invoke: () => sdk.refunds.listByCharge(chargeId, params) };\n}\n\nfunction mutation(\n guards: { idempotencyKey: string; approvalReference: string },\n fingerprintPayload: unknown,\n invoke: () => Promise<unknown>\n): PreparedMutation {\n return {\n kind: 'mutation',\n ...guards,\n fingerprintPayload,\n invoke\n };\n}\n\nfunction mutationGuards(input: Record<string, unknown>): {\n idempotencyKey: string;\n approvalReference: string;\n} {\n requireOwn(input, MUTATION_REQUIRED);\n if (input.confirm_financial_effect !== true) {\n throw new ValidationFailure();\n }\n const idempotencyKey = panSafeVisibleAscii(\n input.idempotency_key,\n MAX_IDEMPOTENCY_KEY_LENGTH\n );\n if (typeof input.approval_reference !== 'string') {\n throw new ValidationFailure();\n }\n const approvalReference = stringMatching(\n panSafeText(input.approval_reference),\n APPROVAL_REFERENCE_PATTERN,\n MAX_IDENTIFIER_LENGTH\n );\n return { idempotencyKey, approvalReference };\n}\n\nfunction chargeCustomer(value: unknown): Record<string, unknown> {\n const customer = strictObject(value, ['id', 'name', 'email', 'tax_id']);\n const id = optionalPanSafeIdentifier(customer.id);\n const name = optionalPanSafeText(customer.name, 200);\n const email = optionalPanSafeEmail(customer.email);\n const taxId = optionalTaxId(customer.tax_id);\n if (name === undefined || email === undefined || taxId === undefined) {\n throw new ValidationFailure();\n }\n const result: Record<string, unknown> = { name, email, tax_id: taxId };\n addDefined(result, 'id', id);\n return result;\n}\n\nfunction optionalIpLiteral(value: unknown): string | undefined {\n if (value === undefined) {\n return undefined;\n }\n if (typeof value !== 'string' || value.length > 45 || isIP(value) === 0) {\n throw new ValidationFailure();\n }\n return value;\n}\n\nfunction optionalCheckoutCustomer(value: unknown): Record<string, unknown> | undefined {\n if (value === undefined) {\n return undefined;\n }\n const customer = strictObject(value, ['name', 'email', 'document', 'phone']);\n const result: Record<string, unknown> = {};\n addDefined(result, 'name', optionalPanSafeText(customer.name, 200));\n addDefined(result, 'email', optionalPanSafeEmail(customer.email));\n addDefined(result, 'document', optionalTaxId(customer.document));\n addDefined(result, 'phone', optionalPhone(customer.phone));\n if (Object.keys(result).length === 0) {\n throw new ValidationFailure();\n }\n return result;\n}\n\nfunction optionalPaymentMethods(value: unknown): Array<'pix'> | undefined {\n if (value === undefined) {\n return undefined;\n }\n if (!Array.isArray(value) || value.length !== 1) {\n throw new ValidationFailure();\n }\n const methods = value.map((item) => enumValue(item, ['pix'] as const));\n if (new Set(methods).size !== methods.length) {\n throw new ValidationFailure();\n }\n return methods;\n}\n\nfunction strictObject(value: unknown, allowedKeys: readonly string[]): Record<string, unknown> {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n throw new ValidationFailure();\n }\n const prototype = Object.getPrototypeOf(value);\n if (prototype !== Object.prototype && prototype !== null) {\n throw new ValidationFailure();\n }\n const record = value as Record<string, unknown>;\n const allowed = new Set(allowedKeys);\n for (const key of Object.keys(record)) {\n if (!allowed.has(key)) {\n throw new ValidationFailure();\n }\n }\n return record;\n}\n\nfunction requireOwn(value: Record<string, unknown>, keys: readonly string[]): void {\n for (const key of keys) {\n if (!Object.prototype.hasOwnProperty.call(value, key)) {\n throw new ValidationFailure();\n }\n }\n}\n\nfunction integer(value: unknown, minimum: number, maximum: number): number {\n if (\n typeof value !== 'number' ||\n !Number.isSafeInteger(value) ||\n value < minimum ||\n value > maximum\n ) {\n throw new ValidationFailure();\n }\n return value;\n}\n\nfunction optionalInteger(\n value: unknown,\n minimum: number,\n maximum: number\n): number | undefined {\n return value === undefined ? undefined : integer(value, minimum, maximum);\n}\n\nfunction enumValue<const T extends readonly string[]>(value: unknown, allowed: T): T[number] {\n if (typeof value !== 'string' || !allowed.includes(value)) {\n throw new ValidationFailure();\n }\n return value as T[number];\n}\n\nfunction optionalEnumValue<const T extends readonly string[]>(\n value: unknown,\n allowed: T\n): T[number] | undefined {\n return value === undefined ? undefined : enumValue(value, allowed);\n}\n\nfunction identifier(value: unknown): string {\n return stringMatching(value, IDENTIFIER_PATTERN, MAX_IDENTIFIER_LENGTH);\n}\n\nfunction optionalIdentifier(value: unknown): string | undefined {\n return value === undefined ? undefined : identifier(value);\n}\n\nfunction optionalCardTokenIdentifier(value: unknown): string | undefined {\n const cardTokenId = optionalIdentifier(value);\n if (cardTokenId !== undefined && containsPanLikeSequence(cardTokenId)) {\n throw new ValidationFailure();\n }\n return cardTokenId;\n}\n\nfunction panSafeText(value: string): string {\n if (containsPanLikeSequence(value)) {\n throw new ValidationFailure();\n }\n return value;\n}\n\nfunction optionalPanSafeText(value: unknown, maximumLength: number): string | undefined {\n const parsed = optionalText(value, maximumLength);\n return parsed === undefined ? undefined : panSafeText(parsed);\n}\n\nfunction optionalPanSafeEmail(value: unknown): string | undefined {\n const parsed = optionalEmail(value);\n return parsed === undefined ? undefined : panSafeText(parsed);\n}\n\nfunction optionalPanSafeIdentifier(value: unknown): string | undefined {\n const parsed = optionalIdentifier(value);\n return parsed === undefined ? undefined : panSafeText(parsed);\n}\n\nfunction containsPanLikeSequence(value: string): boolean {\n let retainedDigits = '';\n for (const character of value) {\n if (character >= '0' && character <= '9') {\n retainedDigits = (retainedDigits + character).slice(-19);\n for (let length = 12; length <= retainedDigits.length; length += 1) {\n if (validPanSequence(retainedDigits.slice(-length))) return true;\n }\n } else if (/^[\\s\\p{P}\\p{S}\\p{M}\\p{Cc}\\p{Cf}]$/u.test(character)) {\n continue;\n } else {\n retainedDigits = '';\n }\n }\n return false;\n}\n\nfunction validPanSequence(digits: string): boolean {\n if (!/^[0-9]{12,19}$/.test(digits)) return false;\n let total = 0;\n let doubleDigit = false;\n for (let index = digits.length - 1; index >= 0; index -= 1) {\n let digit = digits.charCodeAt(index) - 48;\n if (doubleDigit) {\n digit *= 2;\n if (digit > 9) digit -= 9;\n }\n total += digit;\n doubleDigit = !doubleDigit;\n }\n return total % 10 === 0;\n}\n\nfunction visibleAscii(value: unknown, maximumLength: number): string {\n if (\n typeof value !== 'string' ||\n value.length < 1 ||\n value.length > maximumLength ||\n !/^[\\x21-\\x7e]+$/.test(value)\n ) {\n throw new ValidationFailure();\n }\n return value;\n}\n\nfunction panSafeVisibleAscii(value: unknown, maximumLength: number): string {\n if (typeof value !== 'string' || containsPanLikeSequence(value)) {\n throw new ValidationFailure();\n }\n return visibleAscii(value, maximumLength);\n}\n\nfunction optionalVisibleAscii(value: unknown, maximumLength: number): string | undefined {\n return value === undefined ? undefined : visibleAscii(value, maximumLength);\n}\n\nfunction stringMatching(value: unknown, pattern: RegExp, maximumLength: number): string {\n if (\n typeof value !== 'string' ||\n value.length < 1 ||\n value.length > maximumLength ||\n !pattern.test(value)\n ) {\n throw new ValidationFailure();\n }\n return value;\n}\n\nfunction requiredText(value: unknown, maximumLength: number): string {\n if (typeof value !== 'string' || value.trim().length === 0 || value.length > maximumLength) {\n throw new ValidationFailure();\n }\n if (hasUnsafeTextControl(value)) {\n throw new ValidationFailure();\n }\n return value.trim();\n}\n\nfunction optionalText(value: unknown, maximumLength: number): string | undefined {\n return value === undefined ? undefined : requiredText(value, maximumLength);\n}\n\nfunction optionalSlug(value: unknown, maximumLength: number): string | undefined {\n if (value === undefined) {\n return undefined;\n }\n return stringMatching(value, /^[a-z][a-z0-9_-]*$/, maximumLength);\n}\n\nfunction optionalEmail(value: unknown): string | undefined {\n if (value === undefined) {\n return undefined;\n }\n if (\n typeof value !== 'string' ||\n value.length < 3 ||\n value.length > 254 ||\n !/^[^\\s@]+@[^\\s@]+\\.[^\\s@]+$/.test(value) ||\n hasControlCharacter(value)\n ) {\n throw new ValidationFailure();\n }\n return value;\n}\n\nfunction optionalTaxId(value: unknown): string | undefined {\n if (value === undefined) {\n return undefined;\n }\n if (typeof value !== 'string' || !/^(?:\\d{11}|\\d{14})$/.test(value)) {\n throw new ValidationFailure();\n }\n return value;\n}\n\nfunction optionalPhone(value: unknown): string | undefined {\n if (value === undefined) {\n return undefined;\n }\n if (typeof value !== 'string' || !/^\\+?[0-9 ()-]{8,20}$/.test(value)) {\n throw new ValidationFailure();\n }\n return value;\n}\n\nfunction optionalTimestamp(value: unknown): string | undefined {\n if (value === undefined) {\n return undefined;\n }\n if (\n typeof value !== 'string' ||\n value.length < 1 ||\n value.length > 64 ||\n !Number.isFinite(Date.parse(value))\n ) {\n throw new ValidationFailure();\n }\n return value;\n}\n\nfunction redirectUrl(value: unknown): string {\n if (typeof value !== 'string' || value.length < 1 || value.length > 2_048) {\n throw new ValidationFailure();\n }\n let parsed: URL;\n try {\n parsed = new URL(value);\n } catch {\n throw new ValidationFailure();\n }\n if (\n parsed.username !== '' ||\n parsed.password !== '' ||\n parsed.hash !== '' ||\n !isAllowedHttpUrl(parsed)\n ) {\n throw new ValidationFailure();\n }\n return parsed.toString();\n}\n\nfunction validateBaseUrl(value: string): string {\n if (value.length < 1 || value.length > 2_048 || value.trim() !== value) {\n throw new Error('MUPAG_API_URL inválida.');\n }\n let parsed: URL;\n try {\n parsed = new URL(value);\n } catch {\n throw new Error('MUPAG_API_URL inválida.');\n }\n if (\n parsed.username !== '' ||\n parsed.password !== '' ||\n parsed.search !== '' ||\n parsed.hash !== '' ||\n (parsed.pathname !== '' && parsed.pathname !== '/') ||\n !isAllowedHttpUrl(parsed)\n ) {\n throw new Error('MUPAG_API_URL inválida.');\n }\n return `${parsed.protocol}//${parsed.host}`;\n}\n\nfunction isAllowedHttpUrl(value: URL): boolean {\n if (value.protocol === 'https:') {\n return value.hostname.length > 0;\n }\n return value.protocol === 'http:' && isLoopbackHost(value.hostname);\n}\n\nfunction isLoopbackHost(hostname: string): boolean {\n const normalized = hostname.toLowerCase().replace(/^\\[|\\]$/g, '');\n return normalized === 'localhost' || normalized === '127.0.0.1' || normalized === '::1';\n}\n\nfunction assertInputBudget(value: unknown): void {\n const stack: Array<{ value: unknown; depth: number }> = [{ value, depth: 0 }];\n const seen = new WeakSet<object>();\n let bytes = 0;\n let nodes = 0;\n\n while (stack.length > 0) {\n const current = stack.pop();\n if (current === undefined) {\n break;\n }\n nodes++;\n if (nodes > 10_000 || current.depth > 10) {\n throw new ValidationFailure();\n }\n const item = current.value;\n if (typeof item === 'string') {\n bytes += Buffer.byteLength(item, 'utf8');\n } else if (typeof item === 'number' || typeof item === 'boolean' || item === null) {\n bytes += 16;\n } else if (typeof item === 'object') {\n if (item === null || seen.has(item)) {\n if (item !== null) {\n throw new ValidationFailure();\n }\n } else {\n seen.add(item);\n if (Array.isArray(item)) {\n for (const child of item) {\n stack.push({ value: child, depth: current.depth + 1 });\n }\n } else {\n for (const [key, child] of Object.entries(item)) {\n bytes += Buffer.byteLength(key, 'utf8');\n stack.push({ value: child, depth: current.depth + 1 });\n }\n }\n }\n } else if (item !== undefined) {\n throw new ValidationFailure();\n }\n if (bytes > MAX_INPUT_BYTES) {\n throw new ValidationFailure();\n }\n }\n}\n\nfunction serializeResult(value: unknown): CallToolResult {\n let serialized: string;\n try {\n serialized = JSON.stringify(value);\n } catch {\n return toolError('invalid_sdk_response');\n }\n if (serialized === undefined) {\n return toolError('invalid_sdk_response');\n }\n if (Buffer.byteLength(serialized, 'utf8') > MAX_OUTPUT_BYTES) {\n return toolError('output_too_large');\n }\n return { content: [{ type: 'text', text: serialized }] };\n}\n\nfunction safeSdkError(error: unknown): CallToolResult {\n if (error instanceof MuPagError) {\n const payload: Record<string, unknown> = {\n code:\n typeof error.code === 'string' && SAFE_ERROR_CODE_PATTERN.test(error.code)\n ? error.code\n : 'api_error'\n };\n if (\n typeof error.status === 'number' &&\n Number.isInteger(error.status) &&\n error.status >= 400 &&\n error.status <= 599\n ) {\n payload.status = error.status;\n }\n if (typeof error.requestId === 'string' && IDENTIFIER_PATTERN.test(error.requestId)) {\n payload.request_id = error.requestId;\n }\n return toolErrorPayload(payload);\n }\n return toolError('sdk_error');\n}\n\nfunction toolError(code: string): CallToolResult {\n return toolErrorPayload({ code });\n}\n\nfunction toolErrorPayload(payload: Record<string, unknown>): CallToolResult {\n return {\n isError: true,\n content: [{ type: 'text', text: JSON.stringify({ error: payload }) }]\n };\n}\n\nfunction stableStringify(value: unknown): string {\n if (value === null || typeof value !== 'object') {\n return JSON.stringify(value);\n }\n if (Array.isArray(value)) {\n return `[${value.map(stableStringify).join(',')}]`;\n }\n const record = value as Record<string, unknown>;\n const pairs = Object.keys(record)\n .sort()\n .map((key) => `${JSON.stringify(key)}:${stableStringify(record[key])}`);\n return `{${pairs.join(',')}}`;\n}\n\nfunction sha256(value: string): string {\n return createHash('sha256').update(value, 'utf8').digest('hex');\n}\n\nfunction addDefined(target: Record<string, unknown>, key: string, value: unknown): void {\n if (value !== undefined) {\n target[key] = value;\n }\n}\n\nfunction hasControlCharacter(value: string): boolean {\n return /[\\u0000-\\u001f\\u007f]/.test(value);\n}\n\nfunction hasUnsafeTextControl(value: string): boolean {\n return /[\\u0000-\\u0008\\u000b\\u000c\\u000e-\\u001f\\u007f]/.test(value);\n}\n\nfunction writeAuditEntry(entry: AuditEntry): void {\n process.stderr.write(`${JSON.stringify({ event: 'mupag_mcp_financial_command', ...entry })}\\n`);\n}\n\nclass ValidationFailure extends Error {}\nclass UnknownToolError extends Error {}\n"],"mappings":";AAAA,SAAS,kBAAkB;AAC3B,SAAS,YAAY;AAErB,SAAS,cAAc;AACvB;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AACP,SAAS,OAAO,kBAAkB;AAElC,IAAM,qBAAqB;AAC3B,IAAM,6BAA6B;AACnC,IAAM,wBAAwB;AAC9B,IAAM,oBAAoB;AAC1B,IAAM,kBAAkB;AACxB,IAAM,kBAAkB,KAAK;AAC7B,IAAM,mBAAmB,KAAK;AAC9B,IAAM,qBAAqB,IAAI,OAAO;AACtC,IAAM,kBAAkB;AACxB,IAAM,0BAA0B;AAChC,IAAM,qBAAqB;AAC3B,IAAM,6BAA6B;AACnC,IAAM,0BAA0B;AAEhC,IAAM,4BAA4B;AAAA,EAChC,iBAAiB;AAAA,IACf,MAAM;AAAA,IACN,WAAW;AAAA,IACX,WAAW;AAAA,IACX,SAAS;AAAA,IACT,aAAa;AAAA,EACf;AAAA,EACA,oBAAoB;AAAA,IAClB,MAAM;AAAA,IAC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F;AAEA,SAAS,oBAAoB,OAAwB;AACnD,SAAO,wBAAwB,KAAK,KAAK;AAC3C;AAEA,SAAS,qBAAqB,OAAwB;AACpD,SAAO,iDAAiD,KAAK,KAAK;AACpE;AAEA,SAAS,gBAAgB,OAAyB;AAChD,UAAQ,OAAO,MAAM,GAAG,KAAK,UAAU,EAAE,OAAO,+BAA+B,GAAG,MAAM,CAAC,CAAC;AAAA,CAAI;AAChG;AAEA,IAAM,oBAAN,cAAgC,MAAM;AAAC;AACvC,IAAM,mBAAN,cAA+B,MAAM;AAAC;","names":[]}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
createMuPagServer,
|
|
4
|
+
readConfig
|
|
5
|
+
} from "./chunk-ZGVY3GVY.js";
|
|
6
|
+
|
|
7
|
+
// src/index.ts
|
|
8
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
9
|
+
import dotenv from "dotenv";
|
|
10
|
+
dotenv.config();
|
|
11
|
+
async function main() {
|
|
12
|
+
const config = readConfig(process.env);
|
|
13
|
+
const server = createMuPagServer(config);
|
|
14
|
+
await server.connect(new StdioServerTransport());
|
|
15
|
+
}
|
|
16
|
+
main().catch(() => {
|
|
17
|
+
process.stderr.write("N\xE3o foi poss\xEDvel iniciar o MuPag MCP Server. Verifique a configura\xE7\xE3o.\n");
|
|
18
|
+
process.exitCode = 1;
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';\nimport dotenv from 'dotenv';\n\nimport { createMuPagServer, readConfig } from './server.js';\n\ndotenv.config();\n\nasync function main(): Promise<void> {\n const config = readConfig(process.env);\n const server = createMuPagServer(config);\n await server.connect(new StdioServerTransport());\n}\n\nmain().catch(() => {\n // Nunca imprima o erro bruto: configuração e falhas de transporte podem conter\n // chaves, URLs internas, caminhos locais ou outros dados sensíveis.\n process.stderr.write('Não foi possível iniciar o MuPag MCP Server. Verifique a configuração.\\n');\n process.exitCode = 1;\n});\n"],"mappings":";;;;;;;AAEA,SAAS,4BAA4B;AACrC,OAAO,YAAY;AAInB,OAAO,OAAO;AAEd,eAAe,OAAsB;AACnC,QAAM,SAAS,WAAW,QAAQ,GAAG;AACrC,QAAM,SAAS,kBAAkB,MAAM;AACvC,QAAM,OAAO,QAAQ,IAAI,qBAAqB,CAAC;AACjD;AAEA,KAAK,EAAE,MAAM,MAAM;AAGjB,UAAQ,OAAO,MAAM,sFAA0E;AAC/F,UAAQ,WAAW;AACrB,CAAC;","names":[]}
|
package/dist/server.d.ts
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
2
|
+
import { Tool, CallToolResult } from '@modelcontextprotocol/sdk/types.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Catálogo deliberadamente pequeno. Cada mutação exige confirmação e chave fornecidas
|
|
6
|
+
* pelo chamador; o servidor nunca inventa uma intenção financeira nem uma chave por ele.
|
|
7
|
+
*/
|
|
8
|
+
declare const TOOL_DEFINITIONS: Tool[];
|
|
9
|
+
type McpConfig = {
|
|
10
|
+
apiKey: string;
|
|
11
|
+
env: 'test';
|
|
12
|
+
baseUrl: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
type AuditEntry = {
|
|
15
|
+
tool: string;
|
|
16
|
+
approvalReference: string;
|
|
17
|
+
idempotencyKeyHash: string;
|
|
18
|
+
payloadHash: string;
|
|
19
|
+
timestamp: string;
|
|
20
|
+
};
|
|
21
|
+
type AuditSink = (entry: AuditEntry) => void | Promise<void>;
|
|
22
|
+
type RequestOptions = {
|
|
23
|
+
idempotencyKey: string;
|
|
24
|
+
};
|
|
25
|
+
/** Subconjunto mínimo do SDK utilizado pelas ferramentas; facilita testes sem rede. */
|
|
26
|
+
type PaymentSdk = {
|
|
27
|
+
charges: {
|
|
28
|
+
create(params: Record<string, unknown>, options: RequestOptions): Promise<unknown>;
|
|
29
|
+
list(params: Record<string, unknown>): Promise<unknown>;
|
|
30
|
+
};
|
|
31
|
+
checkoutSessions: {
|
|
32
|
+
create(params: Record<string, unknown>, options: RequestOptions): Promise<unknown>;
|
|
33
|
+
};
|
|
34
|
+
subscriptions: {
|
|
35
|
+
create(params: Record<string, unknown>, options: RequestOptions): Promise<unknown>;
|
|
36
|
+
cancel(id: string, params: Record<string, unknown>, options: RequestOptions): Promise<unknown>;
|
|
37
|
+
};
|
|
38
|
+
refunds: {
|
|
39
|
+
create(chargeId: string, params: Record<string, unknown>, options: RequestOptions): Promise<unknown>;
|
|
40
|
+
get(refundId: string): Promise<unknown>;
|
|
41
|
+
listByCharge(chargeId: string, params?: Record<string, unknown>): Promise<unknown>;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
/**
|
|
45
|
+
* Lê configuração sem defaults perigosos. Prd é rejeitado de propósito: este
|
|
46
|
+
* servidor só é habilitado enquanto o produto está no ciclo sandbox.
|
|
47
|
+
*/
|
|
48
|
+
declare function readConfig(environment: Readonly<Record<string, string | undefined>>): McpConfig;
|
|
49
|
+
/** Cria o servidor MCP usando exclusivamente o SDK oficial endurecido. */
|
|
50
|
+
declare function createMuPagServer(config: McpConfig, options?: {
|
|
51
|
+
sdk?: PaymentSdk;
|
|
52
|
+
auditSink?: AuditSink;
|
|
53
|
+
}): Server;
|
|
54
|
+
/**
|
|
55
|
+
* Executor isolado e testável. Valida integralmente antes da chamada, coalesce
|
|
56
|
+
* concorrência idêntica e rejeita reuso conflitante da mesma chave localmente.
|
|
57
|
+
*/
|
|
58
|
+
declare function createToolExecutor(sdk: PaymentSdk, auditSink?: AuditSink): (name: string, args: unknown) => Promise<CallToolResult>;
|
|
59
|
+
|
|
60
|
+
export { type AuditEntry, type AuditSink, type McpConfig, type PaymentSdk, TOOL_DEFINITIONS, createMuPagServer, createToolExecutor, readConfig };
|
package/dist/server.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mupag/mcp-server",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"mcpName": "br.com.mupag/mcp-server",
|
|
5
|
+
"description": "MCP (Model Context Protocol) Server oficial da MuPag para integrar ferramentas agenticas em segundos.",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"main": "./dist/server.js",
|
|
8
|
+
"types": "./dist/server.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/server.d.ts",
|
|
12
|
+
"import": "./dist/server.js",
|
|
13
|
+
"default": "./dist/server.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"dist",
|
|
18
|
+
"README.md",
|
|
19
|
+
"server.json"
|
|
20
|
+
],
|
|
21
|
+
"bin": {
|
|
22
|
+
"mupag-mcp": "./dist/index.js"
|
|
23
|
+
},
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup",
|
|
26
|
+
"start": "node dist/index.js",
|
|
27
|
+
"dev": "tsup --watch",
|
|
28
|
+
"typecheck": "tsc --noEmit",
|
|
29
|
+
"lint": "tsc --noEmit",
|
|
30
|
+
"test": "npm run build && node --test tests/*.test.mjs",
|
|
31
|
+
"check": "npm run typecheck && npm test",
|
|
32
|
+
"prepack": "npm run build"
|
|
33
|
+
},
|
|
34
|
+
"dependencies": {
|
|
35
|
+
"@modelcontextprotocol/sdk": "^1.4.1",
|
|
36
|
+
"dotenv": "^16.4.7",
|
|
37
|
+
"mupag-sdk": "0.2.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/node": "^22.15.21",
|
|
41
|
+
"tsup": "^8.5.0",
|
|
42
|
+
"typescript": "^5.8.3"
|
|
43
|
+
},
|
|
44
|
+
"overrides": {
|
|
45
|
+
"esbuild": "0.28.2"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"mupag",
|
|
49
|
+
"mcp",
|
|
50
|
+
"payments",
|
|
51
|
+
"pix",
|
|
52
|
+
"sandbox"
|
|
53
|
+
],
|
|
54
|
+
"author": "MuPag",
|
|
55
|
+
"license": "UNLICENSED",
|
|
56
|
+
"homepage": "https://docs.mupag.com.br/docs/tools/ai-integration",
|
|
57
|
+
"engines": {
|
|
58
|
+
"node": ">=20"
|
|
59
|
+
},
|
|
60
|
+
"publishConfig": {
|
|
61
|
+
"access": "public"
|
|
62
|
+
}
|
|
63
|
+
}
|
package/server.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://static.modelcontextprotocol.io/schemas/2025-12-11/server.schema.json",
|
|
3
|
+
"name": "br.com.mupag/mcp-server",
|
|
4
|
+
"title": "MuPag Sandbox Payments",
|
|
5
|
+
"description": "Sandbox-only MuPag MCP server for approved payments, subscriptions, refunds, and reconciliation.",
|
|
6
|
+
"websiteUrl": "https://docs.mupag.com.br/docs/tools/ai-integration",
|
|
7
|
+
"version": "0.1.0",
|
|
8
|
+
"packages": [
|
|
9
|
+
{
|
|
10
|
+
"registryType": "npm",
|
|
11
|
+
"registryBaseUrl": "https://registry.npmjs.org",
|
|
12
|
+
"identifier": "@mupag/mcp-server",
|
|
13
|
+
"version": "0.1.0",
|
|
14
|
+
"runtimeHint": "npx",
|
|
15
|
+
"transport": {
|
|
16
|
+
"type": "stdio"
|
|
17
|
+
},
|
|
18
|
+
"environmentVariables": [
|
|
19
|
+
{
|
|
20
|
+
"name": "MUPAG_API_KEY",
|
|
21
|
+
"description": "MuPag sandbox secret key beginning with sk_test_.",
|
|
22
|
+
"isRequired": true,
|
|
23
|
+
"isSecret": true,
|
|
24
|
+
"format": "string"
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
"name": "MUPAG_ENV",
|
|
28
|
+
"description": "Fixed sandbox environment for this release.",
|
|
29
|
+
"isRequired": true,
|
|
30
|
+
"isSecret": false,
|
|
31
|
+
"format": "string",
|
|
32
|
+
"value": "test"
|
|
33
|
+
}
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
]
|
|
37
|
+
}
|