@capivv/mcp-server 0.1.3 → 0.2.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 (49) hide show
  1. package/README.md +73 -2
  2. package/dist/client.d.ts +15 -3
  3. package/dist/client.js +45 -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/autopilot-status.d.ts +3 -0
  19. package/dist/tools/autopilot-status.js +117 -0
  20. package/dist/tools/create-app.d.ts +3 -0
  21. package/dist/tools/create-app.js +13 -0
  22. package/dist/tools/create-entitlement.d.ts +3 -0
  23. package/dist/tools/create-entitlement.js +11 -0
  24. package/dist/tools/create-product.d.ts +3 -0
  25. package/dist/tools/create-product.js +42 -0
  26. package/dist/tools/delete-product.d.ts +3 -0
  27. package/dist/tools/delete-product.js +9 -0
  28. package/dist/tools/delete-rule.d.ts +3 -0
  29. package/dist/tools/delete-rule.js +9 -0
  30. package/dist/tools/import-products.js +7 -5
  31. package/dist/tools/index.js +40 -1
  32. package/dist/tools/list-entitlements.d.ts +3 -0
  33. package/dist/tools/list-entitlements.js +6 -0
  34. package/dist/tools/list-rules.js +4 -2
  35. package/dist/tools/next-step.d.ts +3 -0
  36. package/dist/tools/next-step.js +123 -0
  37. package/dist/tools/setup-wizard.d.ts +3 -0
  38. package/dist/tools/setup-wizard.js +259 -0
  39. package/dist/tools/status.js +25 -1
  40. package/dist/tools/update-product.d.ts +3 -0
  41. package/dist/tools/update-product.js +16 -0
  42. package/dist/tools/verify-setup.d.ts +3 -0
  43. package/dist/tools/verify-setup.js +200 -0
  44. package/dist/tools/whoami.d.ts +3 -0
  45. package/dist/tools/whoami.js +31 -0
  46. package/dist/types.d.ts +115 -79
  47. package/dist/types.js +0 -2
  48. package/mcp.json +89 -0
  49. package/package.json +8 -2
@@ -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
+ }
package/dist/types.d.ts CHANGED
@@ -1,8 +1,42 @@
1
+ export interface ApiKeyUsageSample {
2
+ bucket_start: string;
3
+ client_ip: string | null;
4
+ sdk_version: string | null;
5
+ country_code: string | null;
6
+ request_count: number;
7
+ error_count: number;
8
+ }
9
+ export interface ApiKeyUsageSummary {
10
+ total_requests: number;
11
+ total_errors: number;
12
+ distinct_ips: number;
13
+ distinct_countries: number;
14
+ distinct_sdk_versions: number;
15
+ }
16
+ export interface ApiKeyUsageResponse {
17
+ hours: number;
18
+ summary: ApiKeyUsageSummary;
19
+ samples: ApiKeyUsageSample[];
20
+ }
21
+ export interface WhoamiResponse {
22
+ tenant_id: string;
23
+ org_name: string;
24
+ key_type?: 'public' | 'secret';
25
+ app_id?: string;
26
+ apps: WhoamiApp[];
27
+ }
28
+ export interface WhoamiApp {
29
+ id: string;
30
+ name: string;
31
+ bundle_id: string;
32
+ platform: string;
33
+ }
1
34
  export interface App {
2
35
  id: string;
3
36
  name: string;
4
37
  platform: string;
5
- bundle_id: string;
38
+ bundle_id: string | null;
39
+ settings: Record<string, unknown>;
6
40
  archived_at: string | null;
7
41
  created_at: string;
8
42
  updated_at: string;
@@ -15,6 +49,7 @@ export interface Product {
15
49
  display_name: string;
16
50
  description: string | null;
17
51
  entitlement_ids: string[];
52
+ metadata: Record<string, unknown>;
18
53
  created_at: string;
19
54
  updated_at: string;
20
55
  }
@@ -26,66 +61,66 @@ export interface Entitlement {
26
61
  created_at: string;
27
62
  updated_at: string;
28
63
  }
29
- export interface Package {
64
+ export interface OfferingPackage {
30
65
  identifier: string;
31
66
  product_id: string;
32
67
  display_name: string;
68
+ description: string | null;
33
69
  package_type: string;
34
70
  position: number;
35
71
  }
36
72
  export interface Offering {
37
73
  id: string;
38
- app_id: string;
39
74
  identifier: string;
40
75
  display_name: string;
41
76
  description: string | null;
42
77
  is_default: boolean;
43
- packages: Package[];
78
+ packages: OfferingPackage[];
79
+ /** V7 autopilot provenance, omitted for user-created. */
80
+ generated_by?: string | null;
81
+ app_id?: string;
44
82
  created_at: string;
45
83
  updated_at: string;
46
84
  }
47
85
  export interface Rule {
48
86
  id: string;
87
+ identifier: string;
49
88
  name: string;
50
- content: string;
89
+ description: string | null;
51
90
  priority: number;
52
- is_enabled: boolean;
91
+ status: string;
92
+ conditions: unknown;
93
+ actions: unknown;
94
+ guardrails: unknown;
95
+ schedule: unknown | null;
96
+ metadata: unknown;
97
+ version: number;
98
+ /** V7 autopilot provenance. */
99
+ generated_by?: string | null;
100
+ created_at: string;
53
101
  updated_at: string;
102
+ activated_at: string | null;
54
103
  }
55
104
  export interface ExperimentVariant {
56
105
  id: string;
57
106
  name: string;
58
107
  is_control: boolean;
59
108
  traffic_percent: number;
60
- sample_size: number;
61
- conversion_count: number;
62
- conversion_rate: number | null;
63
- uplift_percent: number | null;
109
+ [key: string]: unknown;
64
110
  }
65
111
  export interface Experiment {
66
112
  id: string;
67
113
  name: string;
68
114
  description: string | null;
69
115
  status: string;
70
- target_metric: string | null;
71
- start_date: string | null;
72
- end_date: string | null;
73
- confidence_level: number;
74
116
  variants: ExperimentVariant[];
117
+ [key: string]: unknown;
75
118
  }
76
119
  export interface ExperimentSummary {
77
- experiment_id: string;
78
- experiment_name: string;
120
+ id: string;
121
+ name: string;
79
122
  status: string;
80
- total_participants: number;
81
- leading_variant: string | null;
82
- uplift: number | null;
83
- confidence: number | null;
84
- days_running: number;
85
- }
86
- export interface PeriodComparison {
87
- mrr_change_percent: number;
88
- subscriptions_change_percent: number;
123
+ [key: string]: unknown;
89
124
  }
90
125
  export interface AnalyticsOverview {
91
126
  mrr: number;
@@ -97,65 +132,29 @@ export interface AnalyticsOverview {
97
132
  churn_rate: number;
98
133
  arpu: number;
99
134
  arpu_formatted: string;
100
- period_comparison: PeriodComparison | null;
101
- }
102
- export interface OnboardingProgress {
103
- onboarding_mode: string;
104
- welcome_seen: boolean;
105
- app_created: boolean;
106
- entitlement_created: boolean;
107
- store_credentials_configured: boolean;
108
- product_created: boolean;
109
- offering_created: boolean;
110
- sdk_key_viewed: boolean;
111
- store_connected: boolean;
112
- import_reviewed: boolean;
113
- import_completed: boolean;
135
+ period_comparison: {
136
+ mrr_change: string;
137
+ mrr_change_percent: number;
138
+ subscriptions_change: string;
139
+ subscriptions_change_percent: number;
140
+ };
141
+ [key: string]: unknown;
142
+ }
143
+ export interface OnboardingStep {
144
+ key: string;
145
+ label: string;
146
+ completed: boolean;
114
147
  }
115
148
  export interface OnboardingResponse {
116
- progress: OnboardingProgress;
117
149
  is_complete: boolean;
118
150
  completed_steps: number;
119
151
  total_steps: number;
152
+ steps: OnboardingStep[];
120
153
  next_step: string | null;
121
- }
122
- export interface SuggestedProduct {
123
- external_id: string;
124
- product_type: string;
125
- display_name: string;
126
- source: string;
127
- already_exists: boolean;
128
- }
129
- export interface SuggestedEntitlement {
130
- identifier: string;
131
- display_name: string;
132
- already_exists: boolean;
133
- }
134
- export interface SuggestedOffering {
135
- identifier: string;
136
- display_name: string;
137
- is_default: boolean;
138
- }
139
- export interface ImportSuggestion {
140
- products: SuggestedProduct[];
141
- entitlements: SuggestedEntitlement[];
142
- offerings: SuggestedOffering[];
143
- warnings: string[];
144
- }
145
- export interface ExistingEntityCounts {
146
- apps: number;
147
- products: number;
148
- entitlements: number;
149
- offerings: number;
150
- }
151
- export interface StoreError {
152
- source: string;
153
- message: string;
154
+ [key: string]: unknown;
154
155
  }
155
156
  export interface ImportPreviewResponse {
156
- suggestion: ImportSuggestion;
157
- existing_counts: ExistingEntityCounts;
158
- store_errors: StoreError[];
157
+ [key: string]: unknown;
159
158
  }
160
159
  export interface CreateOfferingRequest {
161
160
  app_id: string;
@@ -172,13 +171,50 @@ export interface CreateOfferingRequest {
172
171
  }>;
173
172
  }
174
173
  export interface CreateRuleRequest {
174
+ identifier: string;
175
175
  name: string;
176
- content: string;
177
- priority: number;
178
- is_enabled: boolean;
176
+ description?: string;
177
+ priority?: number;
178
+ conditions: unknown;
179
+ actions: unknown;
180
+ guardrails?: unknown[] | undefined;
181
+ schedule?: unknown;
182
+ metadata?: unknown;
183
+ }
184
+ export interface ValidateRuleRequest {
185
+ conditions: unknown;
186
+ actions: unknown;
187
+ guardrails?: unknown[] | undefined;
179
188
  }
180
189
  export interface ValidateRuleResponse {
181
190
  is_valid: boolean;
182
191
  errors: string[];
183
192
  warnings: string[];
184
193
  }
194
+ export interface CreateAppRequest {
195
+ name: string;
196
+ platform: string;
197
+ bundle_id: string;
198
+ }
199
+ export interface CreateEntitlementRequest {
200
+ identifier: string;
201
+ display_name: string;
202
+ description?: string;
203
+ }
204
+ export interface CreateProductRequest {
205
+ app_id: string;
206
+ external_id: string;
207
+ product_type: string;
208
+ display_name: string;
209
+ description?: string;
210
+ entitlement_ids?: string[];
211
+ subscription?: {
212
+ billing_period: string;
213
+ grace_period_enabled?: boolean;
214
+ };
215
+ prices?: Array<{
216
+ currency: string;
217
+ amount_cents: number;
218
+ is_default?: boolean;
219
+ }>;
220
+ }
package/dist/types.js CHANGED
@@ -1,3 +1 @@
1
- // API response types mirrored from crates/capivv-cli/src/client.rs
2
- // and dashboard/src/types/api.ts
3
1
  export {};
package/mcp.json CHANGED
@@ -20,6 +20,77 @@
20
20
  }
21
21
  },
22
22
  "tools": [
23
+ {
24
+ "name": "capivv_whoami",
25
+ "description": "Show which Capivv workspace (organization) and apps the current API key is connected to. Use this first when something looks wrong — e.g., products appear missing — to confirm the MCP is pointed at the right workspace."
26
+ },
27
+ {
28
+ "name": "capivv_autopilot_status",
29
+ "description": "Show everything autopilot generated for a specific app — offerings, entitlement rules, and experiments. Use after capivv_setup_wizard or product imports to confirm what was auto-created.",
30
+ "inputSchema": {
31
+ "type": "object",
32
+ "properties": {
33
+ "app_id": {
34
+ "type": "string",
35
+ "description": "The Capivv app ID to inspect"
36
+ }
37
+ },
38
+ "required": ["app_id"]
39
+ }
40
+ },
41
+ {
42
+ "name": "capivv_api_key_usage",
43
+ "description": "Fetch SDK request telemetry for a publishable API key (hourly buckets, distinct IPs, countries, SDK versions). Use to investigate a suspected leaked key.",
44
+ "inputSchema": {
45
+ "type": "object",
46
+ "properties": {
47
+ "api_key_id": {
48
+ "type": "string",
49
+ "description": "UUID of the api_keys row to inspect"
50
+ },
51
+ "hours": {
52
+ "type": "number",
53
+ "description": "Window in hours to summarize over (default 24, max 168)"
54
+ }
55
+ },
56
+ "required": ["api_key_id"]
57
+ }
58
+ },
59
+ {
60
+ "name": "capivv_next_step",
61
+ "description": "Analyze your current Capivv setup and tell you exactly what to do next. Returns a prioritized checklist with clear instructions for each step."
62
+ },
63
+ {
64
+ "name": "capivv_setup_wizard",
65
+ "description": "One-shot setup for an EXISTING app: creates entitlement, products, and offering on an app you imported from App Store Connect or Google Play via the dashboard. Output includes tenant_id + org_name so you can verify which workspace was written to.",
66
+ "inputSchema": {
67
+ "type": "object",
68
+ "properties": {
69
+ "bundle_id": { "type": "string", "description": "Bundle ID of an already-imported app. Omit if the workspace has exactly one app." },
70
+ "entitlement_id": { "type": "string", "description": "Entitlement identifier (e.g., pro, premium)" },
71
+ "products": {
72
+ "type": "array",
73
+ "description": "Subscription products to create",
74
+ "items": {
75
+ "type": "object",
76
+ "properties": {
77
+ "name": { "type": "string" },
78
+ "external_id": { "type": "string", "description": "Store product ID — must match App Store / Google Play exactly" },
79
+ "billing_period": { "type": "string", "description": "week, month, three_months, six_months, or year" },
80
+ "price_cents": { "type": "number", "description": "Price in USD cents (e.g., 799 for $7.99)" }
81
+ },
82
+ "required": ["name", "external_id", "billing_period", "price_cents"]
83
+ }
84
+ },
85
+ "offering_id": { "type": "string", "description": "Offering identifier (default: 'default')" }
86
+ },
87
+ "required": ["entitlement_id", "products"]
88
+ }
89
+ },
90
+ {
91
+ "name": "capivv_verify_setup",
92
+ "description": "Verify your Capivv setup is complete and correctly configured. Returns a pass/fail checklist with fix instructions for any issues."
93
+ },
23
94
  {
24
95
  "name": "capivv_status",
25
96
  "description": "Get the current status of your Capivv subscription platform including setup progress, resource counts, and key metrics."
@@ -127,6 +198,12 @@
127
198
  }
128
199
  ],
129
200
  "resources": [
201
+ {
202
+ "uri": "capivv://docs/quickstart",
203
+ "name": "quickstart",
204
+ "description": "Step-by-step quickstart guide: register app, create entitlements, create products, create offering, integrate SDK. Start here.",
205
+ "mimeType": "text/markdown"
206
+ },
130
207
  {
131
208
  "uri": "capivv://status",
132
209
  "name": "status",
@@ -144,6 +221,18 @@
144
221
  "name": "concepts",
145
222
  "description": "Glossary of Capivv subscription platform concepts (15 terms).",
146
223
  "mimeType": "application/json"
224
+ },
225
+ {
226
+ "uri": "capivv://docs/guides/ios",
227
+ "name": "guide-ios",
228
+ "description": "Complete iOS integration guide: App Store Connect setup, SDK installation, purchases, entitlements, testing, troubleshooting.",
229
+ "mimeType": "text/markdown"
230
+ },
231
+ {
232
+ "uri": "capivv://docs/guides/ai-prompts",
233
+ "name": "guide-ai-prompts",
234
+ "description": "Ready-to-use prompts for AI code generators (Lovable, Bolt, Cursor) to integrate Capivv on iOS, Android, Flutter, Web, Ionic.",
235
+ "mimeType": "text/markdown"
147
236
  }
148
237
  ]
149
238
  }
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "@capivv/mcp-server",
3
- "version": "0.1.3",
3
+ "version": "0.2.0",
4
4
  "description": "MCP server for managing Capivv subscription platform via AI assistants",
5
5
  "type": "module",
6
6
  "bin": {
7
- "capivv-mcp": "./dist/index.js"
7
+ "capivv-mcp": "./dist/index.js",
8
+ "capivv-mcp-http": "./dist/http.js"
8
9
  },
9
10
  "main": "./dist/index.js",
10
11
  "types": "./dist/index.d.ts",
@@ -34,6 +35,8 @@
34
35
  "scripts": {
35
36
  "build": "tsc",
36
37
  "dev": "tsx src/index.ts",
38
+ "dev:http": "tsx src/http.ts",
39
+ "start:http": "node dist/http.js",
37
40
  "test": "vitest run",
38
41
  "test:watch": "vitest",
39
42
  "typecheck": "tsc --noEmit",
@@ -41,9 +44,12 @@
41
44
  },
42
45
  "dependencies": {
43
46
  "@modelcontextprotocol/sdk": "^1.26.0",
47
+ "express": "^4.21.0",
48
+ "yaml": "^2.8.2",
44
49
  "zod": "^4.0.0"
45
50
  },
46
51
  "devDependencies": {
52
+ "@types/express": "^4.17.21",
47
53
  "@types/node": "^20.0.0",
48
54
  "tsx": "^4.0.0",
49
55
  "typescript": "^5.0.0",