@revealui/mcp 0.1.11 → 0.3.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 (86) hide show
  1. package/LICENSE +104 -17
  2. package/README.md +18 -13
  3. package/dist/adapters/db.d.ts +16 -7
  4. package/dist/adapters/db.d.ts.map +1 -1
  5. package/dist/adapters/db.js +6 -24
  6. package/dist/adapters/db.js.map +1 -1
  7. package/dist/client.d.ts +307 -0
  8. package/dist/client.d.ts.map +1 -0
  9. package/dist/client.js +492 -0
  10. package/dist/client.js.map +1 -0
  11. package/dist/hypervisor.d.ts +18 -0
  12. package/dist/hypervisor.d.ts.map +1 -1
  13. package/dist/hypervisor.js +83 -4
  14. package/dist/hypervisor.js.map +1 -1
  15. package/dist/index.d.ts +7 -8
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +10 -19
  18. package/dist/index.js.map +1 -1
  19. package/dist/metering.d.ts +59 -0
  20. package/dist/metering.d.ts.map +1 -0
  21. package/dist/metering.js +25 -0
  22. package/dist/metering.js.map +1 -0
  23. package/dist/oauth.d.ts +171 -0
  24. package/dist/oauth.d.ts.map +1 -0
  25. package/dist/oauth.js +292 -0
  26. package/dist/oauth.js.map +1 -0
  27. package/dist/remote-client.d.ts +86 -0
  28. package/dist/remote-client.d.ts.map +1 -0
  29. package/dist/remote-client.js +130 -0
  30. package/dist/remote-client.js.map +1 -0
  31. package/dist/servers/adapter.d.ts.map +1 -1
  32. package/dist/servers/adapter.js +4 -0
  33. package/dist/servers/adapter.js.map +1 -1
  34. package/dist/servers/contracts.d.ts +23 -0
  35. package/dist/servers/contracts.d.ts.map +1 -0
  36. package/dist/servers/contracts.js +34 -0
  37. package/dist/servers/contracts.js.map +1 -0
  38. package/dist/servers/factories/contracts.d.ts +7272 -0
  39. package/dist/servers/factories/contracts.d.ts.map +1 -0
  40. package/dist/servers/factories/contracts.js +646 -0
  41. package/dist/servers/factories/contracts.js.map +1 -0
  42. package/dist/servers/factories/revealui-content.d.ts +85 -0
  43. package/dist/servers/factories/revealui-content.d.ts.map +1 -0
  44. package/dist/servers/factories/revealui-content.js +471 -0
  45. package/dist/servers/factories/revealui-content.js.map +1 -0
  46. package/dist/servers/neon.d.ts.map +1 -1
  47. package/dist/servers/neon.js +1 -5
  48. package/dist/servers/neon.js.map +1 -1
  49. package/dist/servers/next-devtools.d.ts.map +1 -1
  50. package/dist/servers/next-devtools.js +0 -4
  51. package/dist/servers/next-devtools.js.map +1 -1
  52. package/dist/servers/playwright.d.ts.map +1 -1
  53. package/dist/servers/playwright.js +0 -4
  54. package/dist/servers/playwright.js.map +1 -1
  55. package/dist/servers/revealui-content.d.ts +12 -18
  56. package/dist/servers/revealui-content.d.ts.map +1 -1
  57. package/dist/servers/revealui-content.js +14 -224
  58. package/dist/servers/revealui-content.js.map +1 -1
  59. package/dist/servers/revealui-email.d.ts.map +1 -1
  60. package/dist/servers/revealui-email.js +0 -6
  61. package/dist/servers/revealui-email.js.map +1 -1
  62. package/dist/servers/revealui-memory.d.ts +24 -0
  63. package/dist/servers/revealui-memory.d.ts.map +1 -0
  64. package/dist/servers/revealui-memory.js +335 -0
  65. package/dist/servers/revealui-memory.js.map +1 -0
  66. package/dist/servers/revealui-stripe.d.ts.map +1 -1
  67. package/dist/servers/revealui-stripe.js +0 -4
  68. package/dist/servers/revealui-stripe.js.map +1 -1
  69. package/dist/servers/stripe.d.ts.map +1 -1
  70. package/dist/servers/stripe.js +1 -5
  71. package/dist/servers/stripe.js.map +1 -1
  72. package/dist/servers/supabase.d.ts.map +1 -1
  73. package/dist/servers/supabase.js +0 -4
  74. package/dist/servers/supabase.js.map +1 -1
  75. package/dist/servers/vercel.d.ts.map +1 -1
  76. package/dist/servers/vercel.js +1 -5
  77. package/dist/servers/vercel.js.map +1 -1
  78. package/dist/streamable-http.d.ts +72 -0
  79. package/dist/streamable-http.d.ts.map +1 -0
  80. package/dist/streamable-http.js +120 -0
  81. package/dist/streamable-http.js.map +1 -0
  82. package/package.json +30 -12
  83. package/dist/stores/postgres-idempotency.d.ts +0 -32
  84. package/dist/stores/postgres-idempotency.d.ts.map +0 -1
  85. package/dist/stores/postgres-idempotency.js +0 -63
  86. package/dist/stores/postgres-idempotency.js.map +0 -1
package/LICENSE CHANGED
@@ -1,22 +1,109 @@
1
- MIT License
1
+ Functional Source License, Version 1.1, MIT Future License
2
2
 
3
- Copyright (c) 2025-2026 RevealUI Studio
3
+ Abbreviation
4
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:
5
+ FSL-1.1-MIT
11
6
 
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
7
+ Notice
14
8
 
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.
9
+ Copyright 2025-2026 RevealUI Studio (founder@revealui.com)
22
10
 
11
+ Terms and Conditions
12
+
13
+ Licensor: RevealUI Studio
14
+
15
+ Licensed Work: @revealui/mcp
16
+ The Licensed Work is copyright 2025-2026 RevealUI Studio.
17
+
18
+ Change Date: 2028-04-08
19
+
20
+ Change License: MIT
21
+
22
+ For information about alternative licensing arrangements for the Licensed Work,
23
+ please contact: founder@revealui.com
24
+
25
+ License text below is the Functional Source License, Version 1.1, MIT Future
26
+ License, as published at https://fsl.software/FSL-1.1-MIT.template.md
27
+
28
+ ---
29
+
30
+ ## Terms and Conditions
31
+
32
+ ### Acceptance
33
+
34
+ In order to get any license under these terms, you must agree to them as
35
+ both strict obligations and conditions to all your licenses.
36
+
37
+ ### Copyright License
38
+
39
+ The licensor grants you a non-exclusive, royalty-free, worldwide,
40
+ non-sublicensable, non-transferable license to use, copy, distribute, make
41
+ available, and prepare derivative works of the licensed work, in each case
42
+ subject to the limitations and conditions below.
43
+
44
+ ### Limitations
45
+
46
+ You may not make the functionality of the licensed work or a modified
47
+ version available to third parties as a service, or distribute the
48
+ licensed work or a modified version in a way that makes the functionality
49
+ of the software available to third parties. Making the functionality of
50
+ the licensed work available to third parties includes, without limitation,
51
+ enabling third parties to interact with the functionality of the licensed
52
+ work remotely through a computer network, offering a service the value of
53
+ which entirely or primarily derives from the value of the licensed work,
54
+ or offering a service that accomplishes for users the primary purpose of
55
+ the licensed work or a modified version.
56
+
57
+ ### Patents
58
+
59
+ The licensor grants you a license, under any patent claims the licensor
60
+ can license, or becomes able to license, to make, have made, use, sell,
61
+ offer for sale, import and have imported the licensed work, in each case
62
+ subject to the limitations and conditions in this license. This license
63
+ does not cover any patent claims that you cause to be infringed by
64
+ modifications or additions to the licensed work. If you or your company
65
+ make any written claim that the licensed work infringes or contributes to
66
+ infringement of any patent, your patent license for the licensed work
67
+ granted under these terms ends immediately. If your company makes such a
68
+ claim, your patent license ends immediately for work on behalf of your
69
+ company.
70
+
71
+ ### Fair Use
72
+
73
+ This license is not intended to limit any right of fair use, fair
74
+ dealing, or other applicable copyright exception or limitation.
75
+
76
+ ### No Other Rights
77
+
78
+ These terms do not allow you to sublicense or transfer any of your
79
+ licenses to anyone else, or prevent the licensor from granting licenses
80
+ to anyone else. These terms do not imply any other licenses.
81
+
82
+ ### Termination
83
+
84
+ If you use the licensed work in violation of these terms, such use is
85
+ not licensed, and your licenses may be revoked if you do not cure the
86
+ violation.
87
+
88
+ The licensor may also revoke your licenses if you fail to comply with
89
+ these terms.
90
+
91
+ ### No Liability
92
+
93
+ ***As far as the law allows, the licensed work comes as is, without any
94
+ warranty or condition, and the licensor will not be liable to you for any
95
+ damages arising out of these terms or the use or nature of the licensed
96
+ work, under any kind of legal claim.***
97
+
98
+ ### Change Date
99
+
100
+ On the Change Date, or the fourth anniversary of the first publicly
101
+ available distribution of a specific version of the Licensed Work under
102
+ this License, whichever comes first, the Licensor hereby grants you
103
+ rights under the terms of the Change License, and the rights granted in
104
+ the paragraphs above terminate.
105
+
106
+ ### Change License
107
+
108
+ On the Change Date, the Licensed Work will be made available under the
109
+ Change License specified above (MIT).
package/README.md CHANGED
@@ -11,7 +11,7 @@ Centralized MCP server infrastructure, configuration, and documentation for Reve
11
11
 
12
12
  This package contains everything MCP-related:
13
13
 
14
- - **10 MCP Servers** - Code validator, Vercel, Stripe, Neon, Supabase, Playwright, Next.js DevTools, RevealUI Content, RevealUI Email, RevealUI Stripe
14
+ - **13 MCP Servers** Code Validator, Contracts Introspection, Neon, Next.js DevTools, Playwright, RevealUI Content, RevealUI Email, RevealUI Memory, RevealUI Stripe, Stripe, Supabase, Vercel, and an Email Provider helper. Ground-truth count is enforced by `pnpm validate:claims`.
15
15
  - **Configuration Templates** - For Claude Code / Claude Desktop
16
16
  - **Utilities** - Config management, database adapters
17
17
  - **Documentation** - Complete guides and per-server docs
@@ -55,14 +55,9 @@ tsx packages/mcp/src/servers/code-validator.ts
55
55
  ```
56
56
  packages/mcp/
57
57
  ├── src/
58
- │ ├── servers/ # 7 MCP server implementations
58
+ │ ├── servers/ # MCP server implementations (run `ls packages/mcp/src/servers/` for the current list)
59
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
60
+ │ │ └── … ← Neon, Next.js DevTools, Playwright, RevealUI-*, Stripe, Supabase, Vercel
66
61
  │ ├── config/ # Configuration utilities
67
62
  │ │ ├── index.ts
68
63
  │ │ ├── config.json
@@ -78,9 +73,6 @@ packages/mcp/
78
73
  │ ├── SETUP.md # Setup instructions
79
74
  │ └── servers/ # Per-server documentation
80
75
  │ └── code-validator.md
81
- ├── migrations/ # Database migrations
82
- │ ├── 0001_add_crdt_columns.sql
83
- │ └── ...
84
76
  └── package.json
85
77
  ```
86
78
 
@@ -153,6 +145,19 @@ Next.js 16+ runtime diagnostics and automation.
153
145
  pnpm mcp:next-devtools
154
146
  ```
155
147
 
148
+ ### 8. Contracts Introspection
149
+ **Status:** ✅ Active (no API key required, **not** Pro-license-gated)
150
+
151
+ Phase 1 of the protocol-pyramid ADR ([`docs/decisions/2026-05-03-contracts-protocol-pyramid.md`](../../docs/decisions/2026-05-03-contracts-protocol-pyramid.md)). Exposes every `@revealui/contracts` category (representation, entities, content, admin, agents, security, secrets, a2a, api-auth, api-chat, api-gdpr, content-validation, devkit-profiles, generated, providers, revealcoin, stripe-webhook-events) as MCP **resources** (read-only JSON Schemas of every category schema) and matching MCP **tools** that parse arbitrary JSON against any registered schema.
152
+
153
+ - **Resources:** `revealui-contracts://catalog` (full discovery payload) + `revealui-contracts://<category>` (one per category, returns all schemas).
154
+ - **Tools:** `contracts_list_categories`, `contracts_get_schema`, plus one `contracts_validate_<category>` per category.
155
+ - **License:** intentionally NOT Pro-gated. `@revealui/contracts` is MIT and agent-side schema introspection is meant to enable any MCP client (Claude Code, Cursor, custom agents) to integrate cleanly.
156
+
157
+ ```bash
158
+ tsx packages/mcp/src/servers/contracts.ts
159
+ ```
160
+
156
161
  ## Configuration
157
162
 
158
163
  All configuration templates are in `configs/`:
@@ -259,5 +264,5 @@ Commercial - see [LICENSE.commercial](../../LICENSE.commercial)
259
264
  ---
260
265
 
261
266
  **Status:** ✅ Consolidated and Active
262
- **Servers:** 7 available (1 active, 6 optional)
263
- **Last Updated:** 2026-03-04
267
+ **Servers:** 13 available (ground truth: `pnpm validate:claims` — source of truth is `packages/mcp/src/servers/`)
268
+ **Last Updated:** 2026-05-03
@@ -1,12 +1,14 @@
1
1
  /**
2
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.
3
+ * - `connectPglite()` returns a PGlite-backed client.
4
+ * - `connectPostgres()` returns a `pg.Pool`-backed client.
5
+ * - `createMcpDbClient()` selects adapter based on `persistenceDriver` config.
6
6
  *
7
- * Uses @revealui/contracts as the single source of truth for CRDT operation types.
7
+ * Schema is the caller's responsibility these factories do NOT bootstrap any
8
+ * tables. Apply drizzle-kit migrations (`pnpm --filter @revealui/db db:migrate`
9
+ * or the PGlite equivalent) before issuing queries.
8
10
  */
9
- import type { CrdtOperationsInsert, CrdtOperationsRow } from '@revealui/contracts';
11
+ import type { McpDocumentOperationsInsert, McpDocumentOperationsRow } from '@revealui/contracts';
10
12
  export interface QueryResult<T = Record<string, unknown>> {
11
13
  rows: T[];
12
14
  affectedRows?: number;
@@ -15,8 +17,15 @@ export type McpDbClient = {
15
17
  query: <T = Record<string, unknown>>(sql: string, params?: unknown[]) => Promise<QueryResult<T>>;
16
18
  close: () => Promise<void>;
17
19
  };
18
- /** Re-export contracts CRDT types for consumers */
19
- export type { CrdtOperationsInsert, CrdtOperationsRow };
20
+ /**
21
+ * Re-export the Drizzle-generated types for MCP's document-operations log so
22
+ * consumers of `@revealui/mcp` don't have to also import `@revealui/contracts`
23
+ * just to type a `mcp_document_operations` row. These types ARE the source of
24
+ * truth — they are generated from the Drizzle schema at
25
+ * `packages/db/src/schema/mcp-document-operations.ts` and will track any
26
+ * future column changes automatically.
27
+ */
28
+ export type { McpDocumentOperationsInsert, McpDocumentOperationsRow };
20
29
  /**
21
30
  * Connect to PGlite (embedded PostgreSQL) for local development/testing.
22
31
  * Uses dynamic import to avoid bundling @electric-sql/pglite when not needed.
@@ -1 +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"}
1
+ {"version":3,"file":"db.d.ts","sourceRoot":"","sources":["../../src/adapters/db.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,OAAO,KAAK,EAAE,2BAA2B,EAAE,wBAAwB,EAAE,MAAM,qBAAqB,CAAC;AAGjG,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;;;;;;;GAOG;AACH,YAAY,EAAE,2BAA2B,EAAE,wBAAwB,EAAE,CAAC;AAatE;;;;;;GAMG;AACH,wBAAsB,aAAa,CAAC,OAAO,CAAC,EAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,WAAW,CAAC,CA2CxF;AAED;;;GAGG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,WAAW,CAAC,CA4C5D;AAED;;;GAGG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,WAAW,CAAC,CAS9D;;;;;;AAED,wBAAqE"}
@@ -1,31 +1,17 @@
1
1
  /**
2
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.
3
+ * - `connectPglite()` returns a PGlite-backed client.
4
+ * - `connectPostgres()` returns a `pg.Pool`-backed client.
5
+ * - `createMcpDbClient()` selects adapter based on `persistenceDriver` config.
6
6
  *
7
- * Uses @revealui/contracts as the single source of truth for CRDT operation types.
7
+ * Schema is the caller's responsibility these factories do NOT bootstrap any
8
+ * tables. Apply drizzle-kit migrations (`pnpm --filter @revealui/db db:migrate`
9
+ * or the PGlite equivalent) before issuing queries.
8
10
  */
9
11
  import { mkdir } from 'node:fs/promises';
10
12
  import { dirname } from 'node:path';
11
13
  import getMcpConfig from '@revealui/config/mcp';
12
14
  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
15
  /**
30
16
  * Connect to PGlite (embedded PostgreSQL) for local development/testing.
31
17
  * Uses dynamic import to avoid bundling @electric-sql/pglite when not needed.
@@ -55,8 +41,6 @@ export async function connectPglite(options) {
55
41
  }
56
42
  throw error;
57
43
  }
58
- // Create CRDT operations table
59
- await db.exec(CRDT_TABLE_SQL);
60
44
  return {
61
45
  async query(sql, params) {
62
46
  const result = await db.query(sql, params);
@@ -96,8 +80,6 @@ export async function connectPostgres() {
96
80
  finally {
97
81
  client.release();
98
82
  }
99
- // Create CRDT operations table
100
- await pool.query(CRDT_TABLE_SQL);
101
83
  return {
102
84
  async query(sql, params) {
103
85
  const result = await pool.query(sql, params);
@@ -1 +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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MAAM,CAAC,IAAI,CAAC,CAAC;IACpC,MAAM,IAAI,GAAG,IAAI,IAAI,CAAC;QACpB,gBAAgB;QAChB,GAAG,EAAE,YAAY,CAAC,gBAAgB,CAAC;KACpC,CAAC,CAAC;IAEH,kBAAkB;IAClB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;IACpC,IAAI,CAAC;QACH,MAAM,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,CAAC;IACjC,CAAC;YAAS,CAAC;QACT,MAAM,CAAC,OAAO,EAAE,CAAC;IACnB,CAAC;IAED,OAAO;QACL,KAAK,CAAC,KAAK,CACT,GAAW,EACX,MAAkB;YAElB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;YAC7C,OAAO;gBACL,IAAI,EAAE,MAAM,CAAC,IAAW;gBACxB,YAAY,EAAE,MAAM,CAAC,QAAQ,IAAI,SAAS;aAC3C,CAAC;QACJ,CAAC;QACD,KAAK,CAAC,KAAK;YACT,MAAM,IAAI,CAAC,GAAG,EAAE,CAAC;QACnB,CAAC;KACF,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB;IACrC,MAAM,GAAG,GAAG,YAAY,EAAE,CAAC;IAE3B,IAAI,GAAG,CAAC,iBAAiB,KAAK,UAAU,EAAE,CAAC;QACzC,OAAO,eAAe,EAAE,CAAC;IAC3B,CAAC;IAED,0CAA0C;IAC1C,OAAO,aAAa,EAAE,CAAC;AACzB,CAAC;AAED,eAAe,EAAE,aAAa,EAAE,eAAe,EAAE,iBAAiB,EAAE,CAAC"}
@@ -0,0 +1,307 @@
1
+ /**
2
+ * MCP Client wrapper for `@revealui/mcp`.
3
+ *
4
+ * Phase: Stage 0 of the MCP v1 plan (see `.jv/docs/mcp-productionization-scope.md`).
5
+ *
6
+ * Wraps `@modelcontextprotocol/sdk`'s `Client` with a RevealUI-shaped surface:
7
+ * transport selection, capability enforcement (method throws a typed error if
8
+ * the server doesn't advertise the feature), per-URI resource subscription
9
+ * fan-out, and application-layer handlers for the server-initiated primitives
10
+ * (sampling, elicitation, roots).
11
+ *
12
+ * Stage 0 completion as of PR-0.3:
13
+ * PR-0.1 — resources + prompts.
14
+ * PR-0.2 — sampling + elicitation + roots + completions.
15
+ * PR-0.3 — logging, progress, cancellation, generic notification routing,
16
+ * per-request options (signal + onProgress + timeout) threaded
17
+ * through every client-initiated call.
18
+ *
19
+ * The hypervisor (`./hypervisor.ts`) continues to speak its custom JSON-RPC
20
+ * for tool calls. Stage 1 migrates the hypervisor to route through this
21
+ * client so transport abstraction (Streamable HTTP) lands cleanly.
22
+ */
23
+ import type { OAuthClientProvider } from '@modelcontextprotocol/sdk/client/auth.js';
24
+ import { type StreamableHTTPClientTransportOptions, type StreamableHTTPReconnectionOptions } from '@modelcontextprotocol/sdk/client/streamableHttp.js';
25
+ import type { AnyObjectSchema, SchemaOutput } from '@modelcontextprotocol/sdk/server/zod-compat.js';
26
+ import type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
27
+ import { type CallToolResult, type ClientCapabilities, type CompleteRequest, type CompleteResult, type CreateMessageRequest, type CreateMessageResult, type ElicitRequest, type ElicitResult, type LoggingLevel, type LoggingMessageNotification, type Progress, type Prompt, type PromptMessage, type PromptReference, type Resource, type ResourceContents, type ResourceTemplateReference, type Root, type ServerCapabilities, type Tool } from '@modelcontextprotocol/sdk/types.js';
28
+ /**
29
+ * Spawn a local subprocess and talk MCP over its stdio.
30
+ * Matches `StdioClientTransport` from the SDK; we surface the fields we use.
31
+ */
32
+ export type StdioTransportOptions = {
33
+ kind: 'stdio';
34
+ command: string;
35
+ args?: string[];
36
+ env?: Record<string, string>;
37
+ cwd?: string;
38
+ };
39
+ /**
40
+ * Inject a pre-built SDK `Transport`. Intended for tests (`InMemoryTransport`)
41
+ * and for experimental transports not yet first-classed in this discriminator.
42
+ */
43
+ export type CustomTransportOptions = {
44
+ kind: 'custom';
45
+ transport: Transport;
46
+ };
47
+ /**
48
+ * Talk MCP over the spec's Streamable HTTP transport. The preferred remote
49
+ * transport as of the 2025 spec revision — supports request/response JSON,
50
+ * SSE streaming for progress/notifications, and OAuth 2.1 for authenticated
51
+ * deployments.
52
+ *
53
+ * Pass `authProvider` to enable OAuth 2.1 (Authorization Code + PKCE,
54
+ * Dynamic Client Registration, automatic refresh). `@revealui/mcp` ships
55
+ * `McpOAuthProvider` at `./oauth.js` — construct it with a
56
+ * `(tenant, server, vault)` triple and a redirect URL, and attach it here.
57
+ * If `authProvider` is omitted and the server requires auth, the SDK throws
58
+ * `UnauthorizedError` on connect. Callers who need static bearer-token auth
59
+ * instead can pass the header via `requestInit.headers`.
60
+ */
61
+ export type StreamableHttpTransportOptions = {
62
+ kind: 'streamable-http';
63
+ /** MCP endpoint URL (e.g. `https://example.com/mcp`). */
64
+ url: string | URL;
65
+ /** Fetch `RequestInit` applied to every outgoing request. Use this for
66
+ * headers, credentials, custom signals, etc. */
67
+ requestInit?: RequestInit;
68
+ /** Override `fetch`. Defaults to global `fetch`. */
69
+ fetch?: typeof fetch;
70
+ /** Reuse a server-issued session ID (e.g. for reconnection). */
71
+ sessionId?: string;
72
+ /** SSE reconnection tuning (delays, retry ceiling). */
73
+ reconnectionOptions?: StreamableHTTPReconnectionOptions;
74
+ /**
75
+ * OAuth 2.1 client provider. The SDK invokes discovery, DCR, PKCE, and
76
+ * refresh flows through this object, persisting state via the provider's
77
+ * storage methods. See `./oauth.js` for a revvault-backed implementation.
78
+ */
79
+ authProvider?: OAuthClientProvider;
80
+ };
81
+ export type TransportOptions = StdioTransportOptions | CustomTransportOptions | StreamableHttpTransportOptions;
82
+ export type { StreamableHTTPClientTransportOptions, StreamableHTTPReconnectionOptions };
83
+ /**
84
+ * Handle a `sampling/createMessage` request FROM the server. The server is
85
+ * asking the client to run an LLM completion on its behalf — typically the
86
+ * client delegates to the application's configured LLM provider.
87
+ *
88
+ * Providing this handler causes the client to advertise the `sampling`
89
+ * capability during initialize; omitting it leaves the capability absent and
90
+ * the server will treat sampling as unsupported.
91
+ */
92
+ export type SamplingHandler = (params: CreateMessageRequest['params']) => Promise<CreateMessageResult>;
93
+ /**
94
+ * Handle an `elicitation/create` request FROM the server. The server is
95
+ * asking the client to elicit structured input from the user (form mode) or
96
+ * direct them to a URL (URL mode). The handler is responsible for rendering
97
+ * UI and returning the user's response.
98
+ */
99
+ export type ElicitationHandler = (params: ElicitRequest['params']) => Promise<ElicitResult>;
100
+ /**
101
+ * Return the client's current roots (directories or URI namespaces it
102
+ * exposes to the server). Called each time the server issues `roots/list`,
103
+ * so the provider SHOULD return current state rather than a cached snapshot.
104
+ *
105
+ * Providing this advertises the `roots` capability (with `listChanged: true`
106
+ * — the client can notify via `notifyRootsListChanged()`).
107
+ */
108
+ export type RootsProvider = () => Root[] | Promise<Root[]>;
109
+ /**
110
+ * Per-request options applied to every client-initiated call. Mirrors the
111
+ * SDK's `RequestOptions` but exposes only the fields we expect consumers to
112
+ * use (we may add more as Stage 0 / 1 evolve).
113
+ *
114
+ * - `signal` — pass an `AbortSignal` to cancel the request mid-flight. When
115
+ * aborted the SDK emits `notifications/cancelled` to the server and the
116
+ * pending promise rejects with an AbortError.
117
+ * - `onProgress` — subscribe to per-request progress notifications. The SDK
118
+ * automatically correlates `notifications/progress` by the progress token
119
+ * and invokes this callback.
120
+ * - `timeout` — request-level timeout in ms. If exceeded the SDK raises a
121
+ * `RequestTimeout` error. Absent = SDK default.
122
+ * - `resetTimeoutOnProgress` — if true, receiving a progress notification
123
+ * resets the timeout clock. Useful for long-running operations.
124
+ */
125
+ export type McpRequestOptions = {
126
+ signal?: AbortSignal;
127
+ onProgress?: (progress: Progress) => void;
128
+ timeout?: number;
129
+ resetTimeoutOnProgress?: boolean;
130
+ };
131
+ export type McpClientOptions = {
132
+ /** Advertised to the server during `initialize`. Required by spec. */
133
+ clientInfo: {
134
+ name: string;
135
+ version: string;
136
+ };
137
+ /** Where and how to reach the server. */
138
+ transport: TransportOptions;
139
+ /** Handle `sampling/createMessage` requests from the server. */
140
+ samplingHandler?: SamplingHandler;
141
+ /** Handle `elicitation/create` requests from the server. */
142
+ elicitationHandler?: ElicitationHandler;
143
+ /** Provide the client's current roots in response to `roots/list`. */
144
+ rootsProvider?: RootsProvider;
145
+ };
146
+ /**
147
+ * Thrown when a caller invokes a method that requires a server-side capability
148
+ * the server did NOT advertise during initialize. Signals a misconfiguration
149
+ * or a version mismatch — not a transient failure; do not retry.
150
+ */
151
+ export declare class McpCapabilityError extends Error {
152
+ readonly capability: string;
153
+ constructor(capability: string);
154
+ }
155
+ /**
156
+ * Thrown when a method is called before `connect()` has resolved.
157
+ */
158
+ export declare class McpNotConnectedError extends Error {
159
+ constructor(method: string);
160
+ }
161
+ export type { CallToolResult, ClientCapabilities, CompleteRequest, CompleteResult, CreateMessageRequest, CreateMessageResult, ElicitRequest, ElicitResult, LoggingLevel, LoggingMessageNotification, Progress, Prompt, PromptMessage, PromptReference, Resource, ResourceContents, ResourceTemplateReference, Root, ServerCapabilities, Tool, };
162
+ /** Parameters delivered to a `subscribeResource` handler. */
163
+ export type ResourceUpdatedParams = {
164
+ uri: string;
165
+ };
166
+ /** Return shape of `getPrompt` — the spec's `GetPromptResult`, narrowed. */
167
+ export type GetPromptResult = {
168
+ description?: string;
169
+ messages: PromptMessage[];
170
+ };
171
+ /** Either a prompt or a resource-template reference — the two valid targets
172
+ * for `completions/complete`. */
173
+ export type CompletionReference = PromptReference | ResourceTemplateReference;
174
+ /** The completion result returned by `complete()`. */
175
+ export type Completion = CompleteResult['completion'];
176
+ /** Parameters delivered to an `onLog` subscriber. */
177
+ export type LogMessageParams = LoggingMessageNotification['params'];
178
+ export declare class McpClient {
179
+ private readonly sdk;
180
+ private readonly options;
181
+ private connected;
182
+ /**
183
+ * Tracks the Streamable HTTP transport when that kind is in use, so
184
+ * `finishAuth()` can delegate to it. Set by `createTransport`, cleared
185
+ * on `close()`.
186
+ */
187
+ private httpTransport?;
188
+ private readonly resourceSubscribers;
189
+ private readonly listChangedHandlers;
190
+ /**
191
+ * Subscribers per notification schema. First `on(schema, handler)` call for
192
+ * a schema registers a single fan-out handler with the SDK; subsequent
193
+ * calls just add to the Set. Removing the last subscriber keeps the SDK
194
+ * handler registered (no public API to unregister by schema) — empty
195
+ * fan-out is a cheap no-op.
196
+ */
197
+ private readonly notificationSubscribers;
198
+ constructor(options: McpClientOptions);
199
+ /**
200
+ * Connect the underlying transport and run MCP `initialize`. Idempotent:
201
+ * calling twice is a no-op on the second call.
202
+ */
203
+ connect(): Promise<void>;
204
+ /**
205
+ * Close the underlying transport and invalidate the client. Idempotent.
206
+ */
207
+ close(): Promise<void>;
208
+ /**
209
+ * Finalize an OAuth 2.1 authorization flow initiated by an `authProvider`.
210
+ *
211
+ * After `connect()` triggers `OAuthClientProvider.redirectToAuthorization`,
212
+ * the user completes consent at the authorization server and is redirected
213
+ * back to the caller's callback URL with a `code` query parameter. The
214
+ * caller passes that `code` here, which delegates to the Streamable HTTP
215
+ * transport's `finishAuth`: the SDK exchanges the code (with the stored
216
+ * PKCE verifier) at the token endpoint and persists the resulting token
217
+ * set via the provider's `saveTokens`. Retry `connect()` afterward.
218
+ *
219
+ * Throws if the client is not using the `streamable-http` transport or if
220
+ * `connect()` has not been called yet (the transport is constructed during
221
+ * `connect`).
222
+ */
223
+ finishAuth(authorizationCode: string): Promise<void>;
224
+ /** Server capabilities returned by `initialize`. Undefined before connect. */
225
+ getServerCapabilities(): ServerCapabilities | undefined;
226
+ listResources(options?: McpRequestOptions): Promise<Resource[]>;
227
+ readResource(uri: string, options?: McpRequestOptions): Promise<ResourceContents[]>;
228
+ /**
229
+ * Subscribe to updates for a single resource URI. The returned function
230
+ * removes this subscription (and unsubscribes on the wire once no
231
+ * subscribers remain for the URI).
232
+ *
233
+ * Requires the server to advertise `resources.subscribe`; throws
234
+ * `McpCapabilityError` otherwise.
235
+ */
236
+ subscribeResource(uri: string, handler: (params: ResourceUpdatedParams) => void, options?: McpRequestOptions): Promise<() => Promise<void>>;
237
+ /**
238
+ * Enumerate tools the server exposes. Requires the server to advertise the
239
+ * `tools` capability.
240
+ *
241
+ * Returns the SDK's `Tool` shape unchanged — name, description, input JSON
242
+ * Schema (as `inputSchema`), and any spec-defined annotations.
243
+ */
244
+ listTools(options?: McpRequestOptions): Promise<Tool[]>;
245
+ /**
246
+ * Invoke a tool by name with the supplied structured arguments. Requires
247
+ * the server to advertise `tools`. Returns the full SDK `CallToolResult`
248
+ * (structured content + isError flag + optional `_meta`).
249
+ *
250
+ * Tool failures surface as `{ isError: true, content: [...] }` rather than
251
+ * thrown exceptions — the server is explicitly asked to communicate tool
252
+ * errors in-band per the MCP spec. Transport-level failures still throw.
253
+ */
254
+ callTool(name: string, args?: Record<string, unknown>, options?: McpRequestOptions): Promise<CallToolResult>;
255
+ listPrompts(options?: McpRequestOptions): Promise<Prompt[]>;
256
+ getPrompt(name: string, args?: Record<string, string>, options?: McpRequestOptions): Promise<GetPromptResult>;
257
+ onResourcesListChanged(handler: () => void): () => void;
258
+ onPromptsListChanged(handler: () => void): () => void;
259
+ onToolsListChanged(handler: () => void): () => void;
260
+ /**
261
+ * Notify the server that the client's roots have changed. The server will
262
+ * typically re-fetch via `roots/list`, which routes to the `rootsProvider`
263
+ * passed at construction. No-op if the client wasn't constructed with a
264
+ * `rootsProvider` — advertising list-changed without a provider is
265
+ * nonsensical, so we fail fast.
266
+ */
267
+ notifyRootsListChanged(): Promise<void>;
268
+ /**
269
+ * Request argument completions from the server. The reference points at a
270
+ * prompt or resource-template; the server returns suggestion values for
271
+ * the named argument given the current partial value.
272
+ */
273
+ complete(reference: CompletionReference, argument: {
274
+ name: string;
275
+ value: string;
276
+ }, options?: McpRequestOptions): Promise<Completion>;
277
+ /**
278
+ * Set the minimum log level the server should emit. Requires the server to
279
+ * advertise the `logging` capability.
280
+ */
281
+ setLoggingLevel(level: LoggingLevel, options?: McpRequestOptions): Promise<void>;
282
+ /**
283
+ * Subscribe to server-emitted log messages. Returns an unregister function.
284
+ *
285
+ * Implemented on top of the generic `on()` fan-out, so multiple subscribers
286
+ * coexist cleanly (admin UI, CLI logger, telemetry exporter, …).
287
+ */
288
+ onLog(handler: (params: LogMessageParams) => void): () => void;
289
+ /**
290
+ * Subscribe to arbitrary server notifications by zod schema. First
291
+ * subscription per schema installs a single SDK handler that fans out to
292
+ * every registered subscriber; later subscriptions join the existing fan.
293
+ * Returns an unregister function.
294
+ *
295
+ * Typically callers use the purpose-built subscribers (`onLog`,
296
+ * `onResourcesListChanged`, `subscribeResource`) rather than this. Use
297
+ * `on()` for schemas the client doesn't yet expose a named subscriber for.
298
+ */
299
+ on<T extends AnyObjectSchema>(schema: T, handler: (notification: SchemaOutput<T>) => void): () => void;
300
+ ping(options?: McpRequestOptions): Promise<void>;
301
+ private createTransport;
302
+ private assertConnected;
303
+ private requireCapability;
304
+ private addListChanged;
305
+ private fireListChanged;
306
+ }
307
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,0CAA0C,CAAC;AAGpF,OAAO,EAEL,KAAK,oCAAoC,EACzC,KAAK,iCAAiC,EACvC,MAAM,oDAAoD,CAAC;AAC5D,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,gDAAgD,CAAC;AAEpG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAC/E,OAAO,EACL,KAAK,cAAc,EACnB,KAAK,kBAAkB,EACvB,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,oBAAoB,EAEzB,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAElB,KAAK,YAAY,EAEjB,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAE/B,KAAK,QAAQ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