mcp-twin 1.2.0 → 1.4.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.
- package/.env.example +30 -0
- package/PRD.md +682 -0
- package/dist/cli.js +41 -0
- package/dist/cli.js.map +1 -1
- package/dist/cloud/auth.d.ts +108 -0
- package/dist/cloud/auth.d.ts.map +1 -0
- package/dist/cloud/auth.js +199 -0
- package/dist/cloud/auth.js.map +1 -0
- package/dist/cloud/db.d.ts +21 -0
- package/dist/cloud/db.d.ts.map +1 -0
- package/dist/cloud/db.js +158 -0
- package/dist/cloud/db.js.map +1 -0
- package/dist/cloud/routes/auth.d.ts +7 -0
- package/dist/cloud/routes/auth.d.ts.map +1 -0
- package/dist/cloud/routes/auth.js +291 -0
- package/dist/cloud/routes/auth.js.map +1 -0
- package/dist/cloud/routes/billing.d.ts +7 -0
- package/dist/cloud/routes/billing.d.ts.map +1 -0
- package/dist/cloud/routes/billing.js +368 -0
- package/dist/cloud/routes/billing.js.map +1 -0
- package/dist/cloud/routes/twins.d.ts +7 -0
- package/dist/cloud/routes/twins.d.ts.map +1 -0
- package/dist/cloud/routes/twins.js +740 -0
- package/dist/cloud/routes/twins.js.map +1 -0
- package/dist/cloud/routes/usage.d.ts +7 -0
- package/dist/cloud/routes/usage.d.ts.map +1 -0
- package/dist/cloud/routes/usage.js +145 -0
- package/dist/cloud/routes/usage.js.map +1 -0
- package/dist/cloud/server.d.ts +10 -0
- package/dist/cloud/server.d.ts.map +1 -0
- package/dist/cloud/server.js +161 -0
- package/dist/cloud/server.js.map +1 -0
- package/dist/cloud/stripe.d.ts +60 -0
- package/dist/cloud/stripe.d.ts.map +1 -0
- package/dist/cloud/stripe.js +157 -0
- package/dist/cloud/stripe.js.map +1 -0
- package/package.json +25 -4
- package/src/cli.ts +10 -0
- package/src/cloud/auth.ts +269 -0
- package/src/cloud/db.ts +167 -0
- package/src/cloud/routes/auth.ts +355 -0
- package/src/cloud/routes/billing.ts +460 -0
- package/src/cloud/routes/twins.ts +908 -0
- package/src/cloud/routes/usage.ts +186 -0
- package/src/cloud/server.ts +171 -0
- package/src/cloud/stripe.ts +192 -0
package/.env.example
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# MCP Twin Cloud Configuration
|
|
2
|
+
|
|
3
|
+
# Database (PostgreSQL)
|
|
4
|
+
# Get a free database from Supabase: https://supabase.com
|
|
5
|
+
DATABASE_URL=postgresql://user:password@host:5432/database
|
|
6
|
+
|
|
7
|
+
# Server
|
|
8
|
+
PORT=3000
|
|
9
|
+
HOST=0.0.0.0
|
|
10
|
+
NODE_ENV=development
|
|
11
|
+
|
|
12
|
+
# Security
|
|
13
|
+
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
|
|
14
|
+
|
|
15
|
+
# CORS (comma-separated origins or * for all)
|
|
16
|
+
CORS_ORIGIN=*
|
|
17
|
+
|
|
18
|
+
# Stripe (for billing - optional)
|
|
19
|
+
# Get keys from https://dashboard.stripe.com/apikeys
|
|
20
|
+
STRIPE_SECRET_KEY=sk_test_...
|
|
21
|
+
STRIPE_WEBHOOK_SECRET=whsec_...
|
|
22
|
+
|
|
23
|
+
# Stripe Price IDs (create in Stripe Dashboard)
|
|
24
|
+
# Products > Add Product > Add Price > Copy Price ID
|
|
25
|
+
STRIPE_PRICE_STARTER=price_starter_monthly
|
|
26
|
+
STRIPE_PRICE_PRO=price_pro_monthly
|
|
27
|
+
|
|
28
|
+
# Debug flags (optional)
|
|
29
|
+
DEBUG_SQL=false
|
|
30
|
+
DEBUG_HTTP=false
|
package/PRD.md
ADDED
|
@@ -0,0 +1,682 @@
|
|
|
1
|
+
# MCP Twin Cloud - Product Requirements Document
|
|
2
|
+
|
|
3
|
+
**Version:** 1.0
|
|
4
|
+
**Author:** Prax Labs
|
|
5
|
+
**Date:** December 31, 2024
|
|
6
|
+
**Status:** Draft
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Executive Summary
|
|
11
|
+
|
|
12
|
+
MCP Twin Cloud transforms the open-source mcp-twin CLI into a managed cloud service, enabling developers to deploy, manage, and scale MCP servers with zero-downtime updates. The platform provides multi-tenant hosting, observability, and enterprise-grade reliability for AI agent infrastructure.
|
|
13
|
+
|
|
14
|
+
**Target Market:** Developers and teams using Claude, Cursor, Cline, VS Code, and Windsurf with multiple MCP servers.
|
|
15
|
+
|
|
16
|
+
**Business Model:** Freemium SaaS with tiered pricing based on usage (requests/month) and features.
|
|
17
|
+
|
|
18
|
+
---
|
|
19
|
+
|
|
20
|
+
## Goals & Success Metrics
|
|
21
|
+
|
|
22
|
+
### Primary Goals
|
|
23
|
+
|
|
24
|
+
1. **Launch MVP in 3 weeks** with functional auth, billing, and twin management
|
|
25
|
+
2. **Acquire 150+ free signups** in first month
|
|
26
|
+
3. **Convert 5% to paid** within 60 days
|
|
27
|
+
4. **Demonstrate investor-ready metrics** (MRR, unit economics, growth rate)
|
|
28
|
+
|
|
29
|
+
### Success Metrics
|
|
30
|
+
|
|
31
|
+
| Metric | Week 1 | Week 2 | Week 3 | Month 2 |
|
|
32
|
+
|--------|--------|--------|--------|---------|
|
|
33
|
+
| Signups | 50 | 100 | 150 | 300 |
|
|
34
|
+
| Paid Users | 0 | 2 | 5 | 15 |
|
|
35
|
+
| MRR | $0 | $58 | $295 | $1,000 |
|
|
36
|
+
| API Calls | 10K | 50K | 200K | 1M |
|
|
37
|
+
|
|
38
|
+
---
|
|
39
|
+
|
|
40
|
+
## User Personas
|
|
41
|
+
|
|
42
|
+
### Persona 1: Solo AI Developer ("Alex")
|
|
43
|
+
- Building AI agents with Claude/Cursor
|
|
44
|
+
- Uses 2-3 MCP servers locally
|
|
45
|
+
- Pain: Restarting clients when updating servers
|
|
46
|
+
- Value: Zero-downtime, simple deployment
|
|
47
|
+
|
|
48
|
+
### Persona 2: AI Agency Lead ("Jordan")
|
|
49
|
+
- Manages 5-10 MCP servers for clients
|
|
50
|
+
- Needs observability and multi-tenant isolation
|
|
51
|
+
- Pain: No centralized management, no usage metrics
|
|
52
|
+
- Value: Dashboard, logs, client billing data
|
|
53
|
+
|
|
54
|
+
### Persona 3: Enterprise Platform Team ("Sam")
|
|
55
|
+
- Deploying AI agents at scale (50+ servers)
|
|
56
|
+
- Requires SLAs, audit logs, SSO
|
|
57
|
+
- Pain: Building custom orchestration layer
|
|
58
|
+
- Value: Enterprise features, dedicated support
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## Feature Requirements
|
|
63
|
+
|
|
64
|
+
### Phase 1: Cloud Hosting + Auth (Week 1)
|
|
65
|
+
|
|
66
|
+
#### 1.1 HTTP API Server Mode
|
|
67
|
+
|
|
68
|
+
**Description:** Add cloud server mode to existing mcp-twin CLI.
|
|
69
|
+
|
|
70
|
+
**User Story:** As a developer, I want to run `npx mcp-twin --cloud` to start mcp-twin as an HTTP service so I can deploy it to cloud infrastructure.
|
|
71
|
+
|
|
72
|
+
**Requirements:**
|
|
73
|
+
- [ ] Add `--cloud` flag to CLI
|
|
74
|
+
- [ ] Start Express HTTP server on port 3000 (configurable via `--port`)
|
|
75
|
+
- [ ] Support environment-based configuration (DATABASE_URL, STRIPE_KEY, etc.)
|
|
76
|
+
- [ ] Health check endpoint: `GET /health`
|
|
77
|
+
- [ ] Graceful shutdown handling
|
|
78
|
+
|
|
79
|
+
#### 1.2 Authentication System
|
|
80
|
+
|
|
81
|
+
**Description:** Email/password auth with API key generation.
|
|
82
|
+
|
|
83
|
+
**User Stories:**
|
|
84
|
+
- As a new user, I want to sign up with email/password so I can access the platform
|
|
85
|
+
- As a user, I want to generate API keys so I can authenticate my MCP clients
|
|
86
|
+
- As a user, I want to revoke API keys so I can maintain security
|
|
87
|
+
|
|
88
|
+
**API Endpoints:**
|
|
89
|
+
|
|
90
|
+
| Method | Endpoint | Description | Auth |
|
|
91
|
+
|--------|----------|-------------|------|
|
|
92
|
+
| POST | `/api/auth/signup` | Create account | None |
|
|
93
|
+
| POST | `/api/auth/login` | Get session token | None |
|
|
94
|
+
| POST | `/api/auth/api-keys` | Generate API key | Session |
|
|
95
|
+
| DELETE | `/api/auth/api-keys/:id` | Revoke API key | Session |
|
|
96
|
+
| GET | `/api/auth/me` | Get current user | API Key |
|
|
97
|
+
|
|
98
|
+
**Request/Response Examples:**
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
// POST /api/auth/signup
|
|
102
|
+
Request: {
|
|
103
|
+
email: "user@example.com",
|
|
104
|
+
password: "securepassword123"
|
|
105
|
+
}
|
|
106
|
+
Response: {
|
|
107
|
+
userId: "uuid",
|
|
108
|
+
apiKey: "mtc_live_xxxxx",
|
|
109
|
+
message: "Welcome! Use this API key to create twins."
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
// POST /api/auth/login
|
|
113
|
+
Request: {
|
|
114
|
+
email: "user@example.com",
|
|
115
|
+
password: "securepassword123"
|
|
116
|
+
}
|
|
117
|
+
Response: {
|
|
118
|
+
sessionToken: "jwt_token",
|
|
119
|
+
expiresAt: "2024-01-30T00:00:00Z"
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
#### 1.3 Twin Management
|
|
124
|
+
|
|
125
|
+
**Description:** CRUD operations for twin configurations.
|
|
126
|
+
|
|
127
|
+
**User Stories:**
|
|
128
|
+
- As a user, I want to create a twin configuration so my MCP server runs in the cloud
|
|
129
|
+
- As a user, I want to list my twins so I can manage them
|
|
130
|
+
- As a user, I want to update twin config so I can change settings without recreating
|
|
131
|
+
- As a user, I want to delete twins I no longer need
|
|
132
|
+
|
|
133
|
+
**API Endpoints:**
|
|
134
|
+
|
|
135
|
+
| Method | Endpoint | Description | Auth |
|
|
136
|
+
|--------|----------|-------------|------|
|
|
137
|
+
| POST | `/api/twins` | Create twin | API Key |
|
|
138
|
+
| GET | `/api/twins` | List user's twins | API Key |
|
|
139
|
+
| GET | `/api/twins/:id` | Get twin details | API Key |
|
|
140
|
+
| PATCH | `/api/twins/:id` | Update twin config | API Key |
|
|
141
|
+
| DELETE | `/api/twins/:id` | Delete twin | API Key |
|
|
142
|
+
| POST | `/api/twins/:id/call` | Execute tool call | API Key |
|
|
143
|
+
| GET | `/api/twins/:id/logs` | Get execution logs | API Key |
|
|
144
|
+
| GET | `/api/twins/:id/status` | Get twin health | API Key |
|
|
145
|
+
|
|
146
|
+
**Request/Response Examples:**
|
|
147
|
+
|
|
148
|
+
```typescript
|
|
149
|
+
// POST /api/twins
|
|
150
|
+
Request: {
|
|
151
|
+
name: "my-mcp-server",
|
|
152
|
+
config: {
|
|
153
|
+
script: "/path/to/server.py",
|
|
154
|
+
ports: [8101, 8102],
|
|
155
|
+
healthEndpoint: "/health",
|
|
156
|
+
startupTimeout: 10
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
Response: {
|
|
160
|
+
twinId: "uuid",
|
|
161
|
+
name: "my-mcp-server",
|
|
162
|
+
status: "provisioning",
|
|
163
|
+
endpoints: {
|
|
164
|
+
active: "https://twins.mcp-twin.cloud/t/uuid/a",
|
|
165
|
+
standby: "https://twins.mcp-twin.cloud/t/uuid/b"
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// POST /api/twins/:id/call
|
|
170
|
+
Request: {
|
|
171
|
+
toolName: "search_files",
|
|
172
|
+
args: { query: "*.py", path: "/src" }
|
|
173
|
+
}
|
|
174
|
+
Response: {
|
|
175
|
+
result: { files: ["main.py", "utils.py"] },
|
|
176
|
+
durationMs: 45,
|
|
177
|
+
server: "a",
|
|
178
|
+
requestId: "req_xxxxx"
|
|
179
|
+
}
|
|
180
|
+
```
|
|
181
|
+
|
|
182
|
+
#### 1.4 Observability & Logging
|
|
183
|
+
|
|
184
|
+
**Description:** Automatic logging of all tool calls with searchable history.
|
|
185
|
+
|
|
186
|
+
**User Stories:**
|
|
187
|
+
- As a user, I want to see logs of all tool calls so I can debug issues
|
|
188
|
+
- As a user, I want to filter logs by status/time so I can find specific events
|
|
189
|
+
- As a user, I want to see latency metrics so I can monitor performance
|
|
190
|
+
|
|
191
|
+
**Log Entry Schema:**
|
|
192
|
+
```typescript
|
|
193
|
+
interface LogEntry {
|
|
194
|
+
id: string;
|
|
195
|
+
twinId: string;
|
|
196
|
+
userId: string;
|
|
197
|
+
toolName: string;
|
|
198
|
+
args: object;
|
|
199
|
+
result: object | null;
|
|
200
|
+
error: string | null;
|
|
201
|
+
status: 'success' | 'error' | 'timeout';
|
|
202
|
+
durationMs: number;
|
|
203
|
+
server: 'a' | 'b';
|
|
204
|
+
createdAt: Date;
|
|
205
|
+
}
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
---
|
|
209
|
+
|
|
210
|
+
### Phase 2: Stripe Integration + Billing (Week 2)
|
|
211
|
+
|
|
212
|
+
#### 2.1 Stripe Setup
|
|
213
|
+
|
|
214
|
+
**Description:** Payment processing with Stripe for subscriptions.
|
|
215
|
+
|
|
216
|
+
**Products/Prices:**
|
|
217
|
+
|
|
218
|
+
| Tier | Price | Stripe Price ID |
|
|
219
|
+
|------|-------|-----------------|
|
|
220
|
+
| Free | $0/month | (no subscription) |
|
|
221
|
+
| Starter | $29/month | price_starter_monthly |
|
|
222
|
+
| Professional | $149/month | price_pro_monthly |
|
|
223
|
+
| Enterprise | Custom | (contact sales) |
|
|
224
|
+
|
|
225
|
+
**Webhook Events to Handle:**
|
|
226
|
+
- `checkout.session.completed` → Activate subscription
|
|
227
|
+
- `customer.subscription.updated` → Update tier
|
|
228
|
+
- `customer.subscription.deleted` → Downgrade to free
|
|
229
|
+
- `invoice.payment_failed` → Send warning email
|
|
230
|
+
|
|
231
|
+
#### 2.2 Usage Tracking & Quotas
|
|
232
|
+
|
|
233
|
+
**Description:** Track API usage and enforce tier limits.
|
|
234
|
+
|
|
235
|
+
**Tier Limits:**
|
|
236
|
+
|
|
237
|
+
| Tier | Twins | Requests/Month | Log Retention | Support |
|
|
238
|
+
|------|-------|----------------|---------------|---------|
|
|
239
|
+
| Free | 1 | 10,000 | 24 hours | Community |
|
|
240
|
+
| Starter | 5 | 100,000 | 7 days | Email |
|
|
241
|
+
| Professional | Unlimited | 1,000,000 | 30 days | Priority |
|
|
242
|
+
| Enterprise | Unlimited | Unlimited | 90 days | Dedicated |
|
|
243
|
+
|
|
244
|
+
**Quota Enforcement:**
|
|
245
|
+
- Check usage on every `/api/twins/:id/call` request
|
|
246
|
+
- Return 429 when quota exceeded with upgrade prompt
|
|
247
|
+
- Reset quota on 1st of each month (UTC)
|
|
248
|
+
|
|
249
|
+
**API Endpoints:**
|
|
250
|
+
|
|
251
|
+
| Method | Endpoint | Description | Auth |
|
|
252
|
+
|--------|----------|-------------|------|
|
|
253
|
+
| GET | `/api/usage` | Get current month usage | API Key |
|
|
254
|
+
| GET | `/api/usage/history` | Get usage history | API Key |
|
|
255
|
+
|
|
256
|
+
```typescript
|
|
257
|
+
// GET /api/usage
|
|
258
|
+
Response: {
|
|
259
|
+
tier: "starter",
|
|
260
|
+
period: { start: "2024-01-01", end: "2024-01-31" },
|
|
261
|
+
twins: { used: 3, limit: 5 },
|
|
262
|
+
requests: { used: 45000, limit: 100000 },
|
|
263
|
+
percentUsed: 45
|
|
264
|
+
}
|
|
265
|
+
```
|
|
266
|
+
|
|
267
|
+
#### 2.3 Billing Portal
|
|
268
|
+
|
|
269
|
+
**Description:** Self-service billing management.
|
|
270
|
+
|
|
271
|
+
**User Stories:**
|
|
272
|
+
- As a user, I want to upgrade my plan so I can get more features
|
|
273
|
+
- As a user, I want to see my invoices so I can track spending
|
|
274
|
+
- As a user, I want to update payment method so my subscription continues
|
|
275
|
+
|
|
276
|
+
**API Endpoints:**
|
|
277
|
+
|
|
278
|
+
| Method | Endpoint | Description | Auth |
|
|
279
|
+
|--------|----------|-------------|------|
|
|
280
|
+
| POST | `/api/billing/checkout` | Create Stripe checkout session | Session |
|
|
281
|
+
| POST | `/api/billing/portal` | Create Stripe billing portal session | Session |
|
|
282
|
+
| GET | `/api/billing/invoices` | List invoices | Session |
|
|
283
|
+
|
|
284
|
+
---
|
|
285
|
+
|
|
286
|
+
### Phase 3: Landing Page + Public Demo (Week 3)
|
|
287
|
+
|
|
288
|
+
#### 3.1 Marketing Landing Page
|
|
289
|
+
|
|
290
|
+
**Description:** Public-facing website to convert visitors to signups.
|
|
291
|
+
|
|
292
|
+
**Pages:**
|
|
293
|
+
- `/` - Hero + features + pricing + CTA
|
|
294
|
+
- `/pricing` - Detailed pricing comparison
|
|
295
|
+
- `/docs` - API documentation
|
|
296
|
+
- `/blog` - Content marketing
|
|
297
|
+
- `/login` - Auth flow
|
|
298
|
+
- `/dashboard` - User dashboard (authenticated)
|
|
299
|
+
|
|
300
|
+
**Hero Section Content:**
|
|
301
|
+
```
|
|
302
|
+
MCP Twin Cloud
|
|
303
|
+
Deploy MCP servers in seconds. Zero downtime, infinite scale.
|
|
304
|
+
|
|
305
|
+
[Start Free] [View Pricing]
|
|
306
|
+
|
|
307
|
+
Trusted by developers at: [logos]
|
|
308
|
+
```
|
|
309
|
+
|
|
310
|
+
**Features Section:**
|
|
311
|
+
- One API key, infinite twins
|
|
312
|
+
- Auto-scaling, no ops needed
|
|
313
|
+
- Built-in observability
|
|
314
|
+
- Works with Claude, Cursor, Cline, VS Code, Windsurf
|
|
315
|
+
- Zero-downtime updates
|
|
316
|
+
- 99.9% uptime SLA (Pro+)
|
|
317
|
+
|
|
318
|
+
#### 3.2 Dashboard UI
|
|
319
|
+
|
|
320
|
+
**Description:** Web dashboard for managing twins and viewing usage.
|
|
321
|
+
|
|
322
|
+
**Dashboard Views:**
|
|
323
|
+
1. **Overview** - Usage stats, quick actions, recent logs
|
|
324
|
+
2. **Twins** - List/create/manage twins
|
|
325
|
+
3. **Logs** - Searchable log viewer
|
|
326
|
+
4. **Settings** - API keys, profile, billing
|
|
327
|
+
5. **Billing** - Current plan, usage, upgrade
|
|
328
|
+
|
|
329
|
+
**Dashboard Wireframe:**
|
|
330
|
+
```
|
|
331
|
+
┌─────────────────────────────────────────────────────────────┐
|
|
332
|
+
│ MCP Twin Cloud [Docs] [Settings] [User] │
|
|
333
|
+
├─────────────┬───────────────────────────────────────────────┤
|
|
334
|
+
│ │ │
|
|
335
|
+
│ Overview │ Usage This Month │
|
|
336
|
+
│ Twins │ ████████████░░░░░░░░ 45,000 / 100,000 │
|
|
337
|
+
│ Logs │ │
|
|
338
|
+
│ Settings │ Active Twins (3/5) │
|
|
339
|
+
│ Billing │ ┌─────────┬─────────┬─────────┐ │
|
|
340
|
+
│ │ │ inbox │ phi │ tools │ │
|
|
341
|
+
│ │ │ ● Active│ ● Active│ ○ Idle │ │
|
|
342
|
+
│ │ └─────────┴─────────┴─────────┘ │
|
|
343
|
+
│ │ │
|
|
344
|
+
│ │ Recent Activity │
|
|
345
|
+
│ │ • search_files called (45ms) - 2m ago │
|
|
346
|
+
│ │ • get_message called (120ms) - 5m ago │
|
|
347
|
+
│ │ • send_message called (89ms) - 8m ago │
|
|
348
|
+
│ │ │
|
|
349
|
+
└─────────────┴───────────────────────────────────────────────┘
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
#### 3.3 Demo Video
|
|
353
|
+
|
|
354
|
+
**Description:** 60-second product demo for marketing.
|
|
355
|
+
|
|
356
|
+
**Script:**
|
|
357
|
+
1. (0-10s) "Deploy MCP servers in seconds with MCP Twin Cloud"
|
|
358
|
+
2. (10-25s) Show signup flow → create twin → get API key
|
|
359
|
+
3. (25-40s) Show tool call execution → logs appear
|
|
360
|
+
4. (40-55s) Show usage dashboard → pricing tiers
|
|
361
|
+
5. (55-60s) CTA: "Start free at mcp-twin.cloud"
|
|
362
|
+
|
|
363
|
+
---
|
|
364
|
+
|
|
365
|
+
## Technical Architecture
|
|
366
|
+
|
|
367
|
+
### System Diagram
|
|
368
|
+
|
|
369
|
+
```
|
|
370
|
+
┌─────────────────────────────────────────────────────────────────┐
|
|
371
|
+
│ MCP Twin Cloud │
|
|
372
|
+
│ │
|
|
373
|
+
│ ┌──────────────┐ ┌──────────────┐ ┌──────────────┐ │
|
|
374
|
+
│ │ Vercel │ │ Railway │ │ Stripe │ │
|
|
375
|
+
│ │ (Frontend) │ │ (Backend) │ │ (Billing) │ │
|
|
376
|
+
│ │ │ │ │ │ │ │
|
|
377
|
+
│ │ - Landing │◄──►│ - API │◄──►│ - Payments │ │
|
|
378
|
+
│ │ - Dashboard │ │ - Workers │ │ - Webhooks │ │
|
|
379
|
+
│ │ - Docs │ │ - Twins │ │ │ │
|
|
380
|
+
│ └──────────────┘ └──────┬───────┘ └──────────────┘ │
|
|
381
|
+
│ │ │
|
|
382
|
+
│ ┌──────▼───────┐ │
|
|
383
|
+
│ │ PostgreSQL │ │
|
|
384
|
+
│ │ (Supabase) │ │
|
|
385
|
+
│ │ │ │
|
|
386
|
+
│ │ - users │ │
|
|
387
|
+
│ │ - twins │ │
|
|
388
|
+
│ │ - logs │ │
|
|
389
|
+
│ │ - api_keys │ │
|
|
390
|
+
│ └──────────────┘ │
|
|
391
|
+
│ │
|
|
392
|
+
└─────────────────────────────────────────────────────────────────┘
|
|
393
|
+
|
|
394
|
+
│ │ │
|
|
395
|
+
▼ ▼ ▼
|
|
396
|
+
┌─────────┐ ┌─────────┐ ┌─────────┐
|
|
397
|
+
│ Claude │ │ Cursor │ │ Cline │
|
|
398
|
+
│ Desktop │ │ │ │ │
|
|
399
|
+
└─────────┘ └─────────┘ └─────────┘
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### Tech Stack
|
|
403
|
+
|
|
404
|
+
| Layer | Technology | Rationale |
|
|
405
|
+
|-------|------------|-----------|
|
|
406
|
+
| Frontend | Next.js 14 + Tailwind | Fast, SEO-friendly, Vercel-native |
|
|
407
|
+
| Backend | Node.js + Express | Same language as mcp-twin CLI |
|
|
408
|
+
| Database | PostgreSQL (Supabase) | Free tier, realtime, auth helpers |
|
|
409
|
+
| Payments | Stripe | Industry standard, great DX |
|
|
410
|
+
| Hosting | Vercel + Railway | Free/cheap, auto-scaling |
|
|
411
|
+
| Auth | Custom JWT + API Keys | Simple, no vendor lock-in |
|
|
412
|
+
|
|
413
|
+
### Database Schema
|
|
414
|
+
|
|
415
|
+
```sql
|
|
416
|
+
-- Users table
|
|
417
|
+
CREATE TABLE users (
|
|
418
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
419
|
+
email VARCHAR(255) UNIQUE NOT NULL,
|
|
420
|
+
password_hash VARCHAR(255) NOT NULL,
|
|
421
|
+
tier VARCHAR(20) DEFAULT 'free' CHECK (tier IN ('free', 'starter', 'pro', 'enterprise')),
|
|
422
|
+
stripe_customer_id VARCHAR(255),
|
|
423
|
+
stripe_subscription_id VARCHAR(255),
|
|
424
|
+
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
425
|
+
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
|
426
|
+
);
|
|
427
|
+
|
|
428
|
+
-- API Keys table
|
|
429
|
+
CREATE TABLE api_keys (
|
|
430
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
431
|
+
user_id UUID REFERENCES users(id) ON DELETE CASCADE,
|
|
432
|
+
key_hash VARCHAR(255) NOT NULL,
|
|
433
|
+
key_prefix VARCHAR(20) NOT NULL, -- "mtc_live_abc" for display
|
|
434
|
+
name VARCHAR(100),
|
|
435
|
+
last_used_at TIMESTAMP WITH TIME ZONE,
|
|
436
|
+
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
437
|
+
revoked_at TIMESTAMP WITH TIME ZONE
|
|
438
|
+
);
|
|
439
|
+
|
|
440
|
+
-- Twins table
|
|
441
|
+
CREATE TABLE twins (
|
|
442
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
443
|
+
user_id UUID REFERENCES users(id) ON DELETE CASCADE,
|
|
444
|
+
name VARCHAR(100) NOT NULL,
|
|
445
|
+
config_json JSONB NOT NULL,
|
|
446
|
+
status VARCHAR(20) DEFAULT 'stopped' CHECK (status IN ('stopped', 'starting', 'running', 'error')),
|
|
447
|
+
active_server VARCHAR(1) DEFAULT 'a' CHECK (active_server IN ('a', 'b')),
|
|
448
|
+
port_a INTEGER,
|
|
449
|
+
port_b INTEGER,
|
|
450
|
+
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
|
|
451
|
+
updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
|
452
|
+
);
|
|
453
|
+
|
|
454
|
+
-- Logs table (partitioned by month for performance)
|
|
455
|
+
CREATE TABLE logs (
|
|
456
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
457
|
+
user_id UUID REFERENCES users(id) ON DELETE CASCADE,
|
|
458
|
+
twin_id UUID REFERENCES twins(id) ON DELETE CASCADE,
|
|
459
|
+
tool_name VARCHAR(100) NOT NULL,
|
|
460
|
+
args JSONB,
|
|
461
|
+
result JSONB,
|
|
462
|
+
error TEXT,
|
|
463
|
+
status VARCHAR(20) NOT NULL CHECK (status IN ('success', 'error', 'timeout')),
|
|
464
|
+
duration_ms INTEGER NOT NULL,
|
|
465
|
+
server VARCHAR(1) NOT NULL CHECK (server IN ('a', 'b')),
|
|
466
|
+
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
|
|
467
|
+
);
|
|
468
|
+
|
|
469
|
+
-- Usage tracking (aggregated daily)
|
|
470
|
+
CREATE TABLE usage_daily (
|
|
471
|
+
id UUID PRIMARY KEY DEFAULT gen_random_uuid(),
|
|
472
|
+
user_id UUID REFERENCES users(id) ON DELETE CASCADE,
|
|
473
|
+
date DATE NOT NULL,
|
|
474
|
+
request_count INTEGER DEFAULT 0,
|
|
475
|
+
error_count INTEGER DEFAULT 0,
|
|
476
|
+
total_duration_ms BIGINT DEFAULT 0,
|
|
477
|
+
UNIQUE(user_id, date)
|
|
478
|
+
);
|
|
479
|
+
|
|
480
|
+
-- Indexes
|
|
481
|
+
CREATE INDEX idx_api_keys_hash ON api_keys(key_hash) WHERE revoked_at IS NULL;
|
|
482
|
+
CREATE INDEX idx_twins_user ON twins(user_id);
|
|
483
|
+
CREATE INDEX idx_logs_twin_created ON logs(twin_id, created_at DESC);
|
|
484
|
+
CREATE INDEX idx_logs_user_created ON logs(user_id, created_at DESC);
|
|
485
|
+
CREATE INDEX idx_usage_user_date ON usage_daily(user_id, date DESC);
|
|
486
|
+
```
|
|
487
|
+
|
|
488
|
+
---
|
|
489
|
+
|
|
490
|
+
## API Specification
|
|
491
|
+
|
|
492
|
+
### Authentication
|
|
493
|
+
|
|
494
|
+
All authenticated endpoints require one of:
|
|
495
|
+
- **API Key**: `Authorization: Bearer mtc_live_xxxxx`
|
|
496
|
+
- **Session Token**: `Authorization: Bearer jwt_xxxxx` (for dashboard)
|
|
497
|
+
|
|
498
|
+
### Rate Limits
|
|
499
|
+
|
|
500
|
+
| Tier | Requests/Second | Burst |
|
|
501
|
+
|------|-----------------|-------|
|
|
502
|
+
| Free | 10 | 20 |
|
|
503
|
+
| Starter | 50 | 100 |
|
|
504
|
+
| Pro | 200 | 500 |
|
|
505
|
+
| Enterprise | Custom | Custom |
|
|
506
|
+
|
|
507
|
+
### Error Responses
|
|
508
|
+
|
|
509
|
+
```typescript
|
|
510
|
+
interface ErrorResponse {
|
|
511
|
+
error: {
|
|
512
|
+
code: string; // "QUOTA_EXCEEDED", "UNAUTHORIZED", etc.
|
|
513
|
+
message: string; // Human-readable message
|
|
514
|
+
details?: object; // Additional context
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
```
|
|
518
|
+
|
|
519
|
+
**Error Codes:**
|
|
520
|
+
|
|
521
|
+
| Code | HTTP Status | Description |
|
|
522
|
+
|------|-------------|-------------|
|
|
523
|
+
| UNAUTHORIZED | 401 | Invalid or missing API key |
|
|
524
|
+
| FORBIDDEN | 403 | Valid key but no access to resource |
|
|
525
|
+
| NOT_FOUND | 404 | Resource doesn't exist |
|
|
526
|
+
| QUOTA_EXCEEDED | 429 | Monthly quota exceeded |
|
|
527
|
+
| RATE_LIMITED | 429 | Too many requests per second |
|
|
528
|
+
| VALIDATION_ERROR | 400 | Invalid request body |
|
|
529
|
+
| INTERNAL_ERROR | 500 | Server error |
|
|
530
|
+
|
|
531
|
+
---
|
|
532
|
+
|
|
533
|
+
## Implementation Timeline
|
|
534
|
+
|
|
535
|
+
### Week 1: Core Infrastructure
|
|
536
|
+
|
|
537
|
+
| Day | Tasks | Owner |
|
|
538
|
+
|-----|-------|-------|
|
|
539
|
+
| 1 | Set up repo, database, basic Express server | Dev |
|
|
540
|
+
| 2 | Implement auth endpoints (signup, login, API keys) | Dev |
|
|
541
|
+
| 3 | Implement twin CRUD endpoints | Dev |
|
|
542
|
+
| 4 | Implement tool call proxy + logging | Dev |
|
|
543
|
+
| 5 | Deploy to Railway, test E2E | Dev |
|
|
544
|
+
|
|
545
|
+
**Deliverables:**
|
|
546
|
+
- [ ] Working API at `api.mcp-twin.cloud`
|
|
547
|
+
- [ ] Database provisioned on Supabase
|
|
548
|
+
- [ ] Auth flow functional
|
|
549
|
+
- [ ] One twin can be created and called
|
|
550
|
+
|
|
551
|
+
### Week 2: Billing + Quotas
|
|
552
|
+
|
|
553
|
+
| Day | Tasks | Owner |
|
|
554
|
+
|-----|-------|-------|
|
|
555
|
+
| 1 | Stripe account setup, products created | Dev |
|
|
556
|
+
| 2 | Implement checkout + webhook handlers | Dev |
|
|
557
|
+
| 3 | Implement usage tracking + quota enforcement | Dev |
|
|
558
|
+
| 4 | Build billing portal page | Dev |
|
|
559
|
+
| 5 | Test full billing flow end-to-end | Dev |
|
|
560
|
+
|
|
561
|
+
**Deliverables:**
|
|
562
|
+
- [ ] Stripe integration live
|
|
563
|
+
- [ ] Users can upgrade/downgrade
|
|
564
|
+
- [ ] Quotas enforced correctly
|
|
565
|
+
- [ ] Billing portal functional
|
|
566
|
+
|
|
567
|
+
### Week 3: Frontend + Launch
|
|
568
|
+
|
|
569
|
+
| Day | Tasks | Owner |
|
|
570
|
+
|-----|-------|-------|
|
|
571
|
+
| 1 | Build landing page (Next.js) | Dev |
|
|
572
|
+
| 2 | Build dashboard UI | Dev |
|
|
573
|
+
| 3 | Build docs site | Dev |
|
|
574
|
+
| 4 | Record demo video | Dev |
|
|
575
|
+
| 5 | Launch: Product Hunt, r/mcp, HN | Dev |
|
|
576
|
+
|
|
577
|
+
**Deliverables:**
|
|
578
|
+
- [ ] Landing page live at `mcp-twin.cloud`
|
|
579
|
+
- [ ] Dashboard functional
|
|
580
|
+
- [ ] Demo video published
|
|
581
|
+
- [ ] Launch posts submitted
|
|
582
|
+
|
|
583
|
+
---
|
|
584
|
+
|
|
585
|
+
## Business Model
|
|
586
|
+
|
|
587
|
+
### Pricing Strategy
|
|
588
|
+
|
|
589
|
+
**Positioning:** Premium pricing for reliability + zero-downtime value.
|
|
590
|
+
|
|
591
|
+
| Tier | Price | Target User | Key Value |
|
|
592
|
+
|------|-------|-------------|-----------|
|
|
593
|
+
| Free | $0 | Individual devs trying it out | Get hooked |
|
|
594
|
+
| Starter | $29/mo | Serious hobbyists, small projects | Remove limits |
|
|
595
|
+
| Pro | $149/mo | Agencies, startups | Unlimited + priority |
|
|
596
|
+
| Enterprise | Custom | Large orgs | SLA, SSO, support |
|
|
597
|
+
|
|
598
|
+
### Unit Economics
|
|
599
|
+
|
|
600
|
+
| Metric | Value | Notes |
|
|
601
|
+
|--------|-------|-------|
|
|
602
|
+
| Hosting cost per user | ~$2/mo | Railway compute + Supabase |
|
|
603
|
+
| Stripe fees | 2.9% + $0.30 | Per transaction |
|
|
604
|
+
| Gross margin (Starter) | 90% | $29 - $2.90 - $2 = $24.10 |
|
|
605
|
+
| Gross margin (Pro) | 95% | $149 - $4.62 - $2 = $142.38 |
|
|
606
|
+
| Target CAC | <$50 | Organic + content marketing |
|
|
607
|
+
| Target LTV | $600 | 12 months avg retention |
|
|
608
|
+
| LTV:CAC | 12:1 | Healthy SaaS ratio |
|
|
609
|
+
|
|
610
|
+
### Revenue Projections
|
|
611
|
+
|
|
612
|
+
| Month | Free Users | Paid Users | MRR |
|
|
613
|
+
|-------|------------|------------|-----|
|
|
614
|
+
| 1 | 150 | 5 | $445 |
|
|
615
|
+
| 2 | 300 | 15 | $1,335 |
|
|
616
|
+
| 3 | 500 | 35 | $3,115 |
|
|
617
|
+
| 6 | 1,500 | 120 | $10,680 |
|
|
618
|
+
| 12 | 5,000 | 500 | $44,500 |
|
|
619
|
+
|
|
620
|
+
---
|
|
621
|
+
|
|
622
|
+
## Risks & Mitigations
|
|
623
|
+
|
|
624
|
+
| Risk | Likelihood | Impact | Mitigation |
|
|
625
|
+
|------|------------|--------|------------|
|
|
626
|
+
| Low initial adoption | Medium | High | Strong content marketing, r/mcp presence |
|
|
627
|
+
| Technical issues at scale | Medium | High | Start with conservative limits, monitor closely |
|
|
628
|
+
| Competitor enters market | Low | Medium | Move fast, build brand, focus on DX |
|
|
629
|
+
| Stripe account issues | Low | High | Keep reserves, document compliance |
|
|
630
|
+
| MCP protocol changes | Medium | Medium | Stay close to Anthropic, adapt quickly |
|
|
631
|
+
|
|
632
|
+
---
|
|
633
|
+
|
|
634
|
+
## Success Criteria
|
|
635
|
+
|
|
636
|
+
### MVP Success (Week 3)
|
|
637
|
+
- [ ] 100+ signups
|
|
638
|
+
- [ ] 5+ paid users
|
|
639
|
+
- [ ] $200+ MRR
|
|
640
|
+
- [ ] 99% uptime
|
|
641
|
+
- [ ] <500ms avg latency
|
|
642
|
+
|
|
643
|
+
### Month 3 Success
|
|
644
|
+
- [ ] 500+ signups
|
|
645
|
+
- [ ] 35+ paid users
|
|
646
|
+
- [ ] $3,000+ MRR
|
|
647
|
+
- [ ] 3+ testimonials
|
|
648
|
+
- [ ] Investor deck ready
|
|
649
|
+
|
|
650
|
+
---
|
|
651
|
+
|
|
652
|
+
## Appendix
|
|
653
|
+
|
|
654
|
+
### Competitor Analysis
|
|
655
|
+
|
|
656
|
+
| Competitor | Offering | Pricing | Gap |
|
|
657
|
+
|------------|----------|---------|-----|
|
|
658
|
+
| MCPTotal | MCP marketplace | Unknown | No zero-downtime |
|
|
659
|
+
| Klavis AI | Managed MCP hosting | Unknown | No multi-client support |
|
|
660
|
+
| Self-hosted | DIY | Free | No observability, manual |
|
|
661
|
+
|
|
662
|
+
### Investor FAQ
|
|
663
|
+
|
|
664
|
+
**Q: How do you differentiate from renting MCP servers?**
|
|
665
|
+
A: We're the orchestration layer solving multi-tenant governance, observability, and vendor lock-in. Platform, not tool.
|
|
666
|
+
|
|
667
|
+
**Q: What's your TAM?**
|
|
668
|
+
A: Enterprise AI agent deployment. $50B market by 2030 (Gartner). Targeting teams with 5+ MCP servers.
|
|
669
|
+
|
|
670
|
+
**Q: How do you acquire customers?**
|
|
671
|
+
A: Developer-first. Partner with MCP creators, post on r/mcp, HN, Dev.to. Target agencies first.
|
|
672
|
+
|
|
673
|
+
**Q: What's your moat?**
|
|
674
|
+
A: First-mover in meta-layer architecture. Network effects from MCP server ecosystem.
|
|
675
|
+
|
|
676
|
+
---
|
|
677
|
+
|
|
678
|
+
## Document History
|
|
679
|
+
|
|
680
|
+
| Version | Date | Author | Changes |
|
|
681
|
+
|---------|------|--------|---------|
|
|
682
|
+
| 1.0 | 2024-12-31 | Prax Labs | Initial PRD |
|