@capivv/mcp-server 0.1.3 → 0.5.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 (141) hide show
  1. package/README.md +73 -2
  2. package/dist/client.d.ts +62 -3
  3. package/dist/client.js +220 -5
  4. package/dist/config.js +1 -1
  5. package/dist/http.d.ts +12 -0
  6. package/dist/http.js +102 -0
  7. package/dist/resources/guides.d.ts +2 -0
  8. package/dist/resources/guides.js +81 -0
  9. package/dist/resources/index.js +4 -0
  10. package/dist/resources/quickstart.d.ts +2 -0
  11. package/dist/resources/quickstart.js +173 -0
  12. package/dist/resources/rules.js +8 -2
  13. package/dist/tools/activate-rule.d.ts +3 -0
  14. package/dist/tools/activate-rule.js +9 -0
  15. package/dist/tools/api-key-usage.d.ts +3 -0
  16. package/dist/tools/api-key-usage.js +70 -0
  17. package/dist/tools/apply-rule.js +54 -13
  18. package/dist/tools/approve-change-request.d.ts +3 -0
  19. package/dist/tools/approve-change-request.js +16 -0
  20. package/dist/tools/archive-app.d.ts +3 -0
  21. package/dist/tools/archive-app.js +9 -0
  22. package/dist/tools/autopilot-status.d.ts +3 -0
  23. package/dist/tools/autopilot-status.js +117 -0
  24. package/dist/tools/check-drift.d.ts +3 -0
  25. package/dist/tools/check-drift.js +21 -0
  26. package/dist/tools/create-app.d.ts +3 -0
  27. package/dist/tools/create-app.js +13 -0
  28. package/dist/tools/create-entitlement.d.ts +3 -0
  29. package/dist/tools/create-entitlement.js +11 -0
  30. package/dist/tools/create-experiment.d.ts +3 -0
  31. package/dist/tools/create-experiment.js +43 -0
  32. package/dist/tools/create-paywall.d.ts +3 -0
  33. package/dist/tools/create-paywall.js +18 -0
  34. package/dist/tools/create-pricing-strategy.d.ts +3 -0
  35. package/dist/tools/create-pricing-strategy.js +49 -0
  36. package/dist/tools/create-product.d.ts +3 -0
  37. package/dist/tools/create-product.js +77 -0
  38. package/dist/tools/create-promotion.d.ts +3 -0
  39. package/dist/tools/create-promotion.js +35 -0
  40. package/dist/tools/create-rescue-flow.d.ts +3 -0
  41. package/dist/tools/create-rescue-flow.js +20 -0
  42. package/dist/tools/delete-app.d.ts +3 -0
  43. package/dist/tools/delete-app.js +9 -0
  44. package/dist/tools/delete-entitlement.d.ts +3 -0
  45. package/dist/tools/delete-entitlement.js +11 -0
  46. package/dist/tools/delete-paywall.d.ts +3 -0
  47. package/dist/tools/delete-paywall.js +16 -0
  48. package/dist/tools/delete-product.d.ts +3 -0
  49. package/dist/tools/delete-product.js +9 -0
  50. package/dist/tools/delete-promotion.d.ts +3 -0
  51. package/dist/tools/delete-promotion.js +11 -0
  52. package/dist/tools/delete-rescue-flow.d.ts +3 -0
  53. package/dist/tools/delete-rescue-flow.js +11 -0
  54. package/dist/tools/delete-rule.d.ts +3 -0
  55. package/dist/tools/delete-rule.js +9 -0
  56. package/dist/tools/get-entitlement.d.ts +3 -0
  57. package/dist/tools/get-entitlement.js +9 -0
  58. package/dist/tools/get-experiment-summary.d.ts +3 -0
  59. package/dist/tools/get-experiment-summary.js +9 -0
  60. package/dist/tools/get-offering.d.ts +3 -0
  61. package/dist/tools/get-offering.js +9 -0
  62. package/dist/tools/get-paywall-stats.d.ts +3 -0
  63. package/dist/tools/get-paywall-stats.js +6 -0
  64. package/dist/tools/get-product.d.ts +3 -0
  65. package/dist/tools/get-product.js +9 -0
  66. package/dist/tools/get-rescue-stats.d.ts +3 -0
  67. package/dist/tools/get-rescue-stats.js +12 -0
  68. package/dist/tools/get-rule.d.ts +3 -0
  69. package/dist/tools/get-rule.js +9 -0
  70. package/dist/tools/import-products.js +7 -5
  71. package/dist/tools/index.js +143 -1
  72. package/dist/tools/list-change-requests.d.ts +3 -0
  73. package/dist/tools/list-change-requests.js +14 -0
  74. package/dist/tools/list-entitlements.d.ts +3 -0
  75. package/dist/tools/list-entitlements.js +6 -0
  76. package/dist/tools/list-paywalls.d.ts +3 -0
  77. package/dist/tools/list-paywalls.js +6 -0
  78. package/dist/tools/list-pricing-strategies.d.ts +3 -0
  79. package/dist/tools/list-pricing-strategies.js +8 -0
  80. package/dist/tools/list-promotions.d.ts +3 -0
  81. package/dist/tools/list-promotions.js +6 -0
  82. package/dist/tools/list-rescue-flows.d.ts +3 -0
  83. package/dist/tools/list-rescue-flows.js +6 -0
  84. package/dist/tools/list-rule-versions.d.ts +3 -0
  85. package/dist/tools/list-rule-versions.js +9 -0
  86. package/dist/tools/list-rules.js +4 -2
  87. package/dist/tools/next-step.d.ts +3 -0
  88. package/dist/tools/next-step.js +123 -0
  89. package/dist/tools/preview-pricing.d.ts +3 -0
  90. package/dist/tools/preview-pricing.js +13 -0
  91. package/dist/tools/push-prices-to-stores.d.ts +3 -0
  92. package/dist/tools/push-prices-to-stores.js +9 -0
  93. package/dist/tools/recompute-prices.d.ts +3 -0
  94. package/dist/tools/recompute-prices.js +24 -0
  95. package/dist/tools/resolve-drift.d.ts +3 -0
  96. package/dist/tools/resolve-drift.js +15 -0
  97. package/dist/tools/restore-app.d.ts +3 -0
  98. package/dist/tools/restore-app.js +9 -0
  99. package/dist/tools/revert-app-autopilot.d.ts +3 -0
  100. package/dist/tools/revert-app-autopilot.js +9 -0
  101. package/dist/tools/rollback-rule.d.ts +3 -0
  102. package/dist/tools/rollback-rule.js +10 -0
  103. package/dist/tools/run-app-autopilot.d.ts +3 -0
  104. package/dist/tools/run-app-autopilot.js +9 -0
  105. package/dist/tools/set-country-price-override.d.ts +3 -0
  106. package/dist/tools/set-country-price-override.js +13 -0
  107. package/dist/tools/setup-wizard.d.ts +3 -0
  108. package/dist/tools/setup-wizard.js +259 -0
  109. package/dist/tools/start-experiment.d.ts +3 -0
  110. package/dist/tools/start-experiment.js +9 -0
  111. package/dist/tools/status.js +25 -1
  112. package/dist/tools/stop-experiment.d.ts +3 -0
  113. package/dist/tools/stop-experiment.js +9 -0
  114. package/dist/tools/sync-suggestions-count.d.ts +3 -0
  115. package/dist/tools/sync-suggestions-count.js +6 -0
  116. package/dist/tools/trigger-sync.d.ts +3 -0
  117. package/dist/tools/trigger-sync.js +6 -0
  118. package/dist/tools/update-app.d.ts +3 -0
  119. package/dist/tools/update-app.js +19 -0
  120. package/dist/tools/update-entitlement.d.ts +3 -0
  121. package/dist/tools/update-entitlement.js +13 -0
  122. package/dist/tools/update-experiment.d.ts +3 -0
  123. package/dist/tools/update-experiment.js +22 -0
  124. package/dist/tools/update-offering.d.ts +3 -0
  125. package/dist/tools/update-offering.js +31 -0
  126. package/dist/tools/update-paywall.d.ts +3 -0
  127. package/dist/tools/update-paywall.js +23 -0
  128. package/dist/tools/update-product.d.ts +3 -0
  129. package/dist/tools/update-product.js +16 -0
  130. package/dist/tools/update-promotion.d.ts +3 -0
  131. package/dist/tools/update-promotion.js +20 -0
  132. package/dist/tools/update-rescue-flow.d.ts +3 -0
  133. package/dist/tools/update-rescue-flow.js +27 -0
  134. package/dist/tools/verify-setup.d.ts +3 -0
  135. package/dist/tools/verify-setup.js +200 -0
  136. package/dist/tools/whoami.d.ts +3 -0
  137. package/dist/tools/whoami.js +31 -0
  138. package/dist/types.d.ts +417 -79
  139. package/dist/types.js +0 -2
  140. package/mcp.json +89 -0
  141. package/package.json +8 -2
@@ -1,22 +1,164 @@
1
1
  import { registerStatusTool } from './status.js';
2
2
  import { registerListAppsTool } from './list-apps.js';
3
+ import { registerCreateAppTool } from './create-app.js';
4
+ import { registerListEntitlementsTool } from './list-entitlements.js';
5
+ import { registerCreateEntitlementTool } from './create-entitlement.js';
3
6
  import { registerListProductsTool } from './list-products.js';
7
+ import { registerCreateProductTool } from './create-product.js';
8
+ import { registerUpdateProductTool } from './update-product.js';
9
+ import { registerDeleteProductTool } from './delete-product.js';
4
10
  import { registerImportProductsTool } from './import-products.js';
5
11
  import { registerListOfferingsTool } from './list-offerings.js';
6
12
  import { registerCreateOfferingTool } from './create-offering.js';
7
13
  import { registerListRulesTool } from './list-rules.js';
8
14
  import { registerApplyRuleTool } from './apply-rule.js';
15
+ import { registerActivateRuleTool } from './activate-rule.js';
16
+ import { registerDeleteRuleTool } from './delete-rule.js';
9
17
  import { registerListExperimentsTool } from './list-experiments.js';
10
18
  import { registerGetAnalyticsTool } from './get-analytics.js';
19
+ import { registerNextStepTool } from './next-step.js';
20
+ import { registerSetupWizardTool } from './setup-wizard.js';
21
+ import { registerVerifySetupTool } from './verify-setup.js';
22
+ import { registerWhoamiTool } from './whoami.js';
23
+ import { registerAutopilotStatusTool } from './autopilot-status.js';
24
+ import { registerApiKeyUsageTool } from './api-key-usage.js';
25
+ import { registerListPaywallsTool } from './list-paywalls.js';
26
+ import { registerCreatePaywallTool } from './create-paywall.js';
27
+ import { registerUpdatePaywallTool } from './update-paywall.js';
28
+ import { registerDeletePaywallTool } from './delete-paywall.js';
29
+ import { registerGetPaywallStatsTool } from './get-paywall-stats.js';
30
+ import { registerListPromotionsTool } from './list-promotions.js';
31
+ import { registerCreatePromotionTool } from './create-promotion.js';
32
+ import { registerUpdatePromotionTool } from './update-promotion.js';
33
+ import { registerDeletePromotionTool } from './delete-promotion.js';
34
+ import { registerListRescueFlowsTool } from './list-rescue-flows.js';
35
+ import { registerCreateRescueFlowTool } from './create-rescue-flow.js';
36
+ import { registerUpdateRescueFlowTool } from './update-rescue-flow.js';
37
+ import { registerDeleteRescueFlowTool } from './delete-rescue-flow.js';
38
+ import { registerGetRescueStatsTool } from './get-rescue-stats.js';
39
+ import { registerListPricingStrategiesTool } from './list-pricing-strategies.js';
40
+ import { registerCreatePricingStrategyTool } from './create-pricing-strategy.js';
41
+ import { registerPreviewPricingTool } from './preview-pricing.js';
42
+ import { registerRecomputePricesTool } from './recompute-prices.js';
43
+ import { registerPushPricesToStoresTool } from './push-prices-to-stores.js';
44
+ import { registerListChangeRequestsTool } from './list-change-requests.js';
45
+ import { registerApproveChangeRequestTool } from './approve-change-request.js';
46
+ import { registerSetCountryPriceOverrideTool } from './set-country-price-override.js';
47
+ import { registerCreateExperimentTool } from './create-experiment.js';
48
+ import { registerUpdateExperimentTool } from './update-experiment.js';
49
+ import { registerStartExperimentTool } from './start-experiment.js';
50
+ import { registerStopExperimentTool } from './stop-experiment.js';
51
+ import { registerGetExperimentSummaryTool } from './get-experiment-summary.js';
52
+ import { registerUpdateAppTool } from './update-app.js';
53
+ import { registerDeleteAppTool } from './delete-app.js';
54
+ import { registerArchiveAppTool } from './archive-app.js';
55
+ import { registerRestoreAppTool } from './restore-app.js';
56
+ import { registerRunAppAutopilotTool } from './run-app-autopilot.js';
57
+ import { registerRevertAppAutopilotTool } from './revert-app-autopilot.js';
58
+ import { registerGetEntitlementTool } from './get-entitlement.js';
59
+ import { registerUpdateEntitlementTool } from './update-entitlement.js';
60
+ import { registerDeleteEntitlementTool } from './delete-entitlement.js';
61
+ import { registerGetProductTool } from './get-product.js';
62
+ import { registerGetRuleTool } from './get-rule.js';
63
+ import { registerListRuleVersionsTool } from './list-rule-versions.js';
64
+ import { registerRollbackRuleTool } from './rollback-rule.js';
65
+ import { registerGetOfferingTool } from './get-offering.js';
66
+ import { registerUpdateOfferingTool } from './update-offering.js';
67
+ import { registerCheckDriftTool } from './check-drift.js';
68
+ import { registerResolveDriftTool } from './resolve-drift.js';
69
+ import { registerSyncSuggestionsCountTool } from './sync-suggestions-count.js';
70
+ import { registerTriggerSyncTool } from './trigger-sync.js';
11
71
  export function registerAllTools(server, client) {
72
+ // Identity — call this first to verify which workspace you're connected to
73
+ registerWhoamiTool(server, client);
74
+ // Autopilot diagnostics — what did autopilot do for a given app?
75
+ registerAutopilotStatusTool(server, client);
76
+ // SDK telemetry — investigate suspected key leaks inline.
77
+ registerApiKeyUsageTool(server, client);
78
+ // Onboarding & guidance
79
+ registerNextStepTool(server, client);
80
+ registerSetupWizardTool(server, client);
81
+ registerVerifySetupTool(server, client);
82
+ // Status & analytics
12
83
  registerStatusTool(server, client);
84
+ registerGetAnalyticsTool(server, client);
85
+ // Apps
13
86
  registerListAppsTool(server, client);
87
+ registerCreateAppTool(server, client);
88
+ // Entitlements
89
+ registerListEntitlementsTool(server, client);
90
+ registerCreateEntitlementTool(server, client);
91
+ // Products
14
92
  registerListProductsTool(server, client);
93
+ registerCreateProductTool(server, client);
94
+ registerUpdateProductTool(server, client);
95
+ registerDeleteProductTool(server, client);
15
96
  registerImportProductsTool(server, client);
97
+ // Offerings
16
98
  registerListOfferingsTool(server, client);
17
99
  registerCreateOfferingTool(server, client);
100
+ // Rules
18
101
  registerListRulesTool(server, client);
19
102
  registerApplyRuleTool(server, client);
103
+ registerActivateRuleTool(server, client);
104
+ registerDeleteRuleTool(server, client);
105
+ // Experiments
20
106
  registerListExperimentsTool(server, client);
21
- registerGetAnalyticsTool(server, client);
107
+ // Paywalls (V8 Phase B.1)
108
+ registerListPaywallsTool(server, client);
109
+ registerCreatePaywallTool(server, client);
110
+ registerUpdatePaywallTool(server, client);
111
+ registerDeletePaywallTool(server, client);
112
+ registerGetPaywallStatsTool(server, client);
113
+ // Promotions (V8 Phase B.2)
114
+ registerListPromotionsTool(server, client);
115
+ registerCreatePromotionTool(server, client);
116
+ registerUpdatePromotionTool(server, client);
117
+ registerDeletePromotionTool(server, client);
118
+ // Rescue flows (V8 Phase B.3)
119
+ registerListRescueFlowsTool(server, client);
120
+ registerCreateRescueFlowTool(server, client);
121
+ registerUpdateRescueFlowTool(server, client);
122
+ registerDeleteRescueFlowTool(server, client);
123
+ registerGetRescueStatsTool(server, client);
124
+ // Pricing (V8 Phase B.4)
125
+ registerListPricingStrategiesTool(server, client);
126
+ registerCreatePricingStrategyTool(server, client);
127
+ registerPreviewPricingTool(server, client);
128
+ registerRecomputePricesTool(server, client);
129
+ registerPushPricesToStoresTool(server, client);
130
+ registerListChangeRequestsTool(server, client);
131
+ registerApproveChangeRequestTool(server, client);
132
+ registerSetCountryPriceOverrideTool(server, client);
133
+ // Experiment writes (V8 Phase B.5)
134
+ registerCreateExperimentTool(server, client);
135
+ registerUpdateExperimentTool(server, client);
136
+ registerStartExperimentTool(server, client);
137
+ registerStopExperimentTool(server, client);
138
+ registerGetExperimentSummaryTool(server, client);
139
+ // Apps gap-fillers (V8 Phase B.6)
140
+ registerUpdateAppTool(server, client);
141
+ registerDeleteAppTool(server, client);
142
+ registerArchiveAppTool(server, client);
143
+ registerRestoreAppTool(server, client);
144
+ registerRunAppAutopilotTool(server, client);
145
+ registerRevertAppAutopilotTool(server, client);
146
+ // Entitlements gap-fillers (V8 Phase B.7)
147
+ registerGetEntitlementTool(server, client);
148
+ registerUpdateEntitlementTool(server, client);
149
+ registerDeleteEntitlementTool(server, client);
150
+ // Products gap-filler (V8 Phase B.8)
151
+ registerGetProductTool(server, client);
152
+ // Rules gap-fillers (V8 Phase B.9)
153
+ registerGetRuleTool(server, client);
154
+ registerListRuleVersionsTool(server, client);
155
+ registerRollbackRuleTool(server, client);
156
+ // Offerings gap-fillers (V8 Phase B.10)
157
+ registerGetOfferingTool(server, client);
158
+ registerUpdateOfferingTool(server, client);
159
+ // Drift detection + remediation (V8 Phase C)
160
+ registerCheckDriftTool(server, client);
161
+ registerResolveDriftTool(server, client);
162
+ registerSyncSuggestionsCountTool(server, client);
163
+ registerTriggerSyncTool(server, client);
22
164
  }
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { CapivvClient } from '../client.js';
3
+ export declare function registerListChangeRequestsTool(server: McpServer, client: CapivvClient): void;
@@ -0,0 +1,14 @@
1
+ import { z } from 'zod';
2
+ export function registerListChangeRequestsTool(server, client) {
3
+ server.tool('capivv_list_change_requests', 'List pricing change requests that exceeded the strategy\'s guardrails and are waiting for human approval. Filter by status (pending / approved / rejected) or by product_id.', {
4
+ app_id: z.string().describe('App to scope the listing to'),
5
+ status: z
6
+ .string()
7
+ .optional()
8
+ .describe('Filter by status: pending, approved, or rejected'),
9
+ product_id: z.string().optional().describe('Filter by product'),
10
+ }, async ({ app_id, status, product_id }) => {
11
+ const requests = await client.listPricingChangeRequests(app_id, status, product_id);
12
+ return { content: [{ type: 'text', text: JSON.stringify(requests, null, 2) }] };
13
+ });
14
+ }
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { CapivvClient } from '../client.js';
3
+ export declare function registerListEntitlementsTool(server: McpServer, client: CapivvClient): void;
@@ -0,0 +1,6 @@
1
+ export function registerListEntitlementsTool(server, client) {
2
+ server.tool('capivv_list_entitlements', 'List all entitlements (feature access identifiers) configured in your Capivv account.', async () => {
3
+ const entitlements = await client.listEntitlements();
4
+ return { content: [{ type: 'text', text: JSON.stringify(entitlements, null, 2) }] };
5
+ });
6
+ }
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { CapivvClient } from '../client.js';
3
+ export declare function registerListPaywallsTool(server: McpServer, client: CapivvClient): void;
@@ -0,0 +1,6 @@
1
+ export function registerListPaywallsTool(server, client) {
2
+ server.tool('capivv_list_paywalls', 'List every paywall in the workspace with its type, status, view / conversion counts, and config. Use this to find a paywall_id before calling capivv_update_paywall or capivv_delete_paywall.', async () => {
3
+ const paywalls = await client.listPaywalls();
4
+ return { content: [{ type: 'text', text: JSON.stringify(paywalls, null, 2) }] };
5
+ });
6
+ }
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { CapivvClient } from '../client.js';
3
+ export declare function registerListPricingStrategiesTool(server: McpServer, client: CapivvClient): void;
@@ -0,0 +1,8 @@
1
+ export function registerListPricingStrategiesTool(server, client) {
2
+ server.tool('capivv_list_pricing_strategies', 'List every pricing strategy across the workspace, including affordability tier bounds, blend weights (PPP / Big Mac / FX-neutral), and guardrails. Use this to find a strategy_id before previewing or recomputing prices.', async () => {
3
+ const strategies = await client.listPricingStrategies();
4
+ return {
5
+ content: [{ type: 'text', text: JSON.stringify(strategies, null, 2) }],
6
+ };
7
+ });
8
+ }
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { CapivvClient } from '../client.js';
3
+ export declare function registerListPromotionsTool(server: McpServer, client: CapivvClient): void;
@@ -0,0 +1,6 @@
1
+ export function registerListPromotionsTool(server, client) {
2
+ server.tool('capivv_list_promotions', 'List every promotion in the workspace with its campaign type, status, schedule, discount, and redemption count. Use this to find a promotion_id before calling capivv_update_promotion or capivv_delete_promotion.', async () => {
3
+ const promotions = await client.listPromotions();
4
+ return { content: [{ type: 'text', text: JSON.stringify(promotions, null, 2) }] };
5
+ });
6
+ }
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { CapivvClient } from '../client.js';
3
+ export declare function registerListRescueFlowsTool(server: McpServer, client: CapivvClient): void;
@@ -0,0 +1,6 @@
1
+ export function registerListRescueFlowsTool(server, client) {
2
+ server.tool('capivv_list_rescue_flows', 'List every cancellation rescue flow in the workspace with its status, priority, conditions, and steps. Use this to find a rescue_flow_id before calling update / delete.', async () => {
3
+ const flows = await client.listRescueFlows();
4
+ return { content: [{ type: 'text', text: JSON.stringify(flows, null, 2) }] };
5
+ });
6
+ }
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { CapivvClient } from '../client.js';
3
+ export declare function registerListRuleVersionsTool(server: McpServer, client: CapivvClient): void;
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ export function registerListRuleVersionsTool(server, client) {
3
+ server.tool('capivv_list_rule_versions', 'List every saved version of a rule (history). Use capivv_rollback_rule with a version number to revert.', {
4
+ rule_id: z.string().describe('Rule ID'),
5
+ }, async ({ rule_id }) => {
6
+ const versions = await client.listRuleVersions(rule_id);
7
+ return { content: [{ type: 'text', text: JSON.stringify(versions, null, 2) }] };
8
+ });
9
+ }
@@ -1,11 +1,13 @@
1
1
  export function registerListRulesTool(server, client) {
2
- server.tool('capivv_list_rules', 'List all YAML-based business rules with their status, priority, and last update time.', async () => {
2
+ server.tool('capivv_list_rules', 'List all business rules with their status, priority, and last update time.', async () => {
3
3
  const rules = await client.listRules();
4
4
  const summary = rules.map((r) => ({
5
5
  id: r.id,
6
+ identifier: r.identifier,
6
7
  name: r.name,
7
8
  priority: r.priority,
8
- is_enabled: r.is_enabled,
9
+ status: r.status,
10
+ version: r.version,
9
11
  updated_at: r.updated_at,
10
12
  }));
11
13
  return { content: [{ type: 'text', text: JSON.stringify(summary, null, 2) }] };
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { CapivvClient } from '../client.js';
3
+ export declare function registerNextStepTool(server: McpServer, client: CapivvClient): void;
@@ -0,0 +1,123 @@
1
+ function buildSteps(state) {
2
+ const steps = [];
3
+ let stepNum = 1;
4
+ const total = 6;
5
+ // Step 1: App
6
+ steps.push({
7
+ step: stepNum++,
8
+ total_steps: total,
9
+ title: 'Register your app',
10
+ status: state.apps > 0 ? 'done' : 'needed',
11
+ what: 'Register your app with its platform and bundle ID.',
12
+ how: 'Use capivv_create_app with name, platform (ios/android/web), and bundle_id (e.g., "com.yourcompany.app").',
13
+ why: 'Every product and offering belongs to an app. This is the foundation of your setup.',
14
+ });
15
+ // Step 2: Entitlements
16
+ steps.push({
17
+ step: stepNum++,
18
+ total_steps: total,
19
+ title: 'Create entitlements',
20
+ status: state.entitlements > 0 ? 'done' : 'needed',
21
+ what: 'Define what features users unlock when they purchase (e.g., "pro", "premium").',
22
+ how: 'Use capivv_create_entitlement with identifier (e.g., "pro") and display_name (e.g., "Pro Access").',
23
+ why: 'Entitlements are how your app checks "does this user have access?" They decouple features from specific products.',
24
+ });
25
+ // Step 3: Store credentials (can't be done via MCP)
26
+ const storeStep = state.nextOnboardingStep === 'store_credentials_configured' || state.nextOnboardingStep === 'store_connected'
27
+ ? 'needed'
28
+ : state.products > 0
29
+ ? 'done'
30
+ : 'optional';
31
+ steps.push({
32
+ step: stepNum++,
33
+ total_steps: total,
34
+ title: 'Connect store credentials',
35
+ status: storeStep,
36
+ what: 'Connect your App Store Connect / Google Play credentials so Capivv can validate receipts and import products.',
37
+ how: 'Go to the Capivv dashboard → Settings → Developer → Integrations. For iOS: upload your App Store Connect API key (p8 file). For Android: upload your Google Play service account JSON.',
38
+ why: 'Without store credentials, Capivv cannot verify purchases or automatically sync subscription status changes.',
39
+ });
40
+ // Step 4: Products
41
+ steps.push({
42
+ step: stepNum++,
43
+ total_steps: total,
44
+ title: 'Create products',
45
+ status: state.products > 0 ? 'done' : 'needed',
46
+ what: 'Create your subscription or in-app purchase products, linked to entitlements. With a connected store integration, Capivv creates the product in Capivv AND in App Store Connect / Google Play in one call.',
47
+ how: state.apps > 0
48
+ ? 'Use capivv_create_product with app_id, external_id (the store product ID you want — Capivv will create it in the store too), product_type, prices, and entitlement_ids. Or use capivv_import_products to pull existing store products into Capivv.'
49
+ : 'First complete Step 1 (create an app), then use capivv_create_product.',
50
+ why: 'Products are end-to-end: Capivv writes to its database AND to the connected store(s) at the price you specify. Tier snapping is automatic and the response shows both the requested and the snapped price.',
51
+ });
52
+ // Step 5: Offerings
53
+ steps.push({
54
+ step: stepNum++,
55
+ total_steps: total,
56
+ title: 'Create an offering',
57
+ status: state.offerings > 0 ? 'done' : 'needed',
58
+ what: 'Bundle your products into an offering that your paywall will display.',
59
+ how: state.products > 0
60
+ ? 'Use capivv_create_offering with your app_id, an identifier (e.g., "default"), and packages that reference your product IDs.'
61
+ : 'First complete Step 4 (create products), then use capivv_create_offering.',
62
+ why: 'The SDK fetches offerings to populate your paywall. Without an offering, your app has nothing to show users.',
63
+ });
64
+ // Step 6: SDK integration
65
+ steps.push({
66
+ step: stepNum++,
67
+ total_steps: total,
68
+ title: 'Integrate the SDK',
69
+ status: state.onboardingComplete ? 'done' : 'needed',
70
+ what: 'Add the Capivv SDK to your app, configure it with your public API key, and implement the paywall.',
71
+ how: 'Get your public key from the Capivv dashboard (Settings → Developer → API Keys). Read capivv://docs/quickstart for code examples, or capivv://docs/guides/ios for a detailed iOS walkthrough.',
72
+ why: 'The SDK handles user identification, entitlement checking, purchase processing, and receipt validation.',
73
+ });
74
+ return steps;
75
+ }
76
+ export function registerNextStepTool(server, client) {
77
+ server.tool('capivv_next_step', 'Analyze your current Capivv setup and tell you exactly what to do next. Returns a prioritized checklist with clear instructions for each step.', async () => {
78
+ const [apps, products, entitlements, offerings, rules, onboarding] = await Promise.allSettled([
79
+ client.listApps(),
80
+ client.listProducts(),
81
+ client.listEntitlements(),
82
+ client.listOfferings(),
83
+ client.listRules(),
84
+ client.getOnboarding(),
85
+ ]);
86
+ const count = (r) => r.status === 'fulfilled' ? r.value.length : 0;
87
+ const state = {
88
+ apps: count(apps),
89
+ entitlements: count(entitlements),
90
+ products: count(products),
91
+ offerings: count(offerings),
92
+ rules: count(rules),
93
+ onboardingComplete: onboarding.status === 'fulfilled' && onboarding.value.is_complete,
94
+ nextOnboardingStep: onboarding.status === 'fulfilled' ? onboarding.value.next_step : null,
95
+ };
96
+ const steps = buildSteps(state);
97
+ const completed = steps.filter((s) => s.status === 'done').length;
98
+ const needed = steps.filter((s) => s.status === 'needed');
99
+ const nextStep = needed[0] ?? null;
100
+ const result = {
101
+ progress: `${completed}/${steps.length} steps completed`,
102
+ setup_complete: needed.length === 0,
103
+ steps,
104
+ };
105
+ if (nextStep) {
106
+ result.next_action = {
107
+ summary: `Step ${nextStep.step}/${nextStep.total_steps}: ${nextStep.title}`,
108
+ what: nextStep.what,
109
+ how: nextStep.how,
110
+ why: nextStep.why,
111
+ };
112
+ }
113
+ else {
114
+ result.next_action = {
115
+ summary: 'Setup complete! Your Capivv integration is ready.',
116
+ what: 'Your app, entitlements, products, and offerings are all configured.',
117
+ how: 'Use capivv_get_analytics to monitor your subscription metrics, or capivv_apply_rule to add business rules like trial offers or churn recovery.',
118
+ why: 'You can now focus on optimizing conversions and reducing churn.',
119
+ };
120
+ }
121
+ return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
122
+ });
123
+ }
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { CapivvClient } from '../client.js';
3
+ export declare function registerPreviewPricingTool(server: McpServer, client: CapivvClient): void;
@@ -0,0 +1,13 @@
1
+ import { z } from 'zod';
2
+ export function registerPreviewPricingTool(server, client) {
3
+ server.tool('capivv_preview_pricing', 'Preview the prices a pricing strategy would compute for a product, without applying them. Returns proposed prices per country, the factor breakdown (FX / PPP / Big Mac contributions), and which countries would trigger the guardrails.', {
4
+ product_id: z.string().describe('Product to preview pricing for'),
5
+ strategy_id: z
6
+ .string()
7
+ .optional()
8
+ .describe('Strategy to use. Defaults to the product\'s assigned strategy.'),
9
+ }, async ({ product_id, strategy_id }) => {
10
+ const result = await client.previewPricing(product_id, strategy_id);
11
+ return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
12
+ });
13
+ }
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { CapivvClient } from '../client.js';
3
+ export declare function registerPushPricesToStoresTool(server: McpServer, client: CapivvClient): void;
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ export function registerPushPricesToStoresTool(server, client) {
3
+ server.tool('capivv_push_prices_to_stores', 'Push the current Capivv prices for a product to the connected stores (App Store Connect / Google Play). Snaps each price to the nearest store tier as needed. Returns counts of pushed / failed / skipped (skipped = no integration connected for that platform).', {
4
+ product_id: z.string().describe('Product whose Capivv prices should be pushed to stores'),
5
+ }, async ({ product_id }) => {
6
+ const result = await client.pushPricesToStores(product_id);
7
+ return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
8
+ });
9
+ }
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { CapivvClient } from '../client.js';
3
+ export declare function registerRecomputePricesTool(server: McpServer, client: CapivvClient): void;
@@ -0,0 +1,24 @@
1
+ import { z } from 'zod';
2
+ export function registerRecomputePricesTool(server, client) {
3
+ server.tool('capivv_recompute_prices', [
4
+ 'Recompute prices and apply them to Capivv. Pass `product_id` to recompute one product, or `strategy_id` to recompute every product tied to that strategy.',
5
+ 'Changes within the strategy\'s guardrails are auto-applied. Changes that exceed `max_auto_change_pct` / `max_auto_decrease_pct` are queued as change requests for human approval (use capivv_list_change_requests + capivv_approve_change_request).',
6
+ 'This does NOT push to the stores — call capivv_push_prices_to_stores afterwards.',
7
+ ].join(' '), {
8
+ product_id: z
9
+ .string()
10
+ .optional()
11
+ .describe('Product to recompute. Mutually exclusive with strategy_id.'),
12
+ strategy_id: z
13
+ .string()
14
+ .optional()
15
+ .describe('Strategy to recompute (applies to every product on it). Mutually exclusive with product_id.'),
16
+ reason: z
17
+ .string()
18
+ .optional()
19
+ .describe('Free-form reason for the recompute (logged on every change request). Defaults to "manual".'),
20
+ }, async (args) => {
21
+ const result = await client.recomputePrices(args);
22
+ return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
23
+ });
24
+ }
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { CapivvClient } from '../client.js';
3
+ export declare function registerResolveDriftTool(server: McpServer, client: CapivvClient): void;
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod';
2
+ export function registerResolveDriftTool(server, client) {
3
+ server.tool('capivv_resolve_drift', [
4
+ 'Resolve a drift suggestion by ID. `accept` applies the store-side change to Capivv (e.g., imports the new product, updates the local price); `dismiss` marks the suggestion as ignored without changing anything.',
5
+ 'For "Capivv has it but the store does not" cases, use capivv_create_product instead — that path re-creates the store-side record from Capivv via the Phase A helpers.',
6
+ ].join(' '), {
7
+ suggestion_id: z.string().describe('Sync suggestion ID (returned by capivv_check_drift)'),
8
+ action: z
9
+ .enum(['accept', 'dismiss'])
10
+ .describe('"accept" applies the change to Capivv; "dismiss" ignores it.'),
11
+ }, async ({ suggestion_id, action }) => {
12
+ const suggestion = await client.resolveSyncSuggestion(suggestion_id, action);
13
+ return { content: [{ type: 'text', text: JSON.stringify(suggestion, null, 2) }] };
14
+ });
15
+ }
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { CapivvClient } from '../client.js';
3
+ export declare function registerRestoreAppTool(server: McpServer, client: CapivvClient): void;
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ export function registerRestoreAppTool(server, client) {
3
+ server.tool('capivv_restore_app', 'Restore a previously archived app. Inverse of capivv_archive_app.', {
4
+ app_id: z.string().describe('App ID to restore'),
5
+ }, async ({ app_id }) => {
6
+ const app = await client.restoreApp(app_id);
7
+ return { content: [{ type: 'text', text: JSON.stringify(app, null, 2) }] };
8
+ });
9
+ }
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { CapivvClient } from '../client.js';
3
+ export declare function registerRevertAppAutopilotTool(server: McpServer, client: CapivvClient): void;
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ export function registerRevertAppAutopilotTool(server, client) {
3
+ server.tool('capivv_revert_app_autopilot', 'Revert autopilot-generated artifacts for an app. Removes entitlements, products, offerings, and rules that were auto-created by capivv_run_app_autopilot. Manually-created records are preserved.', {
4
+ app_id: z.string().describe('App ID to revert autopilot on'),
5
+ }, async ({ app_id }) => {
6
+ const result = await client.revertAppAutopilot(app_id);
7
+ return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
8
+ });
9
+ }
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { CapivvClient } from '../client.js';
3
+ export declare function registerRollbackRuleTool(server: McpServer, client: CapivvClient): void;
@@ -0,0 +1,10 @@
1
+ import { z } from 'zod';
2
+ export function registerRollbackRuleTool(server, client) {
3
+ server.tool('capivv_rollback_rule', 'Roll a rule back to a previous version. Use capivv_list_rule_versions to find the target version number.', {
4
+ rule_id: z.string().describe('Rule ID'),
5
+ version: z.number().describe('Version number to roll back to'),
6
+ }, async ({ rule_id, version }) => {
7
+ const rule = await client.rollbackRule(rule_id, version);
8
+ return { content: [{ type: 'text', text: JSON.stringify(rule, null, 2) }] };
9
+ });
10
+ }
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { CapivvClient } from '../client.js';
3
+ export declare function registerRunAppAutopilotTool(server: McpServer, client: CapivvClient): void;
@@ -0,0 +1,9 @@
1
+ import { z } from 'zod';
2
+ export function registerRunAppAutopilotTool(server, client) {
3
+ server.tool('capivv_run_app_autopilot', 'Run autopilot for an app: idempotent re-seeding of entitlements, products, offerings, and rules from the connected store data. Safe to call repeatedly. Use capivv_revert_app_autopilot to undo.', {
4
+ app_id: z.string().describe('App ID to run autopilot on'),
5
+ }, async ({ app_id }) => {
6
+ const result = await client.runAppAutopilot(app_id);
7
+ return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
8
+ });
9
+ }
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { CapivvClient } from '../client.js';
3
+ export declare function registerSetCountryPriceOverrideTool(server: McpServer, client: CapivvClient): void;
@@ -0,0 +1,13 @@
1
+ import { z } from 'zod';
2
+ export function registerSetCountryPriceOverrideTool(server, client) {
3
+ server.tool('capivv_set_country_price_override', 'Set a manual price override for a product in a specific country. Overridden prices are NOT touched by capivv_recompute_prices — they hold the value the user set until cleared. Use capivv_push_prices_to_stores to propagate the override to App Store Connect / Google Play.', {
4
+ product_id: z.string().describe('Product ID'),
5
+ country_code: z.string().describe('ISO 3166-1 alpha-2 country code (e.g. "US", "DE", "JP")'),
6
+ store: z.string().describe('Which store this price targets: "apple", "google", or "both"'),
7
+ currency: z.string().describe('ISO 4217 currency code (e.g. "USD", "EUR")'),
8
+ amount_cents: z.number().describe('Price in cents (e.g. 999 for $9.99)'),
9
+ }, async (args) => {
10
+ const result = await client.setCountryPriceOverride(args);
11
+ return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
12
+ });
13
+ }
@@ -0,0 +1,3 @@
1
+ import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import type { CapivvClient } from '../client.js';
3
+ export declare function registerSetupWizardTool(server: McpServer, client: CapivvClient): void;