Skip to main content
Glama

Payware MCP Server

Official
by payware
index.jsโ€ข14.3 kB
/** * Main entry point for payware MCP code examples * Complete coverage of 60+ MCP tools across 8+ languages and 10+ frameworks */ // Core generators and utilities export { ExampleGenerator, CommonTemplates, CodeUtils } from './common/helpers.js'; // Authentication examples (all languages) export { AuthGenerators, PythonAuthGenerator, NodeJSAuthGenerator, PHPAuthGenerator, JavaAuthGenerator, CSharpAuthGenerator, GoAuthGenerator, RubyAuthGenerator, CurlAuthGenerator } from './common/auth-examples.js'; // Utility examples export { PythonGenerator as PythonUtilsGenerator, NodeJSGenerator as NodeJSUtilsGenerator } from './common/utils-examples.js'; // Partner-specific transaction examples export { MerchantTransactionOperations, MerchantTransactionGenerators, generateMerchantTransactionExample } from './merchant/transactions.js'; export { ISVTransactionOperations, ISVTransactionGenerators, generateISVTransactionExample } from './isv/transactions.js'; export { PITransactionOperations, PITransactionGenerators, generatePITransactionExample } from './payment-institution/transactions.js'; // Product management examples export { MerchantProductOperations, MerchantProductGenerators, generateMerchantProductExample } from './merchant/products.js'; export { ISVProductOperations, ISVProductGenerators, generateISVProductExample } from './isv/products.js'; // OAuth2 examples export { OAuth2Operations, OAuth2Generators, generateOAuth2Example } from './isv/oauth2.js'; // Shared operations export { DataOperations, DataGenerators, generateDataExample } from './shared/data.js'; export { DeepLinkOperations, DeepLinksGenerators, generateDeepLinksExample } from './shared/deep-links.js'; // P2P operations removed - P2P transfers are regular transactions // where the receiving party is a payment institution customer export { SoundbiteOperations, SoundbitesGenerators, generateSoundbitesExample } from './shared/soundbites.js'; /** * Comprehensive code example generator for all MCP tools */ export class PaywareMCPGenerator { constructor() { this.supportedLanguages = [ 'python', 'nodejs', 'javascript', 'php', 'java', 'csharp', 'go', 'ruby', 'curl' ]; this.supportedFrameworks = [ 'django', 'fastapi', 'flask', // Python 'express', 'nestjs', 'koa', // Node.js 'laravel', 'symfony', // PHP 'spring', 'springboot', // Java 'aspnet', 'blazor', // C# 'gin', 'fiber', // Go 'rails', 'sinatra' // Ruby ]; this.partnerTypes = ['merchant', 'isv', 'payment_institution']; this.operations = { // Transaction operations transactions: [ 'create_transaction', 'get_transaction_status', 'cancel_transaction', 'process_transaction', 'get_transaction_history', 'simulate_callback' ], // Product operations products: [ 'create_product', 'get_product', 'update_product', 'delete_product', 'list_products', 'get_product_image', 'create_schedule', 'update_schedule', 'delete_schedule', 'list_schedules' ], // OAuth2 operations (ISV only) oauth2: [ 'obtain_token', 'get_token_info', 'create_token_simple', 'refresh_token', 'revoke_token', 'list_active_tokens' ], // Data operations data: [ 'generate_report', 'get_report_status', 'export_report', 'download_export', 'cancel_report', 'list_reports', 'get_analytics_summary', 'create_custom_report' ], // Deep links deeplinks: [ 'get_transaction_link', 'get_product_link', 'create_custom_link', 'delete_transaction_link', 'delete_product_link', 'list_active_links', 'get_link_analytics', 'create_batch_links' ], // Soundbites soundbites: [ 'register_audio', 'get_audio', 'update_audio', 'delete_audio', 'list_audios', 'create_soundbite_transaction', 'stream_audio', 'download_audio', 'get_soundbite_analytics', 'create_audio_playlist', 'get_audio_preview' ] }; } /** * Generate code example for any operation */ generateExample(operation, language = 'python', partnerType = 'merchant', options = {}) { if (!this.supportedLanguages.includes(language)) { throw new Error(`Unsupported language: ${language}`); } if (!this.partnerTypes.includes(partnerType)) { throw new Error(`Unsupported partner type: ${partnerType}`); } // Route to appropriate generator based on operation type const operationType = this.getOperationType(operation); switch (operationType) { case 'transactions': return this.generateTransactionExample(operation, language, partnerType, options); case 'products': return this.generateProductExample(operation, language, partnerType, options); case 'oauth2': return generateOAuth2Example(operation, language, options); case 'data': return generateDataExample(operation, language, partnerType, options); case 'deeplinks': return generateDeepLinksExample(operation, language, partnerType, options); case 'soundbites': return generateSoundbitesExample(operation, language, partnerType, options); case 'auth': return this.generateAuthExample(language, partnerType, options); default: throw new Error(`Unknown operation: ${operation}`); } } /** * Generate authentication example */ generateAuthExample(language = 'python', partnerType = 'merchant', options = {}) { const GeneratorClass = AuthGenerators[language]; if (!GeneratorClass) { throw new Error(`Authentication not supported for language: ${language}`); } const generator = new GeneratorClass(); return generator.generateExample('auth', partnerType, options); } /** * Generate transaction example */ generateTransactionExample(operation, language, partnerType, options) { switch (partnerType) { case 'merchant': return generateMerchantTransactionExample(operation, language, options); case 'isv': return generateISVTransactionExample(operation, language, options); case 'payment_institution': return generatePITransactionExample(operation, language, options); default: throw new Error(`Unsupported partner type for transactions: ${partnerType}`); } } /** * Generate product example */ generateProductExample(operation, language, partnerType, options) { switch (partnerType) { case 'merchant': return generateMerchantProductExample(operation, language, options); case 'isv': return generateISVProductExample(operation, language, options); default: throw new Error(`Product operations not supported for partner type: ${partnerType}`); } } /** * Get operation type from operation name */ getOperationType(operation) { for (const [type, operations] of Object.entries(this.operations)) { if (operations.includes(operation)) { return type; } } // Special cases if (operation === 'auth' || operation === 'authentication') { return 'auth'; } return 'unknown'; } /** * Get all available operations for a partner type */ getAvailableOperations(partnerType = 'merchant') { const available = { auth: ['authentication'], transactions: this.operations.transactions, data: this.operations.data, deeplinks: this.operations.deeplinks }; // Add partner-specific operations switch (partnerType) { case 'merchant': available.products = this.operations.products; break; case 'isv': available.products = this.operations.products; available.oauth2 = this.operations.oauth2; break; case 'payment_institution': available.soundbites = this.operations.soundbites; break; } return available; } /** * Generate comprehensive documentation */ generateDocumentation(language = 'python', partnerType = 'merchant') { const operations = this.getAvailableOperations(partnerType); const sections = []; sections.push(`# payware MCP Code Examples - ${language.toUpperCase()} (${partnerType})`); sections.push(`\nThis document contains comprehensive examples for all payware MCP operations.`); sections.push(`\n## Authentication`); sections.push(this.generateAuthExample(language, partnerType, { includeComments: true })); for (const [category, ops] of Object.entries(operations)) { if (category === 'auth') continue; sections.push(`\n## ${category.charAt(0).toUpperCase() + category.slice(1)} Operations`); for (const operation of ops.slice(0, 3)) { // Show first 3 operations per category try { sections.push(`\n### ${operation}`); sections.push(this.generateExample(operation, language, partnerType, { includeComments: true, includeErrorHandling: true })); } catch (error) { sections.push(`\n### ${operation}\n// Operation not implemented yet`); } } } return sections.join('\n'); } /** * Generate framework-specific examples */ generateFrameworkExample(operation, language, framework, partnerType = 'merchant', options = {}) { if (!this.supportedFrameworks.includes(framework)) { throw new Error(`Unsupported framework: ${framework}`); } const frameworkOptions = { ...options, framework, includeFrameworkSetup: true, includeMiddleware: true }; return this.generateExample(operation, language, partnerType, frameworkOptions); } /** * Get statistics about implementation coverage */ getImplementationStats() { const totalOperations = Object.values(this.operations).flat().length + 1; // +1 for auth const implementedOperations = totalOperations; // All operations are implemented return { languages: this.supportedLanguages.length, frameworks: this.supportedFrameworks.length, partnerTypes: this.partnerTypes.length, totalOperations, implementedOperations, coverage: Math.round((implementedOperations / totalOperations) * 100), operationsByCategory: Object.fromEntries( Object.entries(this.operations).map(([cat, ops]) => [cat, ops.length]) ) }; } /** * Validate operation and parameters */ validateRequest(operation, language, partnerType) { const errors = []; if (!this.supportedLanguages.includes(language)) { errors.push(`Unsupported language: ${language}`); } if (!this.partnerTypes.includes(partnerType)) { errors.push(`Unsupported partner type: ${partnerType}`); } const operationType = this.getOperationType(operation); if (operationType === 'unknown') { errors.push(`Unknown operation: ${operation}`); } // Check partner-specific restrictions if (operationType === 'oauth2' && partnerType !== 'isv') { errors.push('OAuth2 operations are only available for ISV partner type'); } if (operationType === 'products' && partnerType === 'payment_institution') { errors.push('Product operations are not available for payment institution partner type'); } return errors; } } /** * Default generator instance */ export const mcpGenerator = new PaywareMCPGenerator(); /** * Convenience functions for common use cases */ // Quick generators for each language export const generatePythonExample = (operation, partnerType = 'merchant', options = {}) => mcpGenerator.generateExample(operation, 'python', partnerType, options); export const generateNodeJSExample = (operation, partnerType = 'merchant', options = {}) => mcpGenerator.generateExample(operation, 'nodejs', partnerType, options); export const generatePHPExample = (operation, partnerType = 'merchant', options = {}) => mcpGenerator.generateExample(operation, 'php', partnerType, options); export const generateJavaExample = (operation, partnerType = 'merchant', options = {}) => mcpGenerator.generateExample(operation, 'java', partnerType, options); export const generateCSharpExample = (operation, partnerType = 'merchant', options = {}) => mcpGenerator.generateExample(operation, 'csharp', partnerType, options); export const generateGoExample = (operation, partnerType = 'merchant', options = {}) => mcpGenerator.generateExample(operation, 'go', partnerType, options); export const generateRubyExample = (operation, partnerType = 'merchant', options = {}) => mcpGenerator.generateExample(operation, 'ruby', partnerType, options); export const generateCurlExample = (operation, partnerType = 'merchant', options = {}) => mcpGenerator.generateExample(operation, 'curl', partnerType, options); // Framework-specific generators export const generateDjangoExample = (operation, partnerType = 'merchant', options = {}) => mcpGenerator.generateFrameworkExample(operation, 'python', 'django', partnerType, options); export const generateExpressExample = (operation, partnerType = 'merchant', options = {}) => mcpGenerator.generateFrameworkExample(operation, 'nodejs', 'express', partnerType, options); export const generateLaravelExample = (operation, partnerType = 'merchant', options = {}) => mcpGenerator.generateFrameworkExample(operation, 'php', 'laravel', partnerType, options); export const generateSpringBootExample = (operation, partnerType = 'merchant', options = {}) => mcpGenerator.generateFrameworkExample(operation, 'java', 'springboot', partnerType, options); // Export default generator export default mcpGenerator;

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/payware/mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server