UNPKG

@thorium-dev-group/x402-mcp-extension

Version:
184 lines 7.25 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConsolidatedPaymentExample = void 0; const mcpTool_1 = require("../../server/decorators/mcpTool"); const mcpPrompt_1 = require("../../server/decorators/mcpPrompt"); const mcpResource_1 = require("../../server/decorators/mcpResource"); const zod_1 = require("zod"); class ConsolidatedPaymentExample { async advancedCalculator(args, extra) { let result; switch (args.operation) { case 'add': result = args.a + args.b; break; case 'subtract': result = args.a - args.b; break; case 'multiply': result = args.a * args.b; break; case 'divide': if (args.b === 0) throw new Error('Division by zero'); result = args.a / args.b; break; default: throw new Error(`Unknown operation: ${args.operation}`); } return { content: [{ type: 'text', text: `Result: ${result}` }] }; } async basicCalculator(args, extra) { let result; switch (args.operation) { case 'add': result = args.a + args.b; break; case 'subtract': result = args.a - args.b; break; default: throw new Error(`Unknown operation: ${args.operation}`); } return { content: [{ type: 'text', text: `Result: ${result}` }] }; } async analyzeText(args, extra) { const analysis = `Analysis of "${args.text.substring(0, 20)}..." using ${args.analysisType}`; return { content: [{ type: 'text', text: analysis }] }; } async basicTextAnalysis(args, extra) { const wordCount = args.text.split(' ').length; return { content: [{ type: 'text', text: `Word count: ${wordCount}` }] }; } async getPaidDocument(args, extra) { return { content: [{ type: 'text', text: 'Premium document content' }] }; } async getFreeDocument(args, extra) { return { content: [{ type: 'text', text: 'Free document content' }] }; } async getPaidResource(args, extra) { return { content: [{ type: 'text', text: `Premium resource for ID: ${args.id}` }] }; } } exports.ConsolidatedPaymentExample = ConsolidatedPaymentExample; __decorate([ (0, mcpTool_1.MCPTool)({ name: 'paid-calculator', description: 'Advanced calculator that requires payment', inputSchema: { operation: zod_1.z.enum(['add', 'subtract', 'multiply', 'divide']), a: zod_1.z.number(), b: zod_1.z.number() }, payment: { amount: 0.001, description: 'Pay for advanced calculation' } }), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Object]), __metadata("design:returntype", Promise) ], ConsolidatedPaymentExample.prototype, "advancedCalculator", null); __decorate([ (0, mcpTool_1.MCPTool)({ name: 'free-calculator', description: 'Basic calculator that is free to use', inputSchema: { operation: zod_1.z.enum(['add', 'subtract']), a: zod_1.z.number(), b: zod_1.z.number() } }), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Object]), __metadata("design:returntype", Promise) ], ConsolidatedPaymentExample.prototype, "basicCalculator", null); __decorate([ (0, mcpPrompt_1.MCPPrompt)({ name: 'paid-analysis', description: 'Advanced text analysis that requires payment', argsSchema: { text: zod_1.z.string(), analysisType: zod_1.z.enum(['sentiment', 'keywords', 'summary']) }, payment: { amount: 0.002, description: 'Pay for advanced text analysis' } }), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Object]), __metadata("design:returntype", Promise) ], ConsolidatedPaymentExample.prototype, "analyzeText", null); __decorate([ (0, mcpPrompt_1.MCPPrompt)({ name: 'free-analysis', description: 'Basic text analysis that is free', argsSchema: { text: zod_1.z.string() } }), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Object]), __metadata("design:returntype", Promise) ], ConsolidatedPaymentExample.prototype, "basicTextAnalysis", null); __decorate([ (0, mcpResource_1.MCPResource)({ name: 'paid-document', uri: 'https://example.com/paid-document', description: 'Premium document that requires payment', mimeType: 'application/pdf', payment: { amount: 0.005, description: 'Pay for premium document access' } }), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Object]), __metadata("design:returntype", Promise) ], ConsolidatedPaymentExample.prototype, "getPaidDocument", null); __decorate([ (0, mcpResource_1.MCPResource)({ name: 'free-document', uri: 'https://example.com/free-document', description: 'Free document that anyone can access', mimeType: 'text/plain' }), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Object]), __metadata("design:returntype", Promise) ], ConsolidatedPaymentExample.prototype, "getFreeDocument", null); __decorate([ (0, mcpResource_1.MCPResource)({ name: 'paid-template', template: 'https://example.com/paid/{id}', description: 'Premium resource template that requires payment', payment: { amount: 0.003, description: 'Pay for premium resource access' } }), __metadata("design:type", Function), __metadata("design:paramtypes", [Object, Object]), __metadata("design:returntype", Promise) ], ConsolidatedPaymentExample.prototype, "getPaidResource", null); //# sourceMappingURL=ConsolidatedPaymentExample.js.map