@revealui/mcp 0.0.1-pre.0 → 0.1.1

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 (40) hide show
  1. package/LICENSE +22 -202
  2. package/LICENSE.commercial +112 -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/config/index.d.ts +11 -0
  9. package/dist/config/index.d.ts.map +1 -0
  10. package/dist/config/index.js +18 -0
  11. package/dist/config/index.js.map +1 -0
  12. package/dist/contracts.d.ts +131 -0
  13. package/dist/contracts.d.ts.map +1 -0
  14. package/dist/contracts.js +153 -0
  15. package/dist/contracts.js.map +1 -0
  16. package/dist/hypervisor.d.ts +132 -0
  17. package/dist/hypervisor.d.ts.map +1 -0
  18. package/dist/hypervisor.js +359 -0
  19. package/dist/hypervisor.js.map +1 -0
  20. package/dist/index.d.ts +25 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/index.js +36 -10985
  23. package/dist/index.js.map +1 -1
  24. package/dist/servers/adapter.d.ts +209 -0
  25. package/dist/servers/adapter.d.ts.map +1 -0
  26. package/dist/servers/adapter.js +503 -0
  27. package/dist/servers/adapter.js.map +1 -0
  28. package/dist/servers/revealui-content.d.ts +21 -0
  29. package/dist/servers/revealui-content.d.ts.map +1 -0
  30. package/dist/servers/revealui-content.js +199 -0
  31. package/dist/servers/revealui-content.js.map +1 -0
  32. package/dist/servers/revealui-email.d.ts +18 -0
  33. package/dist/servers/revealui-email.d.ts.map +1 -0
  34. package/dist/servers/revealui-email.js +185 -0
  35. package/dist/servers/revealui-email.js.map +1 -0
  36. package/dist/servers/revealui-stripe.d.ts +19 -0
  37. package/dist/servers/revealui-stripe.d.ts.map +1 -0
  38. package/dist/servers/revealui-stripe.js +211 -0
  39. package/dist/servers/revealui-stripe.js.map +1 -0
  40. package/package.json +43 -68
@@ -0,0 +1,359 @@
1
+ /**
2
+ * MCP Hypervisor
3
+ *
4
+ * Manages N running MCP server processes, pings them for liveness, and
5
+ * dynamically exposes their tools at runtime. Inspired by the
6
+ * MCPCompatibilityLayer/MCPHypervisor pattern from AnythingLLM.
7
+ *
8
+ * Architecture:
9
+ * - Singleton: one hypervisor per process manages all MCP servers
10
+ * - Each server is spawned with piped stdio for JSON-RPC communication
11
+ * - Tool names are namespaced: @@mcp_{serverName}_{toolName}
12
+ * - Health check loop: every 60s, process.exitCode check + tools/list probe
13
+ *
14
+ * Wire format: newline-delimited JSON-RPC 2.0 (stdin/stdout)
15
+ */
16
+ import { spawn } from 'node:child_process';
17
+ import { registerCleanupHandler } from '@revealui/core/monitoring';
18
+ import { logger } from '@revealui/core/observability/logger';
19
+ // =============================================================================
20
+ // Constants
21
+ // =============================================================================
22
+ const HEALTH_CHECK_INTERVAL_MS = 60_000;
23
+ const REQUEST_TIMEOUT_MS = 5_000;
24
+ const MCP_TOOL_PREFIX = '@@mcp';
25
+ // =============================================================================
26
+ // MCPHypervisor
27
+ // =============================================================================
28
+ /**
29
+ * Singleton that manages MCP server processes and their tool registries.
30
+ *
31
+ * @example
32
+ * ```typescript
33
+ * const hypervisor = MCPHypervisor.getInstance()
34
+ *
35
+ * hypervisor.registerServer({
36
+ * name: 'stripe',
37
+ * command: 'pnpm',
38
+ * args: ['dlx', '@stripe/mcp', '--tools=all', '--api-key=sk_...'],
39
+ * })
40
+ *
41
+ * await hypervisor.startServer('stripe')
42
+ * const tools = hypervisor.getAllTools()
43
+ * // tools[0].namespacedName === '@@mcp_stripe_create_payment_intent'
44
+ * ```
45
+ */
46
+ export class MCPHypervisor {
47
+ static instance = null;
48
+ servers = new Map();
49
+ requestCounter = 0;
50
+ pendingRequests = new Map();
51
+ healthCheckTimer = null;
52
+ constructor() {
53
+ registerCleanupHandler('mcp-hypervisor', async () => this.stopAll(), 'Stop all MCP server processes', 85);
54
+ this.startHealthCheckLoop();
55
+ }
56
+ static getInstance() {
57
+ if (!MCPHypervisor.instance) {
58
+ MCPHypervisor.instance = new MCPHypervisor();
59
+ }
60
+ return MCPHypervisor.instance;
61
+ }
62
+ // ---------------------------------------------------------------------------
63
+ // Server registration
64
+ // ---------------------------------------------------------------------------
65
+ /**
66
+ * Register an MCP server configuration without starting it.
67
+ */
68
+ registerServer(config) {
69
+ if (this.servers.has(config.name)) {
70
+ logger.warn(`[MCPHypervisor] Server "${config.name}" is already registered`);
71
+ return;
72
+ }
73
+ this.servers.set(config.name, {
74
+ config,
75
+ process: null,
76
+ tools: [],
77
+ healthy: false,
78
+ lastPingAt: null,
79
+ });
80
+ logger.info(`[MCPHypervisor] Registered server: ${config.name}`);
81
+ }
82
+ /**
83
+ * Unregister a server (stops it first if running).
84
+ */
85
+ async unregisterServer(name) {
86
+ const entry = this.servers.get(name);
87
+ if (!entry)
88
+ return;
89
+ if (entry.process)
90
+ await this.stopServer(name);
91
+ this.servers.delete(name);
92
+ }
93
+ // ---------------------------------------------------------------------------
94
+ // Lifecycle
95
+ // ---------------------------------------------------------------------------
96
+ /**
97
+ * Spawn the MCP server process with piped stdio.
98
+ * Tools are discovered via `listServerTools()` after startup.
99
+ */
100
+ async startServer(name) {
101
+ const entry = this.servers.get(name);
102
+ if (!entry)
103
+ throw new Error(`[MCPHypervisor] Unknown server: "${name}"`);
104
+ if (entry.process && entry.process.exitCode === null) {
105
+ logger.info(`[MCPHypervisor] Server "${name}" is already running`);
106
+ return;
107
+ }
108
+ const { config } = entry;
109
+ const child = spawn(config.command, config.args, {
110
+ stdio: ['pipe', 'pipe', 'pipe'],
111
+ env: { ...process.env, ...config.env },
112
+ });
113
+ entry.process = child;
114
+ entry.healthy = false;
115
+ entry.tools = [];
116
+ // Buffer incoming stdout for JSON-RPC response parsing
117
+ let buffer = '';
118
+ child.stdout?.on('data', (chunk) => {
119
+ buffer += chunk.toString();
120
+ const lines = buffer.split('\n');
121
+ buffer = lines.pop() ?? ''; // keep incomplete line in buffer
122
+ for (const line of lines) {
123
+ const trimmed = line.trim();
124
+ if (!trimmed)
125
+ continue;
126
+ try {
127
+ const msg = JSON.parse(trimmed);
128
+ this.handleResponse(msg);
129
+ }
130
+ catch {
131
+ // Non-JSON output from server — ignore
132
+ }
133
+ }
134
+ });
135
+ child.stderr?.on('data', (chunk) => {
136
+ logger.warn(`[MCPHypervisor] ${name} stderr: ${chunk.toString().trim()}`);
137
+ });
138
+ child.on('exit', (code) => {
139
+ logger.warn(`[MCPHypervisor] Server "${name}" exited with code ${code}`);
140
+ entry.healthy = false;
141
+ // Reject all pending requests for this server
142
+ for (const [id, pending] of this.pendingRequests) {
143
+ pending.reject(new Error(`Server "${name}" exited`));
144
+ clearTimeout(pending.timer);
145
+ this.pendingRequests.delete(id);
146
+ }
147
+ });
148
+ // Allow a brief startup window, then probe tools
149
+ await new Promise((resolve) => setTimeout(resolve, 500));
150
+ try {
151
+ await this.listServerTools(name);
152
+ entry.healthy = true;
153
+ logger.info(`[MCPHypervisor] Server "${name}" started (${entry.tools.length} tools)`);
154
+ }
155
+ catch (error) {
156
+ logger.warn(`[MCPHypervisor] Server "${name}" started but tool discovery failed: ${error instanceof Error ? error.message : String(error)}`);
157
+ // Still mark healthy if the process is alive (tools may not be supported)
158
+ entry.healthy = entry.process.exitCode === null;
159
+ }
160
+ }
161
+ /**
162
+ * Stop a running MCP server process.
163
+ */
164
+ async stopServer(name) {
165
+ const entry = this.servers.get(name);
166
+ if (!entry?.process)
167
+ return;
168
+ entry.process.kill('SIGTERM');
169
+ await new Promise((resolve) => setTimeout(resolve, 200));
170
+ if (entry.process.exitCode === null) {
171
+ entry.process.kill('SIGKILL');
172
+ }
173
+ entry.process = null;
174
+ entry.healthy = false;
175
+ entry.tools = [];
176
+ logger.info(`[MCPHypervisor] Stopped server: ${name}`);
177
+ }
178
+ /**
179
+ * Stop all running servers.
180
+ */
181
+ async stopAll() {
182
+ this.stopHealthCheckLoop();
183
+ await Promise.all(Array.from(this.servers.keys()).map((name) => this.stopServer(name)));
184
+ }
185
+ // ---------------------------------------------------------------------------
186
+ // JSON-RPC communication
187
+ // ---------------------------------------------------------------------------
188
+ /**
189
+ * Send a JSON-RPC request to a running server and await the response.
190
+ */
191
+ sendRequest(name, method, params) {
192
+ const entry = this.servers.get(name);
193
+ if (!entry?.process || entry.process.exitCode !== null) {
194
+ return Promise.reject(new Error(`Server "${name}" is not running`));
195
+ }
196
+ const id = ++this.requestCounter;
197
+ const request = {
198
+ jsonrpc: '2.0',
199
+ id,
200
+ method,
201
+ ...(params !== undefined && { params }),
202
+ };
203
+ return new Promise((resolve, reject) => {
204
+ const timer = setTimeout(() => {
205
+ this.pendingRequests.delete(id);
206
+ reject(new Error(`Request ${method} timed out after ${REQUEST_TIMEOUT_MS}ms`));
207
+ }, REQUEST_TIMEOUT_MS);
208
+ this.pendingRequests.set(id, { resolve, reject, timer });
209
+ try {
210
+ entry.process?.stdin?.write(`${JSON.stringify(request)}\n`);
211
+ }
212
+ catch (error) {
213
+ clearTimeout(timer);
214
+ this.pendingRequests.delete(id);
215
+ reject(error);
216
+ }
217
+ });
218
+ }
219
+ handleResponse(msg) {
220
+ const pending = this.pendingRequests.get(msg.id);
221
+ if (!pending)
222
+ return;
223
+ clearTimeout(pending.timer);
224
+ this.pendingRequests.delete(msg.id);
225
+ if (msg.error) {
226
+ pending.reject(new Error(`JSON-RPC error ${msg.error.code}: ${msg.error.message}`));
227
+ }
228
+ else {
229
+ pending.resolve(msg.result);
230
+ }
231
+ }
232
+ // ---------------------------------------------------------------------------
233
+ // Health checks
234
+ // ---------------------------------------------------------------------------
235
+ /**
236
+ * Ping a server — checks process liveness and sends a JSON-RPC `ping`.
237
+ * Updates `entry.healthy`.
238
+ */
239
+ async pingServer(name) {
240
+ const entry = this.servers.get(name);
241
+ if (!entry)
242
+ return false;
243
+ // Process liveness check
244
+ if (!entry.process || entry.process.exitCode !== null) {
245
+ entry.healthy = false;
246
+ return false;
247
+ }
248
+ entry.lastPingAt = Date.now();
249
+ try {
250
+ await this.sendRequest(name, 'ping');
251
+ entry.healthy = true;
252
+ return true;
253
+ }
254
+ catch {
255
+ // ping not supported by all servers — still healthy if process is alive
256
+ entry.healthy = entry.process.exitCode === null;
257
+ return entry.healthy;
258
+ }
259
+ }
260
+ // ---------------------------------------------------------------------------
261
+ // Tool discovery
262
+ // ---------------------------------------------------------------------------
263
+ /**
264
+ * Discover tools from a running server via JSON-RPC `tools/list`.
265
+ * Caches the result in the server entry.
266
+ */
267
+ async listServerTools(name) {
268
+ const entry = this.servers.get(name);
269
+ if (!entry)
270
+ throw new Error(`Unknown server: "${name}"`);
271
+ const result = await this.sendRequest(name, 'tools/list');
272
+ const tools = result?.tools ?? [];
273
+ entry.tools = tools;
274
+ return tools;
275
+ }
276
+ /**
277
+ * Return all tools from all healthy servers, namespaced as
278
+ * `@@mcp_{serverName}_{toolName}` to avoid collisions.
279
+ */
280
+ getAllTools() {
281
+ const tools = [];
282
+ for (const [serverName, entry] of this.servers) {
283
+ if (!entry.healthy)
284
+ continue;
285
+ for (const tool of entry.tools) {
286
+ tools.push({
287
+ namespacedName: `${MCP_TOOL_PREFIX}_${serverName}_${tool.name}`,
288
+ serverName,
289
+ tool,
290
+ });
291
+ }
292
+ }
293
+ return tools;
294
+ }
295
+ /**
296
+ * Call a tool on a running MCP server via JSON-RPC `tools/call`.
297
+ *
298
+ * @param serverName - The registered server name
299
+ * @param toolName - The tool name (without namespace prefix)
300
+ * @param args - Arguments to pass to the tool
301
+ */
302
+ async callTool(serverName, toolName, args) {
303
+ return this.sendRequest(serverName, 'tools/call', {
304
+ name: toolName,
305
+ arguments: args,
306
+ });
307
+ }
308
+ /**
309
+ * Return the health status of all registered servers.
310
+ */
311
+ getStatus() {
312
+ const status = {};
313
+ for (const [name, entry] of this.servers) {
314
+ status[name] = {
315
+ healthy: entry.healthy,
316
+ toolCount: entry.tools.length,
317
+ pid: entry.process?.pid ?? null,
318
+ };
319
+ }
320
+ return status;
321
+ }
322
+ // ---------------------------------------------------------------------------
323
+ // Health check loop
324
+ // ---------------------------------------------------------------------------
325
+ startHealthCheckLoop() {
326
+ this.healthCheckTimer = setInterval(async () => {
327
+ for (const [name] of this.servers) {
328
+ try {
329
+ await this.pingServer(name);
330
+ }
331
+ catch {
332
+ // Already handled inside pingServer
333
+ }
334
+ }
335
+ }, HEALTH_CHECK_INTERVAL_MS);
336
+ // Don't prevent process exit
337
+ this.healthCheckTimer.unref?.();
338
+ }
339
+ stopHealthCheckLoop() {
340
+ if (this.healthCheckTimer) {
341
+ clearInterval(this.healthCheckTimer);
342
+ this.healthCheckTimer = null;
343
+ }
344
+ }
345
+ // ---------------------------------------------------------------------------
346
+ // Testing utilities
347
+ // ---------------------------------------------------------------------------
348
+ /**
349
+ * Reset the singleton (for testing only).
350
+ * @internal
351
+ */
352
+ static _resetForTests() {
353
+ if (MCPHypervisor.instance) {
354
+ MCPHypervisor.instance.stopHealthCheckLoop();
355
+ MCPHypervisor.instance = null;
356
+ }
357
+ }
358
+ }
359
+ //# sourceMappingURL=hypervisor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hypervisor.js","sourceRoot":"","sources":["../src/hypervisor.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAAqB,KAAK,EAAE,MAAM,oBAAoB,CAAA;AAC7D,OAAO,EAAE,sBAAsB,EAAE,MAAM,2BAA2B,CAAA;AAClE,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAA;AAwD5D,gFAAgF;AAChF,YAAY;AACZ,gFAAgF;AAEhF,MAAM,wBAAwB,GAAG,MAAM,CAAA;AACvC,MAAM,kBAAkB,GAAG,KAAK,CAAA;AAChC,MAAM,eAAe,GAAG,OAAO,CAAA;AAE/B,gFAAgF;AAChF,gBAAgB;AAChB,gFAAgF;AAEhF;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,OAAO,aAAa;IAChB,MAAM,CAAC,QAAQ,GAAyB,IAAI,CAA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CAAA;gBAC7B,CAAC;gBAAC,MAAM,CAAC;oBACP,oCAAoC;gBACtC,CAAC;YACH,CAAC;QACH,CAAC,EAAE,wBAAwB,CAAC,CAAA;QAE5B,6BAA6B;QAC7B,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE,EAAE,CAAA;IACjC,CAAC;IAEO,mBAAmB;QACzB,IAAI,IAAI,CAAC,gBAAgB,EAAE,CAAC;YAC1B,aAAa,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAA;YACpC,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAA;QAC9B,CAAC;IACH,CAAC;IAED,8EAA8E;IAC9E,oBAAoB;IACpB,8EAA8E;IAE9E;;;OAGG;IACH,MAAM,CAAC,cAAc;QACnB,IAAI,aAAa,CAAC,QAAQ,EAAE,CAAC;YAC3B,aAAa,CAAC,QAAQ,CAAC,mBAAmB,EAAE,CAAA;YAC5C,aAAa,CAAC,QAAQ,GAAG,IAAI,CAAA;QAC/B,CAAC;IACH,CAAC"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @revealui/mcp
3
+ *
4
+ * Model Context Protocol integrations for RevealUI.
5
+ *
6
+ * Provides:
7
+ * - MCP adapter framework (Vercel, Stripe, Neon)
8
+ * - Database adapter (PGlite / PostgreSQL) with CRDT support
9
+ * - MCP contracts (Zod schemas for request/response/tool bridging)
10
+ * - MCP server launchers (code-validator, stripe, neon, etc.)
11
+ *
12
+ * @packageDocumentation
13
+ */
14
+ /**
15
+ * Check if the MCP package is licensed for use.
16
+ * Initializes the license cache from environment variables, then checks the tier.
17
+ * Returns false with a warning log if no Pro/Enterprise license is active.
18
+ */
19
+ export declare function checkMcpLicense(): Promise<boolean>;
20
+ export { type CrdtOperationsInsert, type CrdtOperationsRow, connectPglite, connectPostgres, createMcpDbClient, type McpDbClient, type QueryResult, } from './adapters/db.js';
21
+ export { getMcpConfig, type McpConfig as McpEnvConfig, type McpMetricsMode, } from './config/index.js';
22
+ export { agentDefinitionToAgentCard, agentDefinitionToMcpTools, contractsToolDefinitionToMcpTool, type MCPAdapterConfig, MCPAdapterConfigSchema, type MCPRequest, type MCPRequestOptions, MCPRequestOptionsSchema, MCPRequestSchema, type MCPResponse, type MCPResponseMetadata, MCPResponseMetadataSchema, MCPResponseSchema, mcpToolToContractsToolDefinition, } from './contracts.js';
23
+ export { MCPHypervisor, type MCPServerConfig, type MCPTool, type NamespacedTool, } from './hypervisor.js';
24
+ export { createMCPAdapter, disposeAllAdapters, generateIdempotencyKey, generateUniqueIdempotencyKey, MCPAdapter, type MCPConfig, NeonAdapter, StripeAdapter, VercelAdapter, } from './servers/adapter.js';
25
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAMH;;;;GAIG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAC,OAAO,CAAC,CAUxD;AAGD,OAAO,EACL,KAAK,oBAAoB,EACzB,KAAK,iBAAiB,EACtB,aAAa,EACb,eAAe,EACf,iBAAiB,EACjB,KAAK,WAAW,EAChB,KAAK,WAAW,GACjB,MAAM,kBAAkB,CAAA;AAEzB,OAAO,EACL,YAAY,EACZ,KAAK,SAAS,IAAI,YAAY,EAC9B,KAAK,cAAc,GACpB,MAAM,mBAAmB,CAAA;AAE1B,OAAO,EACL,0BAA0B,EAC1B,yBAAyB,EACzB,gCAAgC,EAChC,KAAK,gBAAgB,EACrB,sBAAsB,EACtB,KAAK,UAAU,EACf,KAAK,iBAAiB,EACtB,uBAAuB,EACvB,gBAAgB,EAChB,KAAK,WAAW,EAChB,KAAK,mBAAmB,EACxB,yBAAyB,EACzB,iBAAiB,EACjB,gCAAgC,GACjC,MAAM,gBAAgB,CAAA;AAEvB,OAAO,EACL,aAAa,EACb,KAAK,eAAe,EACpB,KAAK,OAAO,EACZ,KAAK,cAAc,GACpB,MAAM,iBAAiB,CAAA;AAExB,OAAO,EACL,gBAAgB,EAChB,kBAAkB,EAClB,sBAAsB,EACtB,4BAA4B,EAC5B,UAAU,EACV,KAAK,SAAS,EACd,WAAW,EACX,aAAa,EACb,aAAa,GACd,MAAM,sBAAsB,CAAA"}