@revealui/mcp 0.1.10 → 0.2.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 (54) hide show
  1. package/LICENSE.commercial +90 -0
  2. package/README.md +5 -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 +6 -2
  16. package/dist/index.d.ts.map +1 -1
  17. package/dist/index.js +8 -2
  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/factories/revealui-content.d.ts +85 -0
  35. package/dist/servers/factories/revealui-content.d.ts.map +1 -0
  36. package/dist/servers/factories/revealui-content.js +471 -0
  37. package/dist/servers/factories/revealui-content.js.map +1 -0
  38. package/dist/servers/revealui-content.d.ts +12 -18
  39. package/dist/servers/revealui-content.d.ts.map +1 -1
  40. package/dist/servers/revealui-content.js +14 -220
  41. package/dist/servers/revealui-content.js.map +1 -1
  42. package/dist/servers/revealui-memory.d.ts +24 -0
  43. package/dist/servers/revealui-memory.d.ts.map +1 -0
  44. package/dist/servers/revealui-memory.js +339 -0
  45. package/dist/servers/revealui-memory.js.map +1 -0
  46. package/dist/streamable-http.d.ts +72 -0
  47. package/dist/streamable-http.d.ts.map +1 -0
  48. package/dist/streamable-http.js +120 -0
  49. package/dist/streamable-http.js.map +1 -0
  50. package/package.json +24 -11
  51. package/dist/stores/postgres-idempotency.d.ts +0 -32
  52. package/dist/stores/postgres-idempotency.d.ts.map +0 -1
  53. package/dist/stores/postgres-idempotency.js +0 -63
  54. package/dist/stores/postgres-idempotency.js.map +0 -1
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Factory for the `revealui-content` MCP server.
3
+ *
4
+ * Dual-mode template (Stage 1 PR-1.2 of the MCP v1 plan): this module owns
5
+ * the Server construction + request-handler wiring, decoupled from any
6
+ * transport. The stdio launcher at `./revealui-content.ts` and a future HTTP
7
+ * launcher both consume `createRevealuiContentServer()` to ensure a single
8
+ * source of truth for the tool surface.
9
+ *
10
+ * Tools exposed:
11
+ * revealui_list_sites — list all sites in the RevealUI instance
12
+ * revealui_list_content — list content entries for a site/collection
13
+ * revealui_get_content — fetch a single content entry by ID
14
+ * revealui_list_users — list users (admin only)
15
+ * revealui_site_stats — per-site user + content counts
16
+ *
17
+ * Resources (Stage 4.1 + 4.2): every CollectionConfig with `mcpResource !==
18
+ * false` is surfaced as an MCP resource under `revealui-content://<slug>/
19
+ * <id>`. The factory resolves the effective set via three tiers:
20
+ *
21
+ * 1. Injected `collectionsProvider` — in-process consumers (admin, agent
22
+ * runtime) pass a function that reads directly from the admin registry.
23
+ * 2. HTTP introspection — fetches `${REVEALUI_API_URL}/api/mcp/collections`
24
+ * with the configured API key. Used by out-of-process consumers that
25
+ * can reach a running admin.
26
+ * 3. Curated fallback — `posts`, `pages`, `products`, `media` with
27
+ * well-known title fields. Used when neither 1 nor 2 is available
28
+ * (airgapped dev, admin offline, credentials missing).
29
+ *
30
+ * Credentials are supplied by the hypervisor (or HTTP launcher wrapper)
31
+ * via `setCredentials()`. Falls back to `REVEALUI_API_URL` +
32
+ * `REVEALUI_API_KEY` env vars when no override is set.
33
+ */
34
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
35
+ /**
36
+ * Set credential overrides for this server. Called by the hypervisor with
37
+ * resolved tenant credentials (or by an HTTP launcher before handing the
38
+ * server to the handler).
39
+ *
40
+ * Credentials set here are process-global (module-level state). Multi-tenant
41
+ * HTTP deployments that need per-session credentials should either:
42
+ * (a) instantiate the server inside `createServer` per call, passing the
43
+ * credentials into closure scope, OR
44
+ * (b) use the hypervisor's tenant-scoped credential resolver.
45
+ */
46
+ export declare function setCredentials(creds: Record<string, string>): void;
47
+ /**
48
+ * MCP-facing summary of a content collection. Wire-compatible with the shape
49
+ * returned by `GET /api/mcp/collections` on the admin app.
50
+ */
51
+ export interface CollectionMcpSummary {
52
+ /** Collection slug. */
53
+ slug: string;
54
+ /** Human-readable singular label (e.g. `Post`). */
55
+ label: string;
56
+ /** Human-readable plural label, when known. */
57
+ labelPlural?: string;
58
+ /**
59
+ * Resolved MCP-resource flag. Only collections with `mcpResource: true`
60
+ * are surfaced as resources.
61
+ */
62
+ mcpResource: boolean;
63
+ }
64
+ /**
65
+ * Injection point for in-process consumers. Returning `null` signals the
66
+ * factory to try the next tier (HTTP, then curated).
67
+ */
68
+ export type CollectionsProvider = () => Promise<CollectionMcpSummary[] | null>;
69
+ export interface CreateRevealuiContentServerOptions {
70
+ /**
71
+ * Optional provider used to resolve the list of collections exposed as
72
+ * MCP resources. When provided, skips HTTP introspection. In-process
73
+ * admin or agent-runtime consumers wire this to read the registry
74
+ * directly; out-of-process subprocess consumers leave it unset.
75
+ */
76
+ collectionsProvider?: CollectionsProvider;
77
+ }
78
+ /**
79
+ * Create a fresh `revealui-content` MCP Server instance. Safe to call
80
+ * multiple times — each call returns an independent Server with its own
81
+ * request handlers registered. Dual-mode launchers (stdio, Streamable HTTP)
82
+ * consume this factory; the factory itself is transport-agnostic.
83
+ */
84
+ export declare function createRevealuiContentServer(options?: CreateRevealuiContentServerOptions): Server;
85
+ //# sourceMappingURL=revealui-content.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revealui-content.d.ts","sourceRoot":"","sources":["../../../src/servers/factories/revealui-content.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AAkBnE;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAElE;AAkID;;;GAGG;AACH,MAAM,WAAW,oBAAoB;IACnC,uBAAuB;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,mDAAmD;IACnD,KAAK,EAAE,MAAM,CAAC;IACd,+CAA+C;IAC/C,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;;GAGG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,OAAO,CAAC,oBAAoB,EAAE,GAAG,IAAI,CAAC,CAAC;AAE/E,MAAM,WAAW,kCAAkC;IACjD;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,mBAAmB,CAAC;CAC3C;AAuID;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,OAAO,CAAC,EAAE,kCAAkC,GAAG,MAAM,CAyOhG"}
@@ -0,0 +1,471 @@
1
+ /**
2
+ * Factory for the `revealui-content` MCP server.
3
+ *
4
+ * Dual-mode template (Stage 1 PR-1.2 of the MCP v1 plan): this module owns
5
+ * the Server construction + request-handler wiring, decoupled from any
6
+ * transport. The stdio launcher at `./revealui-content.ts` and a future HTTP
7
+ * launcher both consume `createRevealuiContentServer()` to ensure a single
8
+ * source of truth for the tool surface.
9
+ *
10
+ * Tools exposed:
11
+ * revealui_list_sites — list all sites in the RevealUI instance
12
+ * revealui_list_content — list content entries for a site/collection
13
+ * revealui_get_content — fetch a single content entry by ID
14
+ * revealui_list_users — list users (admin only)
15
+ * revealui_site_stats — per-site user + content counts
16
+ *
17
+ * Resources (Stage 4.1 + 4.2): every CollectionConfig with `mcpResource !==
18
+ * false` is surfaced as an MCP resource under `revealui-content://<slug>/
19
+ * <id>`. The factory resolves the effective set via three tiers:
20
+ *
21
+ * 1. Injected `collectionsProvider` — in-process consumers (admin, agent
22
+ * runtime) pass a function that reads directly from the admin registry.
23
+ * 2. HTTP introspection — fetches `${REVEALUI_API_URL}/api/mcp/collections`
24
+ * with the configured API key. Used by out-of-process consumers that
25
+ * can reach a running admin.
26
+ * 3. Curated fallback — `posts`, `pages`, `products`, `media` with
27
+ * well-known title fields. Used when neither 1 nor 2 is available
28
+ * (airgapped dev, admin offline, credentials missing).
29
+ *
30
+ * Credentials are supplied by the hypervisor (or HTTP launcher wrapper)
31
+ * via `setCredentials()`. Falls back to `REVEALUI_API_URL` +
32
+ * `REVEALUI_API_KEY` env vars when no override is set.
33
+ */
34
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
35
+ import { CallToolRequestSchema, ListResourcesRequestSchema, ListToolsRequestSchema, ReadResourceRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
36
+ // ---------------------------------------------------------------------------
37
+ // Credential overrides (set by hypervisor / HTTP launcher)
38
+ // ---------------------------------------------------------------------------
39
+ let _credentialOverrides = {};
40
+ /**
41
+ * Set credential overrides for this server. Called by the hypervisor with
42
+ * resolved tenant credentials (or by an HTTP launcher before handing the
43
+ * server to the handler).
44
+ *
45
+ * Credentials set here are process-global (module-level state). Multi-tenant
46
+ * HTTP deployments that need per-session credentials should either:
47
+ * (a) instantiate the server inside `createServer` per call, passing the
48
+ * credentials into closure scope, OR
49
+ * (b) use the hypervisor's tenant-scoped credential resolver.
50
+ */
51
+ export function setCredentials(creds) {
52
+ _credentialOverrides = creds;
53
+ }
54
+ function resolveCredentials() {
55
+ const apiUrl = (_credentialOverrides.REVEALUI_API_URL ?? process.env.REVEALUI_API_URL)?.replace(/\/$/, '');
56
+ const apiKey = _credentialOverrides.REVEALUI_API_KEY ?? process.env.REVEALUI_API_KEY;
57
+ return { apiUrl, apiKey };
58
+ }
59
+ // ---------------------------------------------------------------------------
60
+ // API helpers (shared across tool handlers)
61
+ // ---------------------------------------------------------------------------
62
+ function apiHeaders(apiKey) {
63
+ return {
64
+ Authorization: `Bearer ${apiKey}`,
65
+ 'Content-Type': 'application/json',
66
+ 'User-Agent': 'RevealUI-MCP/1.0',
67
+ };
68
+ }
69
+ async function apiGet(baseUrl, apiKey, path, params) {
70
+ const url = new URL(`${baseUrl}${path}`);
71
+ if (params) {
72
+ for (const [k, v] of Object.entries(params))
73
+ url.searchParams.set(k, v);
74
+ }
75
+ const res = await fetch(url.toString(), { headers: apiHeaders(apiKey) });
76
+ const body = await res.json();
77
+ if (!res.ok) {
78
+ throw new Error(body.error ??
79
+ body.message ??
80
+ `API ${res.status}`);
81
+ }
82
+ return body;
83
+ }
84
+ // ---------------------------------------------------------------------------
85
+ // Tool definitions
86
+ // ---------------------------------------------------------------------------
87
+ const TOOLS = [
88
+ {
89
+ name: 'revealui_list_sites',
90
+ description: 'List all sites registered in the RevealUI instance.',
91
+ inputSchema: {
92
+ type: 'object',
93
+ properties: {
94
+ limit: { type: 'number', description: 'Max results to return (default: 20)', default: 20 },
95
+ page: {
96
+ type: 'number',
97
+ description: 'Page number for pagination (default: 1)',
98
+ default: 1,
99
+ },
100
+ },
101
+ },
102
+ },
103
+ {
104
+ name: 'revealui_list_content',
105
+ description: 'List content entries for a site from a given collection (e.g. posts, pages, products).',
106
+ inputSchema: {
107
+ type: 'object',
108
+ properties: {
109
+ site_id: { type: 'string', description: 'Site ID to query content from' },
110
+ collection: {
111
+ type: 'string',
112
+ description: 'Collection slug (e.g. "posts", "pages", "products")',
113
+ },
114
+ limit: { type: 'number', description: 'Max results (default: 20)', default: 20 },
115
+ page: { type: 'number', description: 'Page number (default: 1)', default: 1 },
116
+ status: { type: 'string', description: 'Filter by status: published, draft, archived' },
117
+ },
118
+ required: ['collection'],
119
+ },
120
+ },
121
+ {
122
+ name: 'revealui_get_content',
123
+ description: 'Fetch a single content entry by its ID.',
124
+ inputSchema: {
125
+ type: 'object',
126
+ properties: {
127
+ collection: { type: 'string', description: 'Collection slug (e.g. "posts")' },
128
+ id: { type: 'string', description: 'Content entry ID' },
129
+ },
130
+ required: ['collection', 'id'],
131
+ },
132
+ },
133
+ {
134
+ name: 'revealui_list_users',
135
+ description: 'List users registered in RevealUI. Requires admin API key. ' +
136
+ 'Returns email, role, and account status.',
137
+ inputSchema: {
138
+ type: 'object',
139
+ properties: {
140
+ site_id: { type: 'string', description: 'Filter users by site ID' },
141
+ limit: { type: 'number', description: 'Max results (default: 20)', default: 20 },
142
+ page: { type: 'number', description: 'Page number (default: 1)', default: 1 },
143
+ },
144
+ },
145
+ },
146
+ {
147
+ name: 'revealui_site_stats',
148
+ description: 'Get aggregate stats for a RevealUI site: user count, content count per collection, and license tier.',
149
+ inputSchema: {
150
+ type: 'object',
151
+ properties: {
152
+ site_id: {
153
+ type: 'string',
154
+ description: 'Site ID to fetch stats for (omit for global stats)',
155
+ },
156
+ },
157
+ },
158
+ },
159
+ ];
160
+ /**
161
+ * Curated fallback used when neither an injected provider nor HTTP
162
+ * introspection is available. These four collections exist in every admin
163
+ * instance shipped today and have stable well-known title fields.
164
+ */
165
+ const CURATED_FALLBACK = [
166
+ { slug: 'posts', label: 'Post', labelPlural: 'Posts', mcpResource: true },
167
+ { slug: 'pages', label: 'Page', labelPlural: 'Pages', mcpResource: true },
168
+ { slug: 'products', label: 'Product', labelPlural: 'Products', mcpResource: true },
169
+ { slug: 'media', label: 'Media', mcpResource: true },
170
+ ];
171
+ /**
172
+ * Well-known title-field overrides by slug. Collections listed here pick
173
+ * their title from the named field; unknown collections fall back to a
174
+ * cascade (`title` → `name` → `filename` → `label` → id).
175
+ */
176
+ const TITLE_FIELD_OVERRIDES = {
177
+ posts: 'title',
178
+ pages: 'title',
179
+ products: 'name',
180
+ media: 'filename',
181
+ };
182
+ const TITLE_FIELD_CASCADE = ['title', 'name', 'filename', 'label'];
183
+ /** URI scheme for Stage 4.1. Stage 4.2 leaves this stable; a `revealui://
184
+ * <tenant>/<collection>/<id>` variant is parked for a future design call. */
185
+ const RESOURCE_URI_PREFIX = 'revealui-content://';
186
+ /** Max rows per collection surfaced in a single `resources/list` response. */
187
+ const DEFAULT_RESOURCE_PAGE_SIZE = 50;
188
+ /** Extract rows from one of several shapes the RevealUI content API uses. */
189
+ function extractDocs(body) {
190
+ if (!body || typeof body !== 'object')
191
+ return [];
192
+ const b = body;
193
+ if (Array.isArray(b.docs))
194
+ return b.docs;
195
+ if (Array.isArray(b.items))
196
+ return b.items;
197
+ if (Array.isArray(b.data))
198
+ return b.data;
199
+ if (b.data && typeof b.data === 'object' && Array.isArray(b.data.docs)) {
200
+ return b.data.docs;
201
+ }
202
+ return [];
203
+ }
204
+ function pickTitle(row, collectionSlug) {
205
+ const override = TITLE_FIELD_OVERRIDES[collectionSlug];
206
+ if (override) {
207
+ const raw = row[override];
208
+ if (typeof raw === 'string' && raw.length > 0)
209
+ return raw;
210
+ }
211
+ for (const field of TITLE_FIELD_CASCADE) {
212
+ const raw = row[field];
213
+ if (typeof raw === 'string' && raw.length > 0)
214
+ return raw;
215
+ }
216
+ return String(row.id);
217
+ }
218
+ function resourceForRow(summary, row) {
219
+ const id = String(row.id);
220
+ const description = summary.labelPlural ?? `${summary.label} collection`;
221
+ return {
222
+ uri: `${RESOURCE_URI_PREFIX}${summary.slug}/${id}`,
223
+ name: `${summary.slug}/${pickTitle(row, summary.slug)}`,
224
+ description: `${description} (id: ${id})`,
225
+ mimeType: 'application/json',
226
+ };
227
+ }
228
+ function parseResourceUri(uri) {
229
+ if (!uri.startsWith(RESOURCE_URI_PREFIX))
230
+ return null;
231
+ const rest = uri.slice(RESOURCE_URI_PREFIX.length);
232
+ const slash = rest.indexOf('/');
233
+ if (slash < 1 || slash === rest.length - 1)
234
+ return null;
235
+ const collection = rest.slice(0, slash);
236
+ const id = rest.slice(slash + 1);
237
+ if (!/^[a-z][a-z0-9-]*$/.test(collection))
238
+ return null;
239
+ if (!/^[A-Za-z0-9_-]+$/.test(id))
240
+ return null;
241
+ return { collection, id };
242
+ }
243
+ /**
244
+ * Fetch collection summaries from the admin introspection endpoint.
245
+ * Returns `null` on any failure (network, non-200, malformed body) —
246
+ * callers fall back to the curated set.
247
+ */
248
+ async function fetchCollectionsFromAdmin(apiUrl, apiKey) {
249
+ try {
250
+ const res = await fetch(`${apiUrl}/api/mcp/collections`, {
251
+ headers: apiHeaders(apiKey),
252
+ });
253
+ if (!res.ok)
254
+ return null;
255
+ const body = (await res.json());
256
+ if (!Array.isArray(body.collections))
257
+ return null;
258
+ const out = [];
259
+ for (const raw of body.collections) {
260
+ if (!raw || typeof raw !== 'object')
261
+ continue;
262
+ const r = raw;
263
+ if (typeof r.slug !== 'string' || r.slug.length === 0)
264
+ continue;
265
+ if (typeof r.label !== 'string' || r.label.length === 0)
266
+ continue;
267
+ if (typeof r.mcpResource !== 'boolean')
268
+ continue;
269
+ out.push({
270
+ slug: r.slug,
271
+ label: r.label,
272
+ labelPlural: typeof r.labelPlural === 'string' ? r.labelPlural : undefined,
273
+ mcpResource: r.mcpResource,
274
+ });
275
+ }
276
+ return out;
277
+ // empty-catch-ok: network/auth/schema errors fall back to curated set
278
+ }
279
+ catch {
280
+ return null;
281
+ }
282
+ }
283
+ // ---------------------------------------------------------------------------
284
+ // Factory
285
+ // ---------------------------------------------------------------------------
286
+ /**
287
+ * Create a fresh `revealui-content` MCP Server instance. Safe to call
288
+ * multiple times — each call returns an independent Server with its own
289
+ * request handlers registered. Dual-mode launchers (stdio, Streamable HTTP)
290
+ * consume this factory; the factory itself is transport-agnostic.
291
+ */
292
+ export function createRevealuiContentServer(options) {
293
+ const server = new Server({ name: 'revealui-content', version: '1.0.0' }, { capabilities: { tools: {}, resources: {} } });
294
+ // Per-server memoization: resolve the effective collection set once and
295
+ // reuse across `resources/list` + `resources/read` for the lifetime of the
296
+ // server instance. Avoids double-fetching on every read.
297
+ let cachedCollections = null;
298
+ async function resolveCollections() {
299
+ if (cachedCollections)
300
+ return cachedCollections;
301
+ // Tier 1: injected provider (in-process consumers).
302
+ if (options?.collectionsProvider) {
303
+ const fromProvider = await options.collectionsProvider().catch(() => null);
304
+ if (fromProvider) {
305
+ cachedCollections = fromProvider.filter((c) => c.mcpResource);
306
+ return cachedCollections;
307
+ }
308
+ }
309
+ // Tier 2: HTTP introspection against admin.
310
+ const { apiUrl, apiKey } = resolveCredentials();
311
+ if (apiUrl && apiKey) {
312
+ const fromHttp = await fetchCollectionsFromAdmin(apiUrl, apiKey);
313
+ if (fromHttp) {
314
+ cachedCollections = fromHttp.filter((c) => c.mcpResource);
315
+ return cachedCollections;
316
+ }
317
+ }
318
+ // Tier 3: curated fallback.
319
+ cachedCollections = [...CURATED_FALLBACK];
320
+ return cachedCollections;
321
+ }
322
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS }));
323
+ // -------------------------------------------------------------------------
324
+ // Resources (Stage 4.1 + 4.2)
325
+ // -------------------------------------------------------------------------
326
+ server.setRequestHandler(ListResourcesRequestSchema, async () => {
327
+ const { apiUrl, apiKey } = resolveCredentials();
328
+ if (!(apiUrl && apiKey)) {
329
+ // Without credentials the server can't enumerate rows; advertise an
330
+ // empty list rather than erroring — clients still see the resources
331
+ // capability and can retry once creds are set.
332
+ return { resources: [] };
333
+ }
334
+ const collections = await resolveCollections();
335
+ const resources = [];
336
+ for (const collection of collections) {
337
+ try {
338
+ const body = await apiGet(apiUrl, apiKey, `/api/${collection.slug}`, {
339
+ limit: String(DEFAULT_RESOURCE_PAGE_SIZE),
340
+ page: '1',
341
+ });
342
+ for (const row of extractDocs(body)) {
343
+ resources.push(resourceForRow(collection, row));
344
+ }
345
+ }
346
+ catch {
347
+ // empty-catch-ok: an unavailable collection shouldn't blank-out the entire resource list
348
+ }
349
+ }
350
+ return { resources };
351
+ });
352
+ server.setRequestHandler(ReadResourceRequestSchema, async (request) => {
353
+ const parsed = parseResourceUri(request.params.uri);
354
+ if (!parsed) {
355
+ throw new Error(`Unknown resource URI (expected ${RESOURCE_URI_PREFIX}<collection>/<id>): ${request.params.uri}`);
356
+ }
357
+ const collections = await resolveCollections();
358
+ const collection = collections.find((c) => c.slug === parsed.collection);
359
+ if (!collection) {
360
+ throw new Error(`Collection is not exposed as a resource: ${parsed.collection}`);
361
+ }
362
+ const { apiUrl, apiKey } = resolveCredentials();
363
+ if (!(apiUrl && apiKey)) {
364
+ throw new Error('REVEALUI_API_URL and REVEALUI_API_KEY must be set');
365
+ }
366
+ const row = await apiGet(apiUrl, apiKey, `/api/${parsed.collection}/${parsed.id}`);
367
+ return {
368
+ contents: [
369
+ {
370
+ uri: request.params.uri,
371
+ mimeType: 'application/json',
372
+ text: JSON.stringify(row, null, 2),
373
+ },
374
+ ],
375
+ };
376
+ });
377
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
378
+ const startTime = Date.now();
379
+ const toolName = request.params.name;
380
+ const { apiUrl, apiKey } = resolveCredentials();
381
+ if (!(apiUrl && apiKey)) {
382
+ return {
383
+ content: [
384
+ { type: 'text', text: 'Error: REVEALUI_API_URL and REVEALUI_API_KEY must be set' },
385
+ ],
386
+ isError: true,
387
+ };
388
+ }
389
+ try {
390
+ let data;
391
+ switch (toolName) {
392
+ case 'revealui_list_sites': {
393
+ const { limit = 20, page = 1 } = request.params.arguments;
394
+ data = await apiGet(apiUrl, apiKey, '/api/sites', {
395
+ limit: String(limit),
396
+ page: String(page),
397
+ });
398
+ break;
399
+ }
400
+ case 'revealui_list_content': {
401
+ const { site_id, collection, limit = 20, page = 1, status, } = request.params.arguments;
402
+ const params = {
403
+ limit: String(limit),
404
+ page: String(page),
405
+ };
406
+ if (site_id)
407
+ params.siteId = site_id;
408
+ if (status)
409
+ params.status = status;
410
+ data = await apiGet(apiUrl, apiKey, `/api/${collection}`, params);
411
+ break;
412
+ }
413
+ case 'revealui_get_content': {
414
+ const { collection, id } = request.params.arguments;
415
+ data = await apiGet(apiUrl, apiKey, `/api/${collection}/${id}`);
416
+ break;
417
+ }
418
+ case 'revealui_list_users': {
419
+ const { site_id, limit = 20, page = 1, } = request.params.arguments;
420
+ const params = {
421
+ limit: String(limit),
422
+ page: String(page),
423
+ };
424
+ if (site_id)
425
+ params.siteId = site_id;
426
+ data = await apiGet(apiUrl, apiKey, '/api/users', params);
427
+ break;
428
+ }
429
+ case 'revealui_site_stats': {
430
+ const { site_id } = request.params.arguments;
431
+ const params = {};
432
+ if (site_id)
433
+ params.siteId = site_id;
434
+ data = await apiGet(apiUrl, apiKey, '/api/health', params);
435
+ break;
436
+ }
437
+ default:
438
+ return {
439
+ content: [{ type: 'text', text: `Error: Unknown tool: ${toolName}` }],
440
+ isError: true,
441
+ };
442
+ }
443
+ return {
444
+ content: [
445
+ {
446
+ type: 'text',
447
+ text: JSON.stringify({
448
+ data,
449
+ _meta: {
450
+ durationMs: Date.now() - startTime,
451
+ server: 'revealui-content',
452
+ tool: toolName,
453
+ timestamp: new Date().toISOString(),
454
+ },
455
+ }, null, 2),
456
+ },
457
+ ],
458
+ };
459
+ }
460
+ catch (err) {
461
+ return {
462
+ content: [
463
+ { type: 'text', text: `Error: ${err instanceof Error ? err.message : String(err)}` },
464
+ ],
465
+ isError: true,
466
+ };
467
+ }
468
+ });
469
+ return server;
470
+ }
471
+ //# sourceMappingURL=revealui-content.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revealui-content.js","sourceRoot":"","sources":["../../../src/servers/factories/revealui-content.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAEL,qBAAqB,EACrB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ACF;qBACF;iBACF;aACF,CAAC;QACJ,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO;gBACL,OAAO,EAAE;oBACP,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,EAAE;iBACrF;gBACD,OAAO,EAAE,IAAI;aACd,CAAC;QACJ,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -1,25 +1,19 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * RevealUI Content MCP Server
3
+ * RevealUI Content MCP Server — stdio launcher.
4
4
  *
5
- * Model Context Protocol server that gives AI agents read/write access to
6
- * RevealUI admin content via the RevealUI REST API. Useful for agents that need
7
- * to query site data, list content, manage users, or inspect deployment state.
5
+ * Thin wrapper around `createRevealuiContentServer()` (see
6
+ * `./revealui-content-factory.ts` for the tool surface). This file exists
7
+ * purely to run the server as a stdio subprocess the canonical deployment
8
+ * for local dev, Claude Code integration, and the hypervisor's
9
+ * `spawn()`-based tool-discovery pipeline.
8
10
  *
9
- * Environment:
10
- * REVEALUI_API_URL - Base URL of the RevealUI API (e.g. https://api.mysite.com)
11
- * REVEALUI_API_KEY - API key for authenticating with the RevealUI API
11
+ * For HTTP / serverless / in-process deployment, import the factory
12
+ * directly and wrap it via `createNodeStreamableHttpHandler` from
13
+ * `@revealui/mcp/streamable-http`.
12
14
  *
13
- * Tools:
14
- * revealui_list_sites - List all sites in the RevealUI instance
15
- * revealui_list_content - List content entries for a site and collection
16
- * revealui_get_content - Fetch a single content entry by ID
17
- * revealui_list_users - List users (admin only)
18
- * revealui_site_stats - Get user + content counts for a site
15
+ * Re-exports `setCredentials` for hypervisor compatibility — existing
16
+ * tenant-scoped credential resolution continues to work unchanged.
19
17
  */
20
- /**
21
- * Set credential overrides for this server.
22
- * Called by the Hypervisor with resolved tenant credentials.
23
- */
24
- export declare function setCredentials(creds: Record<string, string>): void;
18
+ export { setCredentials } from './factories/revealui-content.js';
25
19
  //# sourceMappingURL=revealui-content.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"revealui-content.d.ts","sourceRoot":"","sources":["../../src/servers/revealui-content.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;GAiBG;AAmBH;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAElE"}
1
+ {"version":3,"file":"revealui-content.d.ts","sourceRoot":"","sources":["../../src/servers/revealui-content.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;GAeG;AAOH,OAAO,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC"}