Sync vault notes: April-November 2026 sessions, projects, and architecture
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
fe4fe656be
commit
994c7ae577
379 files changed
+55216
-107
No files matched your search
@@ -0,0 +1,119 @@
|
||||
---
|
||||
status: IMPLEMENTED
|
||||
source: gstack /plan-ceo-review
|
||||
generated: 2026-05-13
|
||||
implemented: 2026-05-13
|
||||
---
|
||||
# CEO Plan: SquareMCP v2 — Complete Foundation + MCP-Native Platform
|
||||
|
||||
Generated by /plan-ceo-review on 2026-05-13
|
||||
Branch: main | Mode: SELECTIVE EXPANSION
|
||||
Repo: garfield/hermes-mcp
|
||||
|
||||
## Context
|
||||
|
||||
hermes-mcp is the backend for SquareMCP — a unified MCP gateway for 9 social/messaging platforms (WhatsApp, LinkedIn, Telegram, Discord, Instagram, Twitter, TikTok, Facebook, Obsidian). Multi-tenancy was added 2026-05-08. SaaS web app was shipped 2026-05-13. YC application is being prepared.
|
||||
|
||||
**All 10 scope items were implemented and deployed 2026-05-13. Commit: 61dab40.**
|
||||
|
||||
## What Was Built (v2)
|
||||
|
||||
### Step 1 — MCP session threading + plan limit enforcement
|
||||
- `createMcpServer(customer?)` pattern: customer resolved from `requireAuth` middleware, threaded through `sessionCustomers` Map into MCP tool calls
|
||||
- `handleToolCall` gates on `checkLimit(customer.id, customer.plan)` at entry — returns `isError: true` when over limit
|
||||
- Usage platform attribution fixed: known-prefix matching replaces broken `name.split('_')[0]`
|
||||
- `stripAccountParam(tool)` deep-clones Tool objects, removes `account` enum for multi-tenant sessions
|
||||
|
||||
### Step 2 — Invoice fixes + cron
|
||||
- `generateMonthlyInvoice`: billing period uses previous month (not current month bug fixed)
|
||||
- Idempotency: UNIQUE constraint on `(customer_id, period_start)` + duplicate cleanup migration
|
||||
- Invoice number: `crypto.randomBytes(4).toString('hex')` (not `Math.random()`)
|
||||
- `emailInvoice()` sends HTML invoice via system SMTP
|
||||
- Cron `0 9 1 * *` with compare-delete Redis lock (`SET NX` + Lua DEL)
|
||||
|
||||
### Step 3 — Email multi-tenancy + platform coverage
|
||||
- `src/imap.ts` / `src/smtp.ts` accept `customer?` param, use `EmailCredentials.smtpHost/smtpPort`
|
||||
- TikTok, Facebook, Snapchat added to growth/enterprise plan tiers
|
||||
|
||||
### Step 4 — Analytics dashboard
|
||||
- `GET /api/usage/daily` → `{ date, count }[]` for Chart.js
|
||||
- Platform breakdown bars + daily sparkline in SaaS app
|
||||
|
||||
### Step 5 — Platform health checks
|
||||
- `src/multitenancy/platform-health.ts`: all 11 platforms checked in parallel
|
||||
- Redis cache key `health:{customerId}:{platform}`, 10-min TTL
|
||||
- Status values: `healthy | expired | disconnected | unknown`
|
||||
- Token refresh on near-expiry (60s buffer) via dynamic import to avoid circular dep
|
||||
|
||||
### Step 6 — Dynamic tool schema filtering
|
||||
- `stripAccountParam` exported from `src/tools.ts`
|
||||
- Multi-tenant sessions get tools array without internal `account` param
|
||||
|
||||
### Steps 7–8 — OAuth hardening + DCR browser flow
|
||||
- Atomic auth code consumption: `UPDATE SET used=TRUE WHERE used=FALSE` + `affectedRows` check
|
||||
- `customer_id` threaded through auth codes → tokens
|
||||
- `getTokenCustomer()` in `src/oauth.ts`
|
||||
- `isValidRedirectUri()` with `http://localhost:*` wildcard support
|
||||
- `ensureOAuthAppRegistered()` on startup (ON DUPLICATE KEY UPDATE)
|
||||
- `GET /oauth/connect-mcp` → server-side redirect keeps client_id off frontend
|
||||
- Callback page renders MCP client config snippets
|
||||
|
||||
### Step 9 — Inbound webhooks
|
||||
- `src/webhooks/delivery.ts`: HMAC-SHA256 (`X-SquareMCP-Signature: sha256=...`)
|
||||
- 3× exponential retry: 1s → 4s → 16s
|
||||
- Redis DLQ `webhook:dlq:{customerId}` with 7-day TTL
|
||||
- SSRF protection: blocks private IPs, localhost, .local, non-http schemes
|
||||
- `GET/POST/DELETE /api/webhooks/config`, `GET /api/admin/webhooks/dlq/:customerId`
|
||||
|
||||
### Step 10 — Developer docs
|
||||
- Static HTML + GitHub Pages in `/docs`
|
||||
- Pages: index, getting-started, platforms, agent-tutorial
|
||||
- Full Node.js MCP agent code example with Anthropic SDK
|
||||
|
||||
## Vision
|
||||
|
||||
**10x version:** An AI agent is set up once, automatically discovers all the user's social platforms via MCP tool listing, and can publish to all 9 platforms without writing a single API client. Setup is a browser OAuth flow. Monthly invoices arrive automatically. Revenue scales to 100+ customers with zero marginal billing work.
|
||||
|
||||
**Delight opportunities shipped:**
|
||||
1. Green/yellow/amber health indicators per platform in dashboard
|
||||
2. Platform-by-platform usage chart
|
||||
3. Browser OAuth for MCP clients — no API key config files
|
||||
4. Invoice in email inbox
|
||||
5. Inbound message routing — reactive AI agents
|
||||
|
||||
## Landscape
|
||||
|
||||
All competitors (Ayrshare, Socialync, Zernio, Bundle.social) are REST-first adding MCP as afterthought. Cloudflare, Zuplo, Apigee are doing enterprise MCP governance but not social. **SquareMCP is uniquely positioned as MCP-native from day one — this is the real moat.**
|
||||
|
||||
## NOT in Scope (deferred)
|
||||
- Stripe/payment processing (invoicing-first until revenue validates)
|
||||
- Team workspaces / multi-user accounts
|
||||
- Connector marketplace / SDK for third-party connectors
|
||||
- Mobile app
|
||||
- Token refresh flows for all platforms (LinkedIn, Twitter, TikTok, Instagram done; others deferred to v1.2)
|
||||
- Customer-facing webhook DLQ drain (deferred to v2.1)
|
||||
- Session hijack protection (store `{ transport, customerId }`, return 403 on mismatch — v2.1)
|
||||
|
||||
## Dream State Delta
|
||||
```
|
||||
BEFORE v2 (2026-05-13) AFTER v2 12-MONTH IDEAL
|
||||
MCP server: single-tenant → MCP server: multi-tenant → 50+ paying customers
|
||||
SaaS app: no metering + metering enforced Stripe or equivalent
|
||||
Invoices: manual + auto monthly invoices Team workspaces
|
||||
No analytics + analytics dashboard Analytics product
|
||||
No platform health + health checks + refresh Connector marketplace
|
||||
API key setup only + OAuth MCP connections SDK for devs
|
||||
Publish-only + inbound webhooks Reactive agent platform
|
||||
No docs + developer docs site Category-defining docs
|
||||
```
|
||||
|
||||
## Review Verdicts
|
||||
|
||||
| Review | Status |
|
||||
|--------|--------|
|
||||
| CEO Review (/plan-ceo-review) | CLEARED |
|
||||
| Outside Voice — Codex (CEO) | 18 findings → all resolved |
|
||||
| Eng Review (/plan-eng-review) | CLEARED |
|
||||
| Outside Voice — Codex (Eng) | 20 findings → all resolved |
|
||||
|
||||
**0 unresolved issues. Implemented and deployed 2026-05-13.**
|
||||
Reference in new issue
Block a user