@felipechavaa/pulse-mcp-server 1.0.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.
Files changed (28) hide show
  1. package/README.md +201 -0
  2. package/dist/index.js +75 -0
  3. package/dist/tools/pulse-api/hospitality/cancel-transaction-hospitality.js +54 -0
  4. package/dist/tools/pulse-api/hospitality/cancel-transaction-item-hospitality.js +50 -0
  5. package/dist/tools/pulse-api/hospitality/hold-transaction-hospitality.js +51 -0
  6. package/dist/tools/pulse-api/hospitality/lookup-quote-hospitality.js +55 -0
  7. package/dist/tools/pulse-api/hospitality/lookup-sale-hospitality.js +56 -0
  8. package/dist/tools/pulse-api/hospitality/new-payment-hospitality.js +57 -0
  9. package/dist/tools/pulse-api/hospitality/new-quote-hospitality.js +79 -0
  10. package/dist/tools/pulse-api/hospitality/new-sale-hospitality.js +83 -0
  11. package/dist/tools/pulse-api/hospitality/update-customer-details-hospitality.js +58 -0
  12. package/dist/tools/pulse-api/hospitality/update-customers-hospitality.js +71 -0
  13. package/dist/tools/pulse-api/hospitality/update-event-date-hospitality.js +62 -0
  14. package/dist/tools/pulse-api/hospitality/update-quote-hospitality.js +88 -0
  15. package/dist/tools/pulse-api/hospitality/update-sale-hospitality.js +82 -0
  16. package/dist/tools/pulse-api/hospitality/update-sale-items-hospitality.js +63 -0
  17. package/dist/tools/pulse-api/hospitality/update-sale-status-hospitality.js +58 -0
  18. package/dist/tools/pulse-api/hospitality/update-transaction-item-status-hospitality.js +56 -0
  19. package/dist/tools/pulse-api/hospitality/update-transaction-items-hospitality.js +56 -0
  20. package/dist/tools/pulse-api/hospitality/update-transaction-status-hospitality.js +55 -0
  21. package/dist/tools/pulse-react/pulse-react.content.js +48 -0
  22. package/dist/tools/pulse-react/pulse-react.install.js +56 -0
  23. package/dist/tools/pulse-react/pulse-react.quote.js +46 -0
  24. package/dist/tools/pulse-react/pulse-react.sale.js +73 -0
  25. package/dist/tools/pulse-widget/pulse-widget-installation.js +40 -0
  26. package/dist/tools/pulse-widget/pulse-widget-render.js +36 -0
  27. package/dist/types/toolResponse.js +1 -0
  28. package/package.json +39 -0
@@ -0,0 +1,56 @@
1
+ import { z } from "zod";
2
+ export const updateTransactionItemStatusHospitalityTool = [
3
+ "pulse-api-update-transaction-item-status-hospitality",
4
+ "This is the update transaction item status API contract Protect Group Pulse API in hospitality vertical." +
5
+ "Use the tool to implements services in any programming language that can make HTTP requests." +
6
+ "Follow this API contract to create the services.",
7
+ {
8
+ saleId: z.string().describe("The ID of the sale"),
9
+ reference: z.string().describe("The reference of the item to update the status for"),
10
+ status: z.string().describe("The new status of the item (e.g. 'NotAttended')"),
11
+ member: z.string().describe("Your client ID or the client ID of the client being represented")
12
+ },
13
+ async ({ saleId, reference, status, member }) => {
14
+ const baseUrl = 'https://api.protectgroup.com/test/dynamic/sale';
15
+ const clientId = ''; // will be provided by the user
16
+ const clientSecret = ''; // will be provided by the user
17
+ const body = {
18
+ status,
19
+ member
20
+ };
21
+ try {
22
+ const url = `${baseUrl}/${saleId}/item/${reference}/status`;
23
+ const response = await fetch(url, {
24
+ method: 'PUT',
25
+ headers: {
26
+ 'x-pg-client-id': clientId,
27
+ 'x-pg-client-secret': clientSecret,
28
+ 'Content-Type': 'application/json'
29
+ },
30
+ body: JSON.stringify(body)
31
+ });
32
+ if (!response.ok) {
33
+ const errorData = await response.json();
34
+ throw new Error(JSON.stringify(errorData));
35
+ }
36
+ const data = await response.json();
37
+ const toolResponse = {
38
+ content: [{
39
+ type: "text",
40
+ text: JSON.stringify(data, null, 2)
41
+ }]
42
+ };
43
+ return toolResponse;
44
+ }
45
+ catch (error) {
46
+ console.error('Error updating transaction item status:', error);
47
+ const toolResponse = {
48
+ content: [{
49
+ type: "text",
50
+ text: `Error updating transaction item status: ${error instanceof Error ? error.message : JSON.stringify(error)}`
51
+ }]
52
+ };
53
+ return toolResponse;
54
+ }
55
+ }
56
+ ];
@@ -0,0 +1,56 @@
1
+ import { z } from "zod";
2
+ export const updateTransactionItemsHospitalityTool = [
3
+ "pulse-api-update-transaction-items-hospitality",
4
+ "This is the update transaction items API contract Protect Group Pulse API in hospitality vertical." +
5
+ "Use the tool to implements services in any programming language that can make HTTP requests." +
6
+ "Follow this API contract to create the services.",
7
+ {
8
+ saleId: z.string().describe("The ID of the sale to update items for"),
9
+ member: z.string().describe("Your client ID or the client ID of the client being represented"),
10
+ items: z.array(z.object({
11
+ customerName: z.string().describe("Name of the customer associated with the item"),
12
+ oldReference: z.string().describe("The current reference of the item to be updated"),
13
+ reference: z.string().describe("The new reference to assign to the item")
14
+ })).describe("Array of items to update")
15
+ },
16
+ async ({ saleId, member, items }) => {
17
+ const baseUrl = 'https://api.protectgroup.com/test/dynamic/sale';
18
+ const clientId = ''; // will be provided by the user
19
+ const clientSecret = ''; // will be provided by the user
20
+ const body = { member, items };
21
+ try {
22
+ const url = `${baseUrl}/${saleId}/items`;
23
+ const response = await fetch(url, {
24
+ method: 'PUT',
25
+ headers: {
26
+ 'x-pg-client-id': clientId,
27
+ 'x-pg-client-secret': clientSecret,
28
+ 'Content-Type': 'application/json'
29
+ },
30
+ body: JSON.stringify(body)
31
+ });
32
+ if (!response.ok) {
33
+ const errorData = await response.json();
34
+ throw new Error(JSON.stringify(errorData));
35
+ }
36
+ const data = await response.json();
37
+ const toolResponse = {
38
+ content: [{
39
+ type: "text",
40
+ text: JSON.stringify(data, null, 2)
41
+ }]
42
+ };
43
+ return toolResponse;
44
+ }
45
+ catch (error) {
46
+ console.error('Error updating transaction items:', error);
47
+ const toolResponse = {
48
+ content: [{
49
+ type: "text",
50
+ text: `Error updating transaction items: ${error instanceof Error ? error.message : JSON.stringify(error)}`
51
+ }]
52
+ };
53
+ return toolResponse;
54
+ }
55
+ }
56
+ ];
@@ -0,0 +1,55 @@
1
+ import { z } from "zod";
2
+ export const updateTransactionStatusHospitalityTool = [
3
+ "pulse-api-update-transaction-status-hospitality",
4
+ "This is the update transaction status API contract Protect Group Pulse API in hospitality vertical." +
5
+ "Use the tool to implements services in any programming language that can make HTTP requests." +
6
+ "Follow this API contract to create the services.",
7
+ {
8
+ saleId: z.string().describe("The ID of the sale to update the status for"),
9
+ status: z.string().describe("The new status of the transaction (e.g. 'NotAttended')"),
10
+ member: z.string().describe("Your client ID or the client ID of the client being represented")
11
+ },
12
+ async ({ saleId, status, member }) => {
13
+ const baseUrl = 'https://api.protectgroup.com/test/dynamic/sale';
14
+ const clientId = ''; // will be provided by the user
15
+ const clientSecret = ''; // will be provided by the user
16
+ const body = {
17
+ status,
18
+ member
19
+ };
20
+ try {
21
+ const url = `${baseUrl}/${saleId}/status`;
22
+ const response = await fetch(url, {
23
+ method: 'PUT',
24
+ headers: {
25
+ 'x-pg-client-id': clientId,
26
+ 'x-pg-client-secret': clientSecret,
27
+ 'Content-Type': 'application/json'
28
+ },
29
+ body: JSON.stringify(body)
30
+ });
31
+ if (!response.ok) {
32
+ const errorData = await response.json();
33
+ throw new Error(JSON.stringify(errorData));
34
+ }
35
+ const data = await response.json();
36
+ const toolResponse = {
37
+ content: [{
38
+ type: "text",
39
+ text: JSON.stringify(data, null, 2)
40
+ }]
41
+ };
42
+ return toolResponse;
43
+ }
44
+ catch (error) {
45
+ console.error('Error updating transaction status:', error);
46
+ const toolResponse = {
47
+ content: [{
48
+ type: "text",
49
+ text: `Error updating transaction status: ${error instanceof Error ? error.message : JSON.stringify(error)}`
50
+ }]
51
+ };
52
+ return toolResponse;
53
+ }
54
+ }
55
+ ];
@@ -0,0 +1,48 @@
1
+ export const pulseReactContentTool = [
2
+ "pulse-react-content-render",
3
+ "Place the RefundableContent component wherever you want the Refundable Booking content to appear. This will render the predefined UI from the Pulse component.",
4
+ async () => {
5
+ const reactCode = `
6
+ 1. **Render RefundableContent**:
7
+ After setting up the \`RefundableProvider\`, you can use the \`RefundableContent\` component to display the refundable booking options in your checkout or booking component.:
8
+
9
+ \`\`\`jsx
10
+ import {
11
+ ApiRequestFailedEventArgs,
12
+ RefundableContent,
13
+ useChangeEventArgs
14
+ } from 'protect-group-pulse-react'
15
+
16
+ function MyCheckoutPage() {
17
+ const args = useChangeEventArgs()
18
+
19
+ useEffect(() => {
20
+ // Handle protection change event and quoteId in args.quoteId
21
+ console.log(args);
22
+ }, [args])
23
+
24
+ const handleApiError = (args: ApiRequestFailedEventArgs) => {
25
+ // Maybe some invalid data was supplied?
26
+ }
27
+
28
+ return (
29
+ <MyPageWrapper>
30
+ //some components
31
+ <RefundableContent onApiError={handleApiError} />
32
+ //some components
33
+ </MyPageWrapper>
34
+ )
35
+ }
36
+ \`\`\`
37
+ `.trim();
38
+ const toolResponse = {
39
+ content: [
40
+ {
41
+ type: "text",
42
+ text: reactCode
43
+ }
44
+ ]
45
+ };
46
+ return toolResponse;
47
+ }
48
+ ];
@@ -0,0 +1,56 @@
1
+ import { z } from "zod";
2
+ export const pulseReactInstallationTool = [
3
+ "pulse-react-installation",
4
+ "Install pulse react NPM script and configure RefundableProvider at the root level of the project using RefundableOptions below" +
5
+ " wrapper to provide context to all child components and TheRestOfYourApp is the existing app component",
6
+ {
7
+ VendorCode: z.string().describe("Vendor code (member ID)")
8
+ },
9
+ async ({ VendorCode }) => {
10
+ const reactCode = `
11
+ 1. **Installation**:
12
+ \`\`\`
13
+ npm i --save protect-group-pulse-react
14
+ \`\`\`
15
+
16
+ 2. **Usage**:
17
+ Once the package is installed, use the following React code to render the widget:
18
+
19
+ \`\`\`jsx
20
+ import {
21
+ RefundableOptions,
22
+ RefundableProvider
23
+ } from 'protect-group-pulse-react';
24
+
25
+ function MyApp() {
26
+ const options: RefundableOptions = {
27
+ containerSize: 'medium', // 'small', 'medium', 'large' (default)
28
+ currencyCode: 'USD',
29
+ environment: 'test',
30
+ eventDateFormat: 'DD/MM/YYYY', // Optional – The format must match a valid moment.js date format and the date must be in UTC
31
+ languageCode: 'en',
32
+ nonce: '[nonce code for the inline script, if you have a CSP set up on your site]', // optional
33
+ salesTax: 10, // optional, apply sales tax to the refundable booking cost
34
+ useSaleAction: true, // optional, set this to false if you intend to call our sale endpoint manually
35
+ vendorCode: '${VendorCode}'
36
+ };
37
+
38
+ return (
39
+ <RefundableProvider options={options}>
40
+ <TheRestOfYourApp/>
41
+ </RefundableProvider>
42
+ );
43
+ }
44
+ \`\`\`
45
+ `.trim();
46
+ const toolResponse = {
47
+ content: [
48
+ {
49
+ type: "text",
50
+ text: reactCode
51
+ }
52
+ ]
53
+ };
54
+ return toolResponse;
55
+ }
56
+ ];
@@ -0,0 +1,46 @@
1
+ export const pulseReactUpdateQuoteTool = [
2
+ "pulse-react-update-quote",
3
+ "React code to update quote data when internal state changes in your application",
4
+ async () => {
5
+ const reactCode = `
6
+ 1. **Implement updateQuoteData**:
7
+ After setting up the \`RefundableContent\`, you can use the \`useRefundableActions\` hook to update the quote data whenever your internal state changes. This is particularly useful if the booking cost, number of tickets, or event date changes based on user input or other application logic.
8
+
9
+ \`\`\`jsx
10
+ import {useRefundableActions} from 'protect-group-pulse-react'
11
+
12
+ function MyCheckoutPage() {
13
+ const {updateQuoteData} = useRefundableActions()
14
+ const {myInternalState} = useMyInternalStateContext() // Assume this context provides your app's internal state
15
+
16
+ useEffect(() => {
17
+ const {bookingCost, numberOfTickets, eventDate} = myInternalState
18
+
19
+ updateQuoteData({
20
+ totalValue: bookingCost,
21
+ numberOfTickets,
22
+ eventTravelDateTime: eventDate // in 'DD/MM/YYYY' format
23
+ })
24
+ }, [myInternalState])
25
+
26
+ return (
27
+ <MyPageWrapper>
28
+ {/* some components */}
29
+ <RefundableContent />
30
+ {/* some components */}
31
+ </MyPageWrapper>
32
+ )
33
+ }
34
+ \`\`\`
35
+ `.trim();
36
+ const toolResponse = {
37
+ content: [
38
+ {
39
+ type: "text",
40
+ text: reactCode
41
+ }
42
+ ]
43
+ };
44
+ return toolResponse;
45
+ }
46
+ ];
@@ -0,0 +1,73 @@
1
+ import { z } from "zod";
2
+ export const pulseReactSaleTool = [
3
+ "pulse-react-sale",
4
+ "React code to write sale using writeSale from useRefundableActions hook",
5
+ {
6
+ BookingReference: z.string().describe("Booking reference")
7
+ },
8
+ async ({ BookingReference }) => {
9
+ const reactCode = `
10
+ 1. **Implement writeSale**:
11
+ After setting up the \`RefundableContent\`, you can use the \`useRefundableActions\` hook to write the sale data using the booking reference from the sale.
12
+
13
+ \`\`\`jsx
14
+ import {useRefundableActions, SaleData} from 'protect-group-pulse-react'
15
+
16
+ function MyCheckoutPage() {
17
+ const {writeSale} = useRefundableActions()
18
+
19
+ const handleMakePayment = async () => {
20
+ // Do your sale thing
21
+
22
+ const request: SaleData = {
23
+ bookingReference: ${BookingReference},
24
+ customers: [
25
+ {
26
+ email: 'test@test.com',
27
+ firstName: 'Test',
28
+ lastName: 'Test',
29
+ telephone: "+598 12345678" // Should be in the format +(prefix) (number)
30
+ }
31
+ ],
32
+ flights: [
33
+ {
34
+ arrivalCode: 'LHR',
35
+ departureCode: 'LBA',
36
+ departureDate: '01/01/2000', // the configured date format
37
+ flightNumber: 'PP1'
38
+ terminal: 'Terminal 1',
39
+ class: 'Economy'
40
+ }
41
+ ]
42
+ }
43
+
44
+ try {
45
+ const response = await writeSale(request)
46
+ // Do something with the response
47
+ } catch (e: any) {
48
+ const {data: {error}} = e
49
+ // Something went wrong
50
+ }
51
+ }
52
+
53
+ return (
54
+ <MyPageWrapper>
55
+ {/* some components */}
56
+ <RefundableContent />
57
+ {/* some components */}
58
+ </MyPageWrapper>
59
+ )
60
+ }
61
+ \`\`\`
62
+ `.trim();
63
+ const toolResponse = {
64
+ content: [
65
+ {
66
+ type: "text",
67
+ text: reactCode
68
+ }
69
+ ]
70
+ };
71
+ return toolResponse;
72
+ }
73
+ ];
@@ -0,0 +1,40 @@
1
+ import { z } from "zod";
2
+ export const pulseWidgetInstallation = [
3
+ "pulse-widget-installation",
4
+ "Install Pulse javascript widget, this should be created once in the source code. Insert the code returned as an script",
5
+ {
6
+ VendorCode: z.string().describe("Vendor code (member ID)"),
7
+ },
8
+ async ({ VendorCode }) => {
9
+ const widgetScript = `
10
+ <script>
11
+ (function (P, R, O, t, E, C, T) {
12
+ P[t] = P[t] || function () { (P[t].q = P[t].q || []).push(arguments) };
13
+ C = R.createElement(O), T = R.getElementsByTagName(O)[0];
14
+ C.id = t; C.src = E; C.async = 1; T.parentNode.insertBefore(C, T);
15
+ }(window, document, 'script', '_pgr', 'https://test.widget.protectgroup.com/pulse.js'))
16
+
17
+ window._pgr('init', {
18
+ containerSize: 'large', // 'small', 'medium', 'large' (default)
19
+ currencyCode: 'USD',
20
+ debug: true,
21
+ environment: 'test', // default is 'prod' --> set to 'test' for sandbox
22
+ eventDateFormat: 'DD/MM/YYYY', // Optional – The format must match a valid moment.js date format and the date must be in UTC
23
+ languageCode: 'en',
24
+ resetOnUnload: false, // Reset the widget when the page is unloaded (set to true to enable auto-reset)
25
+ useSaleAction: false, // Optional, set this to false if you intend to call our sale endpoint manually
26
+ vendorCode: '${VendorCode}',
27
+ })
28
+ </script>
29
+ `.trim();
30
+ const toolResponse = {
31
+ content: [
32
+ {
33
+ type: "text",
34
+ text: widgetScript
35
+ }
36
+ ]
37
+ };
38
+ return toolResponse;
39
+ }
40
+ ];
@@ -0,0 +1,36 @@
1
+ import { z } from "zod";
2
+ export const pulseWidgetRender = [
3
+ "pulse-widget-render",
4
+ "This is the code to render the Pulse javascript widget once its installed. Add the div with pgr-payment-container and call updateQuoteData action.",
5
+ {
6
+ TotalValue: z.number().describe("The total value of the booking"),
7
+ NumberOfTickets: z.number().describe("The number of tickets"),
8
+ EventTravelDateTime: z.string().describe("Event travel date time in ISO format")
9
+ },
10
+ async ({ TotalValue, NumberOfTickets, EventTravelDateTime }) => {
11
+ const widgetRenderScript = `
12
+ <script>
13
+ document.addEventListener('pg-widget-loaded', function() {
14
+ const data = {
15
+ totalValue: ${TotalValue},
16
+ numberOfTickets: ${NumberOfTickets},
17
+ eventTravelDateTime: '${EventTravelDateTime}' // in 'DD/MM/YYYY' format
18
+ };
19
+ window._pgr('action', 'updateQuoteData', data);
20
+ });
21
+ </script>
22
+
23
+ <div id="pgr-payment-container"></div>
24
+ <div id='pgr-product-container'></div>
25
+ `.trim();
26
+ const toolResponse = {
27
+ content: [
28
+ {
29
+ type: "text",
30
+ text: widgetRenderScript
31
+ }
32
+ ]
33
+ };
34
+ return toolResponse;
35
+ }
36
+ ];
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,39 @@
1
+ {
2
+ "name": "@felipechavaa/pulse-mcp-server",
3
+ "version": "1.0.0",
4
+ "type": "module",
5
+ "description": "Pulse Model Context Protocol Server in TypeScript",
6
+ "main": "dist/index.js",
7
+ "bin": {
8
+ "pulse-mcp-server": "dist/index.js"
9
+ },
10
+ "files": [
11
+ "dist"
12
+ ],
13
+ "scripts": {
14
+ "build": "tsc && shx chmod +x dist/*.js",
15
+ "prepare": "npm run build",
16
+ "prepublishOnly": "npm run build"
17
+ },
18
+ "author": "Protect Group Tech Team",
19
+ "keywords": [
20
+ "mcp",
21
+ "model-context-protocol",
22
+ "pulse",
23
+ "refund-protect",
24
+ "protect-group",
25
+ "ai-tools"
26
+ ],
27
+ "license": "MIT",
28
+ "dependencies": {
29
+ "@modelcontextprotocol/sdk": "1.19.1",
30
+ "node-fetch": "^3.3.2",
31
+ "zod": "^3.24.3"
32
+ },
33
+ "devDependencies": {
34
+ "@types/node": "^20.11.0",
35
+ "ts-node": "^10.9.2",
36
+ "shx": "^0.3.4",
37
+ "typescript": "^5.3.3"
38
+ }
39
+ }