@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
@@ -0,0 +1,200 @@
1
+ export function registerVerifySetupTool(server, client) {
2
+ server.tool('capivv_verify_setup', 'Verify your Capivv setup is complete and correctly configured. Checks apps, entitlements, products, offerings, and store connectivity. Returns a pass/fail checklist with fix instructions for any issues.', async () => {
3
+ const [apps, products, entitlements, offerings, onboarding, health] = await Promise.allSettled([
4
+ client.listApps(),
5
+ client.listProducts(),
6
+ client.listEntitlements(),
7
+ client.listOfferings(),
8
+ client.getOnboarding(),
9
+ client.healthCheck(),
10
+ ]);
11
+ const checks = [];
12
+ // 1. API connectivity
13
+ if (health.status === 'fulfilled' && health.value) {
14
+ checks.push({
15
+ name: 'API connectivity',
16
+ status: 'pass',
17
+ detail: 'Successfully connected to Capivv API.',
18
+ });
19
+ }
20
+ else {
21
+ checks.push({
22
+ name: 'API connectivity',
23
+ status: 'fail',
24
+ detail: 'Cannot reach Capivv API.',
25
+ fix: 'Check your CAPIVV_API_KEY and CAPIVV_API_URL environment variables. Ensure the API key is valid and not revoked.',
26
+ });
27
+ }
28
+ // 2. Apps
29
+ const appList = apps.status === 'fulfilled' ? apps.value : [];
30
+ if (appList.length > 0) {
31
+ const platforms = [...new Set(appList.map((a) => a.platform))].join(', ');
32
+ checks.push({
33
+ name: 'Apps registered',
34
+ status: 'pass',
35
+ detail: `${appList.length} app(s) registered (${platforms}).`,
36
+ });
37
+ // Check for missing bundle IDs
38
+ const missingBundleId = appList.filter((a) => !a.bundle_id);
39
+ if (missingBundleId.length > 0) {
40
+ checks.push({
41
+ name: 'App bundle IDs',
42
+ status: 'warn',
43
+ detail: `${missingBundleId.length} app(s) missing bundle ID: ${missingBundleId.map((a) => a.name).join(', ')}.`,
44
+ fix: 'Each app should have a bundle_id matching your store listing (e.g., com.yourcompany.yourapp).',
45
+ });
46
+ }
47
+ }
48
+ else {
49
+ checks.push({
50
+ name: 'Apps registered',
51
+ status: 'fail',
52
+ detail: 'No apps registered.',
53
+ fix: 'Use capivv_create_app or capivv_setup_wizard to register your app with its platform and bundle ID.',
54
+ });
55
+ }
56
+ // 3. Entitlements
57
+ const entitlementList = entitlements.status === 'fulfilled' ? entitlements.value : [];
58
+ if (entitlementList.length > 0) {
59
+ const ids = entitlementList.map((e) => e.identifier).join(', ');
60
+ checks.push({
61
+ name: 'Entitlements defined',
62
+ status: 'pass',
63
+ detail: `${entitlementList.length} entitlement(s): ${ids}.`,
64
+ });
65
+ }
66
+ else {
67
+ checks.push({
68
+ name: 'Entitlements defined',
69
+ status: 'fail',
70
+ detail: 'No entitlements defined.',
71
+ fix: 'Use capivv_create_entitlement to define what features users unlock (e.g., identifier: "pro", display_name: "Pro Access").',
72
+ });
73
+ }
74
+ // 4. Products
75
+ const productList = products.status === 'fulfilled' ? products.value : [];
76
+ if (productList.length > 0) {
77
+ checks.push({
78
+ name: 'Products created',
79
+ status: 'pass',
80
+ detail: `${productList.length} product(s) created.`,
81
+ });
82
+ // Check products linked to entitlements
83
+ const unlinked = productList.filter((p) => !p.entitlement_ids || p.entitlement_ids.length === 0);
84
+ if (unlinked.length > 0) {
85
+ checks.push({
86
+ name: 'Products linked to entitlements',
87
+ status: 'warn',
88
+ detail: `${unlinked.length} product(s) not linked to any entitlement: ${unlinked.map((p) => p.display_name).join(', ')}.`,
89
+ fix: 'Use capivv_update_product to add entitlement_ids to these products. Without entitlement links, purchases won\'t grant feature access.',
90
+ });
91
+ }
92
+ else {
93
+ checks.push({
94
+ name: 'Products linked to entitlements',
95
+ status: 'pass',
96
+ detail: 'All products are linked to at least one entitlement.',
97
+ });
98
+ }
99
+ }
100
+ else {
101
+ checks.push({
102
+ name: 'Products created',
103
+ status: 'fail',
104
+ detail: 'No products created.',
105
+ fix: 'Use capivv_create_product to create subscription products. The external_id must exactly match your App Store / Google Play product ID.',
106
+ });
107
+ }
108
+ // 5. Offerings
109
+ const offeringList = offerings.status === 'fulfilled' ? offerings.value : [];
110
+ if (offeringList.length > 0) {
111
+ const defaultOffering = offeringList.find((o) => o.is_default);
112
+ const totalPackages = offeringList.reduce((sum, o) => sum + (o.packages?.length ?? 0), 0);
113
+ checks.push({
114
+ name: 'Offerings configured',
115
+ status: 'pass',
116
+ detail: `${offeringList.length} offering(s) with ${totalPackages} total package(s).`,
117
+ });
118
+ if (!defaultOffering) {
119
+ checks.push({
120
+ name: 'Default offering set',
121
+ status: 'warn',
122
+ detail: 'No offering is marked as default.',
123
+ fix: 'Create or update an offering with is_default: true. The SDK fetches the default offering for paywalls.',
124
+ });
125
+ }
126
+ else {
127
+ checks.push({
128
+ name: 'Default offering set',
129
+ status: 'pass',
130
+ detail: `Default offering: "${defaultOffering.identifier}" with ${defaultOffering.packages?.length ?? 0} package(s).`,
131
+ });
132
+ }
133
+ // Check for empty offerings
134
+ const emptyOfferings = offeringList.filter((o) => !o.packages || o.packages.length === 0);
135
+ if (emptyOfferings.length > 0) {
136
+ checks.push({
137
+ name: 'Offerings have packages',
138
+ status: 'warn',
139
+ detail: `${emptyOfferings.length} offering(s) have no packages: ${emptyOfferings.map((o) => o.identifier).join(', ')}.`,
140
+ fix: 'An offering without packages has nothing to display on your paywall. Add products as packages to these offerings.',
141
+ });
142
+ }
143
+ }
144
+ else {
145
+ checks.push({
146
+ name: 'Offerings configured',
147
+ status: 'fail',
148
+ detail: 'No offerings created.',
149
+ fix: 'Use capivv_create_offering to bundle your products into an offering. This is what your paywall displays to users.',
150
+ });
151
+ }
152
+ // 6. Store credentials (check via onboarding)
153
+ if (onboarding.status === 'fulfilled') {
154
+ const ob = onboarding.value;
155
+ const storeStep = ob.steps?.find((s) => s.key === 'store_credentials_configured' || s.key === 'store_connected');
156
+ if (storeStep) {
157
+ if (storeStep.completed) {
158
+ checks.push({
159
+ name: 'Store credentials connected',
160
+ status: 'pass',
161
+ detail: 'App store credentials are configured.',
162
+ });
163
+ }
164
+ else {
165
+ checks.push({
166
+ name: 'Store credentials connected',
167
+ status: 'warn',
168
+ detail: 'Store credentials not yet configured.',
169
+ fix: 'Go to the Capivv dashboard → Settings → Developer → Integrations. Upload your App Store Connect API key (.p8 file) or Google Play service account JSON. This enables receipt validation and subscription status sync.',
170
+ });
171
+ }
172
+ }
173
+ }
174
+ // Summary
175
+ const passed = checks.filter((c) => c.status === 'pass').length;
176
+ const failed = checks.filter((c) => c.status === 'fail').length;
177
+ const warned = checks.filter((c) => c.status === 'warn').length;
178
+ let overallStatus;
179
+ let summary;
180
+ if (failed === 0 && warned === 0) {
181
+ overallStatus = 'ready';
182
+ summary = 'Your Capivv setup is complete and ready for integration!';
183
+ }
184
+ else if (failed === 0) {
185
+ overallStatus = 'mostly_ready';
186
+ summary = `Setup is functional but has ${warned} warning(s) to address for a production-quality integration.`;
187
+ }
188
+ else {
189
+ overallStatus = 'incomplete';
190
+ summary = `Setup is incomplete: ${failed} required item(s) missing. Fix the failing checks to get started.`;
191
+ }
192
+ const result = {
193
+ status: overallStatus,
194
+ summary,
195
+ score: `${passed}/${checks.length} checks passed`,
196
+ checks,
197
+ };
198
+ return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
199
+ });
200
+ }
@@ -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 registerWhoamiTool(server: McpServer, client: CapivvClient): void;
@@ -0,0 +1,31 @@
1
+ // Introduced in V6 Phase A to address the cross-org API key mismatch from the
2
+ // 2026-04-12 customer audit (Defect 3d). Users holding an API key for one org
3
+ // while viewing a different org in the dashboard now have an immediate way to
4
+ // confirm which org and apps their MCP integration reaches.
5
+ export function registerWhoamiTool(server, client) {
6
+ server.tool('capivv_whoami', 'Show which Capivv workspace (organization) and apps the current API key is connected to. Use this first when something looks wrong — e.g., products or entitlements appear missing — to confirm the MCP is pointed at the right workspace.', async () => {
7
+ const me = await client.whoami();
8
+ const lines = [
9
+ `Workspace: ${me.org_name} (${me.tenant_id})`,
10
+ `Key type: ${me.key_type ?? 'jwt-session'}`,
11
+ ];
12
+ if (me.app_id) {
13
+ lines.push(`Scoped to app: ${me.app_id}`);
14
+ }
15
+ if (me.apps.length === 0) {
16
+ lines.push('Apps: (none yet — connect a store in the Capivv dashboard to import apps)');
17
+ }
18
+ else {
19
+ lines.push(`Apps (${me.apps.length}):`);
20
+ for (const app of me.apps) {
21
+ lines.push(` • ${app.name} — ${app.bundle_id} (${app.platform})`);
22
+ }
23
+ }
24
+ return {
25
+ content: [
26
+ { type: 'text', text: lines.join('\n') },
27
+ { type: 'text', text: JSON.stringify(me, null, 2) },
28
+ ],
29
+ };
30
+ });
31
+ }