@revealui/mcp 0.0.0-canary-20260401205250

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 (88) hide show
  1. package/LICENSE +22 -0
  2. package/LICENSE.commercial +111 -0
  3. package/README.md +263 -0
  4. package/dist/adapters/db.d.ts +46 -0
  5. package/dist/adapters/db.d.ts.map +1 -0
  6. package/dist/adapters/db.js +127 -0
  7. package/dist/adapters/db.js.map +1 -0
  8. package/dist/auth.d.ts +42 -0
  9. package/dist/auth.d.ts.map +1 -0
  10. package/dist/auth.js +73 -0
  11. package/dist/auth.js.map +1 -0
  12. package/dist/config/index.d.ts +11 -0
  13. package/dist/config/index.d.ts.map +1 -0
  14. package/dist/config/index.js +18 -0
  15. package/dist/config/index.js.map +1 -0
  16. package/dist/contracts.d.ts +167 -0
  17. package/dist/contracts.d.ts.map +1 -0
  18. package/dist/contracts.js +197 -0
  19. package/dist/contracts.js.map +1 -0
  20. package/dist/hypervisor.d.ts +195 -0
  21. package/dist/hypervisor.d.ts.map +1 -0
  22. package/dist/hypervisor.js +642 -0
  23. package/dist/hypervisor.js.map +1 -0
  24. package/dist/index.d.ts +40 -0
  25. package/dist/index.d.ts.map +1 -0
  26. package/dist/index.js +62 -0
  27. package/dist/index.js.map +1 -0
  28. package/dist/pipeline.d.ts +62 -0
  29. package/dist/pipeline.d.ts.map +1 -0
  30. package/dist/pipeline.js +230 -0
  31. package/dist/pipeline.js.map +1 -0
  32. package/dist/rate-limiter.d.ts +53 -0
  33. package/dist/rate-limiter.d.ts.map +1 -0
  34. package/dist/rate-limiter.js +96 -0
  35. package/dist/rate-limiter.js.map +1 -0
  36. package/dist/servers/_launcher-utils.d.ts +28 -0
  37. package/dist/servers/_launcher-utils.d.ts.map +1 -0
  38. package/dist/servers/_launcher-utils.js +45 -0
  39. package/dist/servers/_launcher-utils.js.map +1 -0
  40. package/dist/servers/adapter.d.ts +225 -0
  41. package/dist/servers/adapter.d.ts.map +1 -0
  42. package/dist/servers/adapter.js +534 -0
  43. package/dist/servers/adapter.js.map +1 -0
  44. package/dist/servers/neon.d.ts +15 -0
  45. package/dist/servers/neon.d.ts.map +1 -0
  46. package/dist/servers/neon.js +89 -0
  47. package/dist/servers/neon.js.map +1 -0
  48. package/dist/servers/next-devtools.d.ts +15 -0
  49. package/dist/servers/next-devtools.d.ts.map +1 -0
  50. package/dist/servers/next-devtools.js +220 -0
  51. package/dist/servers/next-devtools.js.map +1 -0
  52. package/dist/servers/playwright.d.ts +15 -0
  53. package/dist/servers/playwright.d.ts.map +1 -0
  54. package/dist/servers/playwright.js +73 -0
  55. package/dist/servers/playwright.js.map +1 -0
  56. package/dist/servers/revealui-content.d.ts +25 -0
  57. package/dist/servers/revealui-content.d.ts.map +1 -0
  58. package/dist/servers/revealui-content.js +241 -0
  59. package/dist/servers/revealui-content.js.map +1 -0
  60. package/dist/servers/revealui-email.d.ts +22 -0
  61. package/dist/servers/revealui-email.d.ts.map +1 -0
  62. package/dist/servers/revealui-email.js +220 -0
  63. package/dist/servers/revealui-email.js.map +1 -0
  64. package/dist/servers/revealui-stripe.d.ts +23 -0
  65. package/dist/servers/revealui-stripe.d.ts.map +1 -0
  66. package/dist/servers/revealui-stripe.js +246 -0
  67. package/dist/servers/revealui-stripe.js.map +1 -0
  68. package/dist/servers/stripe.d.ts +15 -0
  69. package/dist/servers/stripe.d.ts.map +1 -0
  70. package/dist/servers/stripe.js +85 -0
  71. package/dist/servers/stripe.js.map +1 -0
  72. package/dist/servers/supabase.d.ts +15 -0
  73. package/dist/servers/supabase.d.ts.map +1 -0
  74. package/dist/servers/supabase.js +143 -0
  75. package/dist/servers/supabase.js.map +1 -0
  76. package/dist/servers/vercel.d.ts +15 -0
  77. package/dist/servers/vercel.d.ts.map +1 -0
  78. package/dist/servers/vercel.js +86 -0
  79. package/dist/servers/vercel.js.map +1 -0
  80. package/dist/stores/postgres-idempotency.d.ts +32 -0
  81. package/dist/stores/postgres-idempotency.d.ts.map +1 -0
  82. package/dist/stores/postgres-idempotency.js +63 -0
  83. package/dist/stores/postgres-idempotency.js.map +1 -0
  84. package/dist/telemetry.d.ts +75 -0
  85. package/dist/telemetry.d.ts.map +1 -0
  86. package/dist/telemetry.js +110 -0
  87. package/dist/telemetry.js.map +1 -0
  88. package/package.json +95 -0
package/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025-2026 RevealUI Studio
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
@@ -0,0 +1,111 @@
1
+ RevealUI Commercial License
2
+ Version 1.0, February 2026
3
+
4
+ Copyright (c) 2025-2026 RevealUI Studio (founder@revealui.com)
5
+
6
+ TERMS AND CONDITIONS
7
+
8
+ 1. DEFINITIONS
9
+
10
+ "Software" means the RevealUI source code, documentation, and associated
11
+ files contained in directories and packages designated as commercial,
12
+ including but not limited to: packages/ai, packages/harnesses, and any
13
+ directory named "ee" within the repository.
14
+
15
+ "License Key" means a valid RevealUI license key obtained through an active
16
+ paid subscription at https://revealui.com.
17
+
18
+ "Licensee" means the individual or organization that holds a valid License
19
+ Key through an active subscription.
20
+
21
+ "Production Use" means any use of the Software beyond local development and
22
+ evaluation, including but not limited to: deploying the Software to serve
23
+ end users, integrating the Software into a product or service, or using the
24
+ Software in a revenue-generating capacity.
25
+
26
+ 2. GRANT OF RIGHTS
27
+
28
+ Subject to the terms of this License and a valid License Key, the Licensee
29
+ is granted a non-exclusive, non-transferable, revocable license to:
30
+
31
+ (a) Use the Software for internal development and Production Use.
32
+ (b) Modify the Software for internal use.
33
+ (c) Deploy the Software on infrastructure controlled by the Licensee.
34
+
35
+ Enterprise License holders are additionally granted the right to:
36
+
37
+ (d) Deploy the Software in a self-hosted environment.
38
+ (e) Remove or replace RevealUI branding (white-label).
39
+ (f) Use the Software for multiple tenants within the Licensee's
40
+ organization or customer base.
41
+
42
+ 3. RESTRICTIONS
43
+
44
+ The Licensee SHALL NOT:
45
+
46
+ (a) Provide the Software, or any portion of it, to third parties as a
47
+ hosted or managed service that competes with RevealUI.
48
+ (b) Redistribute, sublicense, sell, or otherwise transfer the Software
49
+ or any portion of it to third parties.
50
+ (c) Remove, alter, or circumvent the license key verification
51
+ functionality of the Software.
52
+ (d) Use the Software in Production without a valid License Key.
53
+ (e) Share, publish, or make the License Key available to unauthorized
54
+ parties.
55
+
56
+ 4. EVALUATION
57
+
58
+ The Software may be used for evaluation and local development purposes
59
+ without a License Key. Evaluation use does not grant any rights to
60
+ Production Use.
61
+
62
+ 5. SUBSCRIPTION AND PAYMENT
63
+
64
+ This License is valid only during the term of an active paid subscription.
65
+ Upon cancellation or expiration of the subscription:
66
+
67
+ (a) The License terminates automatically.
68
+ (b) A grace period of fourteen (14) days is provided for the Licensee
69
+ to transition away from Production Use.
70
+ (c) After the grace period, the Licensee must cease all Production Use
71
+ of the Software.
72
+
73
+ 6. INTELLECTUAL PROPERTY
74
+
75
+ The Software is and remains the intellectual property of RevealUI Studio.
76
+ This License does not grant any ownership rights. Contributions to
77
+ commercial portions of the Software require a Contributor License Agreement.
78
+
79
+ 7. OPEN SOURCE COMPONENTS
80
+
81
+ This License applies only to files and directories designated as commercial.
82
+ Files under the MIT License (as indicated in the root LICENSE file) are not
83
+ subject to this commercial license and may be used freely under MIT terms.
84
+
85
+ 8. DISCLAIMER OF WARRANTY
86
+
87
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
88
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
89
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
90
+
91
+ 9. LIMITATION OF LIABILITY
92
+
93
+ IN NO EVENT SHALL REVEALUI STUDIO BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
94
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
95
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
96
+ DEALINGS IN THE SOFTWARE, EXCEEDING THE AMOUNT PAID BY THE LICENSEE IN
97
+ THE TWELVE (12) MONTHS PRECEDING THE CLAIM.
98
+
99
+ 10. GOVERNING LAW
100
+
101
+ This License shall be governed by the laws of the State of California,
102
+ United States of America, without regard to its conflict of law provisions.
103
+
104
+ 11. ENTIRE AGREEMENT
105
+
106
+ This License constitutes the entire agreement between the parties with
107
+ respect to the commercial portions of the Software and supersedes all
108
+ prior agreements, understandings, and communications.
109
+
110
+ For licensing inquiries: founder@revealui.com
111
+ For pricing and subscriptions: https://revealui.com/pricing
package/README.md ADDED
@@ -0,0 +1,263 @@
1
+ # @revealui/mcp
2
+
3
+ > **Commercial package** — requires a [RevealUI Pro license](https://revealui.com/pro). Free to install and evaluate; a license key is required for production use.
4
+
5
+
6
+ **Model Context Protocol (MCP) - Complete Integration Package**
7
+
8
+ Centralized MCP server infrastructure, configuration, and documentation for RevealUI.
9
+
10
+ ## Overview
11
+
12
+ This package contains everything MCP-related:
13
+
14
+ - **7 MCP Servers** - Code validator, Vercel, Stripe, Neon, Supabase, Playwright, Next.js DevTools
15
+ - **Configuration Templates** - For Claude Code / Claude Desktop
16
+ - **Utilities** - Config management, database adapters
17
+ - **Documentation** - Complete guides and per-server docs
18
+ - **Database Migrations** - MCP-related schema
19
+
20
+ > **Pro Package** — `@revealui/mcp` is available to RevealUI Pro subscribers via GitHub Packages.
21
+ > Install: `pnpm add @revealui/mcp --registry https://npm.pkg.github.com`
22
+
23
+ ## Quick Start
24
+
25
+ ### 1. Install Dependencies
26
+
27
+ ```bash
28
+ # In the monorepo:
29
+ pnpm install
30
+
31
+ # As an external Pro subscriber:
32
+ pnpm add @revealui/mcp --registry https://npm.pkg.github.com
33
+ ```
34
+
35
+ ### 2. Configure MCP Client
36
+
37
+ ```bash
38
+ # Use template for your IDE
39
+ cp packages/mcp/configs/claude-template.json ~/.claude/config.json
40
+
41
+ # Replace <REPO_PATH> with actual path
42
+ sed -i "s|<REPO_PATH>|$(pwd)|g" ~/.claude/config.json
43
+ ```
44
+
45
+ ### 3. Test Server
46
+
47
+ ```bash
48
+ # Test code validator
49
+ tsx packages/mcp/src/servers/code-validator.ts
50
+ # Should start (Ctrl+C to exit)
51
+ ```
52
+
53
+ ## Structure
54
+
55
+ ```
56
+ packages/mcp/
57
+ ├── src/
58
+ │ ├── servers/ # 7 MCP server implementations
59
+ │ │ ├── code-validator.ts ← AI code standards enforcer
60
+ │ │ ├── vercel.ts
61
+ │ │ ├── stripe.ts
62
+ │ │ ├── neon.ts
63
+ │ │ ├── supabase.ts
64
+ │ │ ├── playwright.ts
65
+ │ │ └── next-devtools.ts
66
+ │ ├── config/ # Configuration utilities
67
+ │ │ ├── index.ts
68
+ │ │ ├── config.json
69
+ │ │ └── README.md
70
+ │ └── adapters/ # Database adapters
71
+ │ └── db.ts
72
+ ├── configs/ # Template configurations
73
+ │ ├── claude-template.json
74
+ │ └── README.md
75
+ ├── docs/ # Complete documentation
76
+ │ ├── INDEX.md ← Start here
77
+ │ ├── README.md # Main MCP guide
78
+ │ ├── SETUP.md # Setup instructions
79
+ │ └── servers/ # Per-server documentation
80
+ │ └── code-validator.md
81
+ ├── migrations/ # Database migrations
82
+ │ ├── 0001_add_crdt_columns.sql
83
+ │ └── ...
84
+ └── package.json
85
+ ```
86
+
87
+ ## Available MCP Servers
88
+
89
+ ### 1. Code Validator ⭐
90
+ **Status:** ✅ Active and configured
91
+
92
+ Prevents AI-generated technical debt by validating code before it's written.
93
+
94
+ - **Rules:** console.log, any types, TODO refs, debugger, skip tests
95
+ - **Integration:** Pre-commit hook + MCP server
96
+ - **Docs:** [docs/servers/code-validator.md](./docs/servers/code-validator.md)
97
+
98
+ ```bash
99
+ tsx packages/mcp/src/servers/code-validator.ts
100
+ ```
101
+
102
+ ### 2. Vercel
103
+ **Status:** Available (requires API key)
104
+
105
+ Deploy and manage Vercel projects.
106
+
107
+ ```bash
108
+ pnpm mcp:vercel
109
+ ```
110
+
111
+ ### 3. Stripe
112
+ **Status:** Available (requires API key)
113
+
114
+ Payment processing and billing operations.
115
+
116
+ ```bash
117
+ pnpm mcp:stripe
118
+ ```
119
+
120
+ ### 4. Neon
121
+ **Status:** Available (requires API key)
122
+
123
+ Database operations and SQL queries.
124
+
125
+ ```bash
126
+ pnpm mcp:neon
127
+ ```
128
+
129
+ ### 5. Supabase
130
+ **Status:** Available (requires API key)
131
+
132
+ Supabase project management and CRUD operations.
133
+
134
+ ```bash
135
+ pnpm mcp:supabase
136
+ ```
137
+
138
+ ### 6. Playwright
139
+ **Status:** Available
140
+
141
+ Browser automation and web scraping.
142
+
143
+ ```bash
144
+ pnpm mcp:playwright
145
+ ```
146
+
147
+ ### 7. Next.js DevTools
148
+ **Status:** Available
149
+
150
+ Next.js 16+ runtime diagnostics and automation.
151
+
152
+ ```bash
153
+ pnpm mcp:next-devtools
154
+ ```
155
+
156
+ ## Configuration
157
+
158
+ All configuration templates are in `configs/`:
159
+
160
+ - **`claude-template.json`** - Claude Code / Claude Desktop
161
+
162
+ See [configs/README.md](./configs/README.md) for details.
163
+
164
+ ## Environment Variables
165
+
166
+ ```env
167
+ # Code Validator (no env vars needed)
168
+
169
+ # Vercel MCP
170
+ VERCEL_API_KEY=vercel_...
171
+
172
+ # Stripe MCP
173
+ STRIPE_SECRET_KEY=sk_test_...
174
+
175
+ # Neon MCP
176
+ NEON_API_KEY=neon_...
177
+
178
+ # Supabase MCP
179
+ SUPABASE_URL=https://....supabase.co
180
+ SUPABASE_ANON_KEY=eyJ...
181
+ SUPABASE_SERVICE_ROLE_KEY=...
182
+ ```
183
+
184
+ ## Documentation
185
+
186
+ 📚 **[Complete Documentation Index](./docs/INDEX.md)**
187
+
188
+ - **[Main Guide](./docs/README.md)** - MCP overview
189
+ - **[Setup Guide](./docs/SETUP.md)** - Configuration steps
190
+ - **[Code Validator](./docs/servers/code-validator.md)** - Validator guide
191
+
192
+ ## Development
193
+
194
+ ```bash
195
+ # Build package
196
+ pnpm build
197
+
198
+ # Run tests
199
+ pnpm test
200
+
201
+ # Type check
202
+ pnpm typecheck
203
+
204
+ # Lint
205
+ pnpm lint
206
+ ```
207
+
208
+ ## Package Scripts (Root)
209
+
210
+ ```bash
211
+ # Start individual MCP servers
212
+ pnpm mcp:vercel
213
+ pnpm mcp:stripe
214
+ pnpm mcp:neon
215
+ pnpm mcp:supabase
216
+ pnpm mcp:playwright
217
+ pnpm mcp:next-devtools
218
+
219
+ # Setup MCP configuration
220
+ pnpm setup:mcp
221
+ ```
222
+
223
+ ## Exports
224
+
225
+ ```typescript
226
+ // Config utilities
227
+ import { getMCPConfig } from '@revealui/mcp/config'
228
+ ```
229
+
230
+ ## Migration from Old Structure
231
+
232
+ This package consolidates MCP code from multiple locations:
233
+
234
+ **Before:**
235
+ - `scripts/mcp/` → Now `src/servers/`
236
+ - `packages/config/src/mcp/` → Now `src/config/`
237
+ - Multiple config files → Now `configs/` templates
238
+ - Scattered docs → Now `docs/`
239
+
240
+ **After:**
241
+ - Everything in `packages/mcp/` ✅
242
+
243
+ ## Related Documentation
244
+
245
+ - [Root MCP Guide](../../docs/MCP.md)
246
+ - [Automation Guide](../../docs/AUTOMATION.md) - AI agent integration
247
+ - [Project Overview](../../docs/OVERVIEW.md) - Framework overview
248
+
249
+ ## References
250
+
251
+ - [Model Context Protocol Specification](https://modelcontextprotocol.io/)
252
+ - [Anthropic MCP Servers](https://github.com/anthropics/mcp-servers)
253
+ - [MCP SDK Documentation](https://github.com/modelcontextprotocol/sdk)
254
+
255
+ ## License
256
+
257
+ Commercial — see [LICENSE.commercial](../../LICENSE.commercial)
258
+
259
+ ---
260
+
261
+ **Status:** ✅ Consolidated and Active
262
+ **Servers:** 7 available (1 active, 6 optional)
263
+ **Last Updated:** 2026-03-04
@@ -0,0 +1,46 @@
1
+ /**
2
+ * DB adapter for MCP.
3
+ * - `connectPglite()` initializes ElectricSQL/pglite client with CRDT metadata.
4
+ * - `connectPostgres()` creates a standard Postgres client with Electric metadata.
5
+ * - `createMcpDbClient()` factory that selects adapter based on config.
6
+ *
7
+ * Uses @revealui/contracts as the single source of truth for CRDT operation types.
8
+ */
9
+ import type { CrdtOperationsInsert, CrdtOperationsRow } from '@revealui/contracts';
10
+ export interface QueryResult<T = Record<string, unknown>> {
11
+ rows: T[];
12
+ affectedRows?: number;
13
+ }
14
+ export type McpDbClient = {
15
+ query: <T = Record<string, unknown>>(sql: string, params?: unknown[]) => Promise<QueryResult<T>>;
16
+ close: () => Promise<void>;
17
+ };
18
+ /** Re-export contracts CRDT types for consumers */
19
+ export type { CrdtOperationsInsert, CrdtOperationsRow };
20
+ /**
21
+ * Connect to PGlite (embedded PostgreSQL) for local development/testing.
22
+ * Uses dynamic import to avoid bundling @electric-sql/pglite when not needed.
23
+ *
24
+ * @param options - Optional connection options
25
+ * @param options.dataDir - Override the default data directory. Use ':memory:' for in-memory.
26
+ */
27
+ export declare function connectPglite(options?: {
28
+ dataDir?: string;
29
+ }): Promise<McpDbClient>;
30
+ /**
31
+ * Connect to PostgreSQL for production use.
32
+ * Supports Neon, Supabase, and generic PostgreSQL with SSL.
33
+ */
34
+ export declare function connectPostgres(): Promise<McpDbClient>;
35
+ /**
36
+ * Factory function that creates an MCP database client based on configuration.
37
+ * Reads `persistenceDriver` from getMcpConfig() to determine which adapter to use.
38
+ */
39
+ export declare function createMcpDbClient(): Promise<McpDbClient>;
40
+ declare const _default: {
41
+ connectPglite: typeof connectPglite;
42
+ connectPostgres: typeof connectPostgres;
43
+ createMcpDbClient: typeof createMcpDbClient;
44
+ };
45
+ export default _default;
46
+ //# sourceMappingURL=db.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/adapters/db.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAKH,OAAO,KAAK,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,qBAAqB,CAAC;AAGnF,MAAM,WAAW,WAAW,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IACtD,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,KAAK,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;IACjG,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CAC5B,CAAC;AAEF,mDAAmD;AACnD,YAAY,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,CAAC;AA8BxD;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CA8CxF;AAED;;;GAGG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,WAAW,CAAC,CA+C5D;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,WAAW,CAAC,CAS9D;;;;;;AAED,wBAAqE"}
@@ -0,0 +1,127 @@
1
+ /**
2
+ * DB adapter for MCP.
3
+ * - `connectPglite()` initializes ElectricSQL/pglite client with CRDT metadata.
4
+ * - `connectPostgres()` creates a standard Postgres client with Electric metadata.
5
+ * - `createMcpDbClient()` factory that selects adapter based on config.
6
+ *
7
+ * Uses @revealui/contracts as the single source of truth for CRDT operation types.
8
+ */
9
+ import { mkdir } from 'node:fs/promises';
10
+ import { dirname } from 'node:path';
11
+ import getMcpConfig from '@revealui/config/mcp';
12
+ import { getSSLConfig } from '@revealui/core/database/ssl-config';
13
+ // CRDT operations table schema for conflict-free replication
14
+ const CRDT_TABLE_SQL = `
15
+ CREATE TABLE IF NOT EXISTS crdt_operations (
16
+ id TEXT PRIMARY KEY,
17
+ document_id TEXT NOT NULL,
18
+ operation_type TEXT NOT NULL,
19
+ payload JSONB NOT NULL,
20
+ vector_clock JSONB NOT NULL,
21
+ node_id TEXT NOT NULL,
22
+ created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
23
+ applied_at TIMESTAMPTZ
24
+ );
25
+ CREATE INDEX IF NOT EXISTS idx_crdt_ops_document ON crdt_operations(document_id);
26
+ CREATE INDEX IF NOT EXISTS idx_crdt_ops_node ON crdt_operations(node_id);
27
+ CREATE INDEX IF NOT EXISTS idx_crdt_ops_created ON crdt_operations(created_at DESC);
28
+ `;
29
+ /**
30
+ * Connect to PGlite (embedded PostgreSQL) for local development/testing.
31
+ * Uses dynamic import to avoid bundling @electric-sql/pglite when not needed.
32
+ *
33
+ * @param options - Optional connection options
34
+ * @param options.dataDir - Override the default data directory. Use ':memory:' for in-memory.
35
+ */
36
+ export async function connectPglite(options) {
37
+ const cfg = getMcpConfig();
38
+ // Determine data directory from options, config, or default
39
+ // Use ':memory:' for in-memory database (useful for testing)
40
+ const dataDir = options?.dataDir || cfg.electricDatabaseUrl || '.revealui/mcp/pglite';
41
+ let db;
42
+ try {
43
+ // Ensure directory exists if not in-memory
44
+ if (dataDir !== ':memory:') {
45
+ await mkdir(dirname(dataDir), { recursive: true });
46
+ }
47
+ const { PGlite } = await import('@electric-sql/pglite');
48
+ db = new PGlite(dataDir);
49
+ await db.waitReady;
50
+ }
51
+ catch (error) {
52
+ const err = error;
53
+ if (err.message?.includes('Cannot find module') || err.message?.includes('MODULE_NOT_FOUND')) {
54
+ throw new Error('@electric-sql/pglite is not installed. Run: pnpm add -D @electric-sql/pglite');
55
+ }
56
+ throw error;
57
+ }
58
+ // Create CRDT operations table
59
+ await db.exec(CRDT_TABLE_SQL);
60
+ return {
61
+ async query(sql, params) {
62
+ const result = await db.query(sql, params);
63
+ return {
64
+ rows: result.rows,
65
+ affectedRows: result.affectedRows,
66
+ };
67
+ },
68
+ async close() {
69
+ await db.close();
70
+ },
71
+ };
72
+ }
73
+ /**
74
+ * Connect to PostgreSQL for production use.
75
+ * Supports Neon, Supabase, and generic PostgreSQL with SSL.
76
+ */
77
+ export async function connectPostgres() {
78
+ const cfg = getMcpConfig();
79
+ const connectionString = cfg.electricDatabaseUrl ||
80
+ process.env.DATABASE_URL ||
81
+ process.env.POSTGRES_URL ||
82
+ process.env.SUPABASE_DATABASE_URI;
83
+ if (!connectionString) {
84
+ throw new Error('Database connection string not found. Set ELECTRIC_DATABASE_URL, DATABASE_URL, POSTGRES_URL, or SUPABASE_DATABASE_URI.');
85
+ }
86
+ const { Pool } = await import('pg');
87
+ const pool = new Pool({
88
+ connectionString,
89
+ ssl: getSSLConfig(connectionString),
90
+ });
91
+ // Test connection
92
+ const client = await pool.connect();
93
+ try {
94
+ await client.query('SELECT 1');
95
+ }
96
+ finally {
97
+ client.release();
98
+ }
99
+ // Create CRDT operations table
100
+ await pool.query(CRDT_TABLE_SQL);
101
+ return {
102
+ async query(sql, params) {
103
+ const result = await pool.query(sql, params);
104
+ return {
105
+ rows: result.rows,
106
+ affectedRows: result.rowCount ?? undefined,
107
+ };
108
+ },
109
+ async close() {
110
+ await pool.end();
111
+ },
112
+ };
113
+ }
114
+ /**
115
+ * Factory function that creates an MCP database client based on configuration.
116
+ * Reads `persistenceDriver` from getMcpConfig() to determine which adapter to use.
117
+ */
118
+ export async function createMcpDbClient() {
119
+ const cfg = getMcpConfig();
120
+ if (cfg.persistenceDriver === 'postgres') {
121
+ return connectPostgres();
122
+ }
123
+ // Default to pglite for local development
124
+ return connectPglite();
125
+ }
126
+ export default { connectPglite, connectPostgres, createMcpDbClient };
127
+ //# sourceMappingURL=db.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"db.js","sourceRoot":"","sources":["../../src/adapters/db.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,YAAY,MAAM,sBAAsB,CAAC;AAEhD,OAAO,EAAE,YAAY,EAAE,MAAM,oCAAoC,CAAC;AA0BlE,6DAA6D;AAC7D,MAAM,cAAc,GAAG;;;;;;;;;;;;;;CActB,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CAAC,OAA8B;IAChE,MAAM,GAAG,GAAG,YAAY,EAAE,CAAC;IAE3B,4DAA4D;IAC5D,6DAA6D;IAC7D,MAAM,OAAO,GAAG,OAAO,EAAE,OAAO,IAAI,GAAG,CAAC,mBAAmB,IAAI,sBAAsB,CAAC;IAEtF,IAAI,EAAkB,CAAC;IAEvB,IAAI,CAAC;QACH,2CAA2C;QAC3C,IAAI,OAAO,KAAK,UAAU,EAAE,CAAC;YAC3B,MAAM,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QACrD,CAAC;QAED,MAA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ridge
3
+ *
4
+ * JWT claims validation and tool-level authorization for MCP server launchers.
5
+ * Does NOT verify JWT signatures — that is the transport layer's responsibility.
6
+ * This module validates the claims structure, expiration, and tier-based ACL.
7
+ */
8
+ import { z } from '@revealui/contracts';
9
+ /** JWT claims expected from RevealUI auth tokens */
10
+ export declare const McpAuthClaimsSchema: z.ZodObject<{
11
+ sub: z.ZodString;
12
+ tier: z.ZodEnum<{
13
+ free: "free";
14
+ pro: "pro";
15
+ max: "max";
16
+ enterprise: "enterprise";
17
+ }>;
18
+ iss: z.ZodOptional<z.ZodString>;
19
+ iat: z.ZodOptional<z.ZodNumber>;
20
+ exp: z.ZodOptional<z.ZodNumber>;
21
+ permissions: z.ZodOptional<z.ZodArray<z.ZodString>>;
22
+ }, z.core.$strip>;
23
+ export type McpAuthClaims = z.infer<typeof McpAuthClaimsSchema>;
24
+ /**
25
+ * Validate and decode MCP auth claims from a JWT payload.
26
+ * Does NOT verify signature — that should be done by the transport layer.
27
+ * This validates the claims structure and expiration.
28
+ */
29
+ export declare function validateMcpClaims(payload: unknown): {
30
+ valid: boolean;
31
+ claims?: McpAuthClaims;
32
+ error?: string;
33
+ };
34
+ /**
35
+ * Check if claims authorize a specific tool invocation.
36
+ * Verifies both tier level and explicit permissions list (if present).
37
+ */
38
+ export declare function authorizeToolCall(claims: McpAuthClaims, toolName: string, requiredTier?: string): {
39
+ authorized: boolean;
40
+ reason?: string;
41
+ };
42
+ //# sourceMappingURL=auth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../src/auth.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,qBAAqB,CAAC;AAMxC,oDAAoD;AACpD,eAAO,MAAM,mBAAmB;;;;;;;;;;;;iBAO9B,CAAC;AAEH,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAMhE;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,OAAO,GAAG;IACnD,KAAK,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,aAAa,CAAC;IACvB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAgBA;AAMD;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,aAAa,EACrB,QAAQ,EAAE,MAAM,EAChB,YAAY,GAAE,MAAe,GAC5B;IAAE,UAAU,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,CAwB1C"}