@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
@@ -1,236 +1,30 @@
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
- import { Server } from '@modelcontextprotocol/sdk/server/index.js';
21
18
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
22
- import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
23
19
  import { logger } from '@revealui/core/observability/logger';
24
20
  import { checkMcpLicense } from '../index.js';
25
- // ---------------------------------------------------------------------------
26
- // Credential overrides (set by Hypervisor before tool invocations)
27
- // ---------------------------------------------------------------------------
28
- let _credentialOverrides = {};
29
- /**
30
- * Set credential overrides for this server.
31
- * Called by the Hypervisor with resolved tenant credentials.
32
- */
33
- export function setCredentials(creds) {
34
- _credentialOverrides = creds;
35
- }
36
- // ---------------------------------------------------------------------------
37
- // API helpers
38
- // ---------------------------------------------------------------------------
39
- function apiHeaders(apiKey) {
40
- return {
41
- Authorization: `Bearer ${apiKey}`,
42
- 'Content-Type': 'application/json',
43
- 'User-Agent': 'RevealUI-MCP/1.0',
44
- };
45
- }
46
- async function apiGet(baseUrl, apiKey, path, params) {
47
- const url = new URL(`${baseUrl}${path}`);
48
- if (params) {
49
- for (const [k, v] of Object.entries(params))
50
- url.searchParams.set(k, v);
51
- }
52
- const res = await fetch(url.toString(), { headers: apiHeaders(apiKey) });
53
- const body = await res.json();
54
- if (!res.ok) {
55
- throw new Error(body.error ??
56
- body.message ??
57
- `API ${res.status}`);
58
- }
59
- return body;
60
- }
61
- // ---------------------------------------------------------------------------
62
- // Server
63
- // ---------------------------------------------------------------------------
64
- const server = new Server({ name: 'revealui-content', version: '1.0.0' }, { capabilities: { tools: {} } });
65
- const TOOLS = [
66
- {
67
- name: 'revealui_list_sites',
68
- description: 'List all sites registered in the RevealUI instance.',
69
- inputSchema: {
70
- type: 'object',
71
- properties: {
72
- limit: { type: 'number', description: 'Max results to return (default: 20)', default: 20 },
73
- page: {
74
- type: 'number',
75
- description: 'Page number for pagination (default: 1)',
76
- default: 1,
77
- },
78
- },
79
- },
80
- },
81
- {
82
- name: 'revealui_list_content',
83
- description: 'List content entries for a site from a given collection (e.g. posts, pages, products).',
84
- inputSchema: {
85
- type: 'object',
86
- properties: {
87
- site_id: { type: 'string', description: 'Site ID to query content from' },
88
- collection: {
89
- type: 'string',
90
- description: 'Collection slug (e.g. "posts", "pages", "products")',
91
- },
92
- limit: { type: 'number', description: 'Max results (default: 20)', default: 20 },
93
- page: { type: 'number', description: 'Page number (default: 1)', default: 1 },
94
- status: { type: 'string', description: 'Filter by status: published, draft, archived' },
95
- },
96
- required: ['collection'],
97
- },
98
- },
99
- {
100
- name: 'revealui_get_content',
101
- description: 'Fetch a single content entry by its ID.',
102
- inputSchema: {
103
- type: 'object',
104
- properties: {
105
- collection: { type: 'string', description: 'Collection slug (e.g. "posts")' },
106
- id: { type: 'string', description: 'Content entry ID' },
107
- },
108
- required: ['collection', 'id'],
109
- },
110
- },
111
- {
112
- name: 'revealui_list_users',
113
- description: 'List users registered in RevealUI. Requires admin API key. ' +
114
- 'Returns email, role, and account status.',
115
- inputSchema: {
116
- type: 'object',
117
- properties: {
118
- site_id: { type: 'string', description: 'Filter users by site ID' },
119
- limit: { type: 'number', description: 'Max results (default: 20)', default: 20 },
120
- page: { type: 'number', description: 'Page number (default: 1)', default: 1 },
121
- },
122
- },
123
- },
124
- {
125
- name: 'revealui_site_stats',
126
- description: 'Get aggregate stats for a RevealUI site: user count, content count per collection, and license tier.',
127
- inputSchema: {
128
- type: 'object',
129
- properties: {
130
- site_id: {
131
- type: 'string',
132
- description: 'Site ID to fetch stats for (omit for global stats)',
133
- },
134
- },
135
- },
136
- },
137
- ];
138
- server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS }));
139
- server.setRequestHandler(CallToolRequestSchema, async (request) => {
140
- const startTime = Date.now();
141
- const toolName = request.params.name;
142
- const apiUrl = (_credentialOverrides.REVEALUI_API_URL ?? process.env.REVEALUI_API_URL)?.replace(/\/$/, '');
143
- const apiKey = _credentialOverrides.REVEALUI_API_KEY ?? process.env.REVEALUI_API_KEY;
144
- if (!(apiUrl && apiKey)) {
145
- return {
146
- content: [{ type: 'text', text: 'Error: REVEALUI_API_URL and REVEALUI_API_KEY must be set' }],
147
- isError: true,
148
- };
149
- }
150
- try {
151
- let data;
152
- switch (toolName) {
153
- case 'revealui_list_sites': {
154
- const { limit = 20, page = 1 } = request.params.arguments;
155
- data = await apiGet(apiUrl, apiKey, '/api/sites', {
156
- limit: String(limit),
157
- page: String(page),
158
- });
159
- break;
160
- }
161
- case 'revealui_list_content': {
162
- const { site_id, collection, limit = 20, page = 1, status, } = request.params.arguments;
163
- const params = {
164
- limit: String(limit),
165
- page: String(page),
166
- };
167
- if (site_id)
168
- params.siteId = site_id;
169
- if (status)
170
- params.status = status;
171
- data = await apiGet(apiUrl, apiKey, `/api/${collection}`, params);
172
- break;
173
- }
174
- case 'revealui_get_content': {
175
- const { collection, id } = request.params.arguments;
176
- data = await apiGet(apiUrl, apiKey, `/api/${collection}/${id}`);
177
- break;
178
- }
179
- case 'revealui_list_users': {
180
- const { site_id, limit = 20, page = 1, } = request.params.arguments;
181
- const params = {
182
- limit: String(limit),
183
- page: String(page),
184
- };
185
- if (site_id)
186
- params.siteId = site_id;
187
- data = await apiGet(apiUrl, apiKey, '/api/users', params);
188
- break;
189
- }
190
- case 'revealui_site_stats': {
191
- const { site_id } = request.params.arguments;
192
- const params = {};
193
- if (site_id)
194
- params.siteId = site_id;
195
- data = await apiGet(apiUrl, apiKey, '/api/health', params);
196
- break;
197
- }
198
- default:
199
- return {
200
- content: [{ type: 'text', text: `Error: Unknown tool: ${toolName}` }],
201
- isError: true,
202
- };
203
- }
204
- return {
205
- content: [
206
- {
207
- type: 'text',
208
- text: JSON.stringify({
209
- data,
210
- _meta: {
211
- durationMs: Date.now() - startTime,
212
- server: 'revealui-content',
213
- tool: toolName,
214
- timestamp: new Date().toISOString(),
215
- },
216
- }, null, 2),
217
- },
218
- ],
219
- };
220
- }
221
- catch (err) {
222
- return {
223
- content: [
224
- { type: 'text', text: `Error: ${err instanceof Error ? err.message : String(err)}` },
225
- ],
226
- isError: true,
227
- };
228
- }
229
- });
21
+ import { createRevealuiContentServer } from './factories/revealui-content.js';
22
+ export { setCredentials } from './factories/revealui-content.js';
230
23
  async function main() {
231
24
  if (!(await checkMcpLicense())) {
232
25
  process.exit(1);
233
26
  }
27
+ const server = createRevealuiContentServer();
234
28
  const transport = new StdioServerTransport();
235
29
  await server.connect(transport);
236
30
  }
@@ -1 +1 @@
1
- {"version":3,"file":"revealui-content.js","sourceRoot":"","sources":["../../src/servers/revealui-content.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAEL,qBAAqB,EACrB,sBAAsB,GAEvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,8EAA8E;AAC9E,mEAAmE;AACnE,8EAA8E;AAE9E,IAAI,oBAAoB,GAA2B,EAAE,CAAC;AAEtD;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAA6B;IAC1D,oBAAoB,GAAG,KAAK,CAAC;AAC/B,CAAC;AAED,8EAA8E;AAC9E,cAAc;AACd,8EAA8E;AAE9E,SAAS,UAAU,CAAC,MAAc;IAChC,OAAO;QACL,aAAa,EAAE,UAAU,MAAM,EAAE;QACjC,cAAc,EAAE,kBAAkB;QAClC,YAAY,EAAE,kBAAkB;KACjC,CAAC;AACJ,CAAC;AAED,KAAK,UAAU,MAAM,CACnB,OAAe,EACf,MAAc,EACd,IAAY,EACZ,MAA+B;IAE/B,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,OAAO,GAAG,IAAI,EAAE,CAAC,CAAC;IACzC,IAAI,MAAM,EAAE,CAAC;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AAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IACD,MAAM,MAAM,GAAG,2BAA2B,EAAE,CAAC;IAC7C,MAAM,SAAS,GAAG,IAAI,oBAAoB,EAAE,CAAC;IAC7C,MAAM,MAAM,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;AAClC,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;IACnB,MAAM,CAAC,KAAK,CAAC,4BAA4B,EAAE,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;IAChG,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * RevealUI Memory MCP Server
4
+ *
5
+ * Model Context Protocol server that exposes multi-agent shared memory tools.
6
+ * Gives any MCP-compatible agent (Claude Desktop, Cursor, Forge customers)
7
+ * access to shared facts, Yjs scratchpads, and reconciled memories.
8
+ *
9
+ * Environment:
10
+ * REVEALUI_API_URL - Admin API base URL (e.g. https://admin.revealui.com)
11
+ * REVEALUI_API_TOKEN - Device token for authenticated API calls
12
+ *
13
+ * Tools:
14
+ * memory_publish_fact - Publish a discovery to the shared fact log
15
+ * memory_list_facts - List facts for a coordination session
16
+ * memory_create_scratchpad - Create a new shared Yjs scratchpad
17
+ * memory_patch_scratchpad - Apply a structured patch to a scratchpad
18
+ * memory_read_scratchpad - Read current scratchpad content
19
+ * memory_share - Share a memory with all agents in a session
20
+ * memory_list_shared - List shared/reconciled memories for a session
21
+ * memory_reconcile - Trigger LLM reconciliation of shared facts
22
+ */
23
+ export declare function setCredentials(creds: Record<string, string>): void;
24
+ //# sourceMappingURL=revealui-memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revealui-memory.d.ts","sourceRoot":"","sources":["../../src/servers/revealui-memory.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AAmBH,wBAAgB,cAAc,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAElE"}
@@ -0,0 +1,339 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * RevealUI Memory MCP Server
4
+ *
5
+ * Model Context Protocol server that exposes multi-agent shared memory tools.
6
+ * Gives any MCP-compatible agent (Claude Desktop, Cursor, Forge customers)
7
+ * access to shared facts, Yjs scratchpads, and reconciled memories.
8
+ *
9
+ * Environment:
10
+ * REVEALUI_API_URL - Admin API base URL (e.g. https://admin.revealui.com)
11
+ * REVEALUI_API_TOKEN - Device token for authenticated API calls
12
+ *
13
+ * Tools:
14
+ * memory_publish_fact - Publish a discovery to the shared fact log
15
+ * memory_list_facts - List facts for a coordination session
16
+ * memory_create_scratchpad - Create a new shared Yjs scratchpad
17
+ * memory_patch_scratchpad - Apply a structured patch to a scratchpad
18
+ * memory_read_scratchpad - Read current scratchpad content
19
+ * memory_share - Share a memory with all agents in a session
20
+ * memory_list_shared - List shared/reconciled memories for a session
21
+ * memory_reconcile - Trigger LLM reconciliation of shared facts
22
+ */
23
+ import { Server } from '@modelcontextprotocol/sdk/server/index.js';
24
+ import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
25
+ import { CallToolRequestSchema, ListToolsRequestSchema, } from '@modelcontextprotocol/sdk/types.js';
26
+ import { logger } from '@revealui/core/observability/logger';
27
+ import { checkMcpLicense } from '../index.js';
28
+ // ---------------------------------------------------------------------------
29
+ // Credential overrides (set by Hypervisor before tool invocations)
30
+ // ---------------------------------------------------------------------------
31
+ let _credentialOverrides = {};
32
+ export function setCredentials(creds) {
33
+ _credentialOverrides = creds;
34
+ }
35
+ // ---------------------------------------------------------------------------
36
+ // API helpers
37
+ // ---------------------------------------------------------------------------
38
+ function getConfig() {
39
+ const apiUrl = _credentialOverrides.REVEALUI_API_URL ?? process.env.REVEALUI_API_URL;
40
+ const token = _credentialOverrides.REVEALUI_API_TOKEN ?? process.env.REVEALUI_API_TOKEN;
41
+ if (!(apiUrl && token)) {
42
+ throw new Error('REVEALUI_API_URL and REVEALUI_API_TOKEN must be set');
43
+ }
44
+ return { apiUrl, token };
45
+ }
46
+ function authHeaders(token) {
47
+ return {
48
+ Authorization: `Bearer ${token}`,
49
+ 'Content-Type': 'application/json',
50
+ 'User-Agent': 'RevealUI-MCP-Memory/0.1.0',
51
+ };
52
+ }
53
+ async function apiPost(path, body) {
54
+ const { apiUrl, token } = getConfig();
55
+ const res = await fetch(`${apiUrl}${path}`, {
56
+ method: 'POST',
57
+ headers: authHeaders(token),
58
+ body: JSON.stringify(body),
59
+ });
60
+ const data = await res.json();
61
+ if (!res.ok) {
62
+ throw new Error(data.error ?? `API error ${res.status}`);
63
+ }
64
+ return data;
65
+ }
66
+ async function apiGet(path, params) {
67
+ const { apiUrl, token } = getConfig();
68
+ const url = new URL(`${apiUrl}${path}`);
69
+ if (params) {
70
+ for (const [k, v] of Object.entries(params))
71
+ url.searchParams.set(k, v);
72
+ }
73
+ const res = await fetch(url.toString(), { headers: authHeaders(token) });
74
+ const data = await res.json();
75
+ if (!res.ok) {
76
+ throw new Error(data.error ?? `API error ${res.status}`);
77
+ }
78
+ return data;
79
+ }
80
+ // ---------------------------------------------------------------------------
81
+ // Server
82
+ // ---------------------------------------------------------------------------
83
+ const server = new Server({ name: 'revealui-memory', version: '0.1.0' }, { capabilities: { tools: {} } });
84
+ const TOOLS = [
85
+ // Layer 1: Shared Fact Log
86
+ {
87
+ name: 'memory_publish_fact',
88
+ description: 'Publish a discovery to the shared fact log. All agents in the same ' +
89
+ 'coordination session see it in real-time via ElectricSQL.',
90
+ inputSchema: {
91
+ type: 'object',
92
+ properties: {
93
+ session_id: { type: 'string', description: 'Coordination session ID' },
94
+ agent_id: { type: 'string', description: 'Agent publishing this fact' },
95
+ content: { type: 'string', description: 'The fact content' },
96
+ fact_type: {
97
+ type: 'string',
98
+ description: 'Type: discovery, bug, decision, warning, question, answer',
99
+ enum: ['discovery', 'bug', 'decision', 'warning', 'question', 'answer'],
100
+ },
101
+ confidence: { type: 'number', description: 'Confidence 0-1 (default: 1.0)' },
102
+ tags: {
103
+ type: 'array',
104
+ items: { type: 'string' },
105
+ description: 'Tags for grouping and filtering',
106
+ },
107
+ source_ref: {
108
+ type: 'object',
109
+ description: 'Source reference (file path, line number, etc.)',
110
+ },
111
+ },
112
+ required: ['session_id', 'agent_id', 'content', 'fact_type'],
113
+ },
114
+ },
115
+ {
116
+ name: 'memory_list_facts',
117
+ description: 'List shared facts for a coordination session.',
118
+ inputSchema: {
119
+ type: 'object',
120
+ properties: {
121
+ session_id: { type: 'string', description: 'Coordination session ID' },
122
+ },
123
+ required: ['session_id'],
124
+ },
125
+ },
126
+ // Layer 2: Yjs Scratchpad
127
+ {
128
+ name: 'memory_create_scratchpad',
129
+ description: 'Create a new shared Yjs scratchpad document. Use set_key patch type ' +
130
+ 'to initialize with a title.',
131
+ inputSchema: {
132
+ type: 'object',
133
+ properties: {
134
+ document_id: { type: 'string', description: 'Unique document ID' },
135
+ agent_id: { type: 'string', description: 'Agent creating the scratchpad' },
136
+ title: { type: 'string', description: 'Initial title for the scratchpad' },
137
+ },
138
+ required: ['document_id', 'agent_id'],
139
+ },
140
+ },
141
+ {
142
+ name: 'memory_patch_scratchpad',
143
+ description: 'Apply a structured patch to a shared Yjs scratchpad. Patches are ' +
144
+ 'applied server-side and synced to all subscribers via Electric.',
145
+ inputSchema: {
146
+ type: 'object',
147
+ properties: {
148
+ document_id: { type: 'string', description: 'Scratchpad document ID' },
149
+ agent_id: { type: 'string', description: 'Agent submitting the patch' },
150
+ patch_type: {
151
+ type: 'string',
152
+ description: 'Type of edit',
153
+ enum: ['append_section', 'append_item', 'replace_section', 'set_key'],
154
+ },
155
+ path: { type: 'string', description: 'Section path (e.g. "findings" or "plan.phase1")' },
156
+ content: { type: 'string', description: 'Content to insert or replace' },
157
+ },
158
+ required: ['document_id', 'agent_id', 'patch_type', 'path', 'content'],
159
+ },
160
+ },
161
+ {
162
+ name: 'memory_read_scratchpad',
163
+ description: 'Read the current content of a shared Yjs scratchpad as JSON.',
164
+ inputSchema: {
165
+ type: 'object',
166
+ properties: {
167
+ document_id: { type: 'string', description: 'Scratchpad document ID' },
168
+ },
169
+ required: ['document_id'],
170
+ },
171
+ },
172
+ // Layer 3: Shared Memory + Reconciliation
173
+ {
174
+ name: 'memory_share',
175
+ description: 'Share a memory with all agents in a coordination session. Creates a ' +
176
+ 'shared agent_memories entry synced via Electric.',
177
+ inputSchema: {
178
+ type: 'object',
179
+ properties: {
180
+ session_scope: { type: 'string', description: 'Coordination session scope' },
181
+ agent_id: { type: 'string', description: 'Agent sharing this memory' },
182
+ site_id: { type: 'string', description: 'Site ID for ownership' },
183
+ content: { type: 'string', description: 'Memory content' },
184
+ type: {
185
+ type: 'string',
186
+ description: 'Memory type',
187
+ enum: [
188
+ 'fact',
189
+ 'preference',
190
+ 'decision',
191
+ 'feedback',
192
+ 'example',
193
+ 'correction',
194
+ 'skill',
195
+ 'warning',
196
+ ],
197
+ },
198
+ source: { type: 'object', description: 'Source metadata' },
199
+ },
200
+ required: ['session_scope', 'agent_id', 'site_id', 'content', 'type', 'source'],
201
+ },
202
+ },
203
+ {
204
+ name: 'memory_list_shared',
205
+ description: 'List shared and reconciled memories for a coordination session.',
206
+ inputSchema: {
207
+ type: 'object',
208
+ properties: {
209
+ session_scope: { type: 'string', description: 'Coordination session scope' },
210
+ },
211
+ required: ['session_scope'],
212
+ },
213
+ },
214
+ {
215
+ name: 'memory_reconcile',
216
+ description: 'Trigger reconciliation of shared facts. Deduplicates, resolves ' +
217
+ 'contradictions, and produces canonical reconciled memories.',
218
+ inputSchema: {
219
+ type: 'object',
220
+ properties: {
221
+ session_id: { type: 'string', description: 'Coordination session ID' },
222
+ site_id: { type: 'string', description: 'Site ID for reconciled memories' },
223
+ },
224
+ required: ['session_id', 'site_id'],
225
+ },
226
+ },
227
+ ];
228
+ server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: TOOLS }));
229
+ server.setRequestHandler(CallToolRequestSchema, async (request) => {
230
+ const startTime = Date.now();
231
+ const toolName = request.params.name;
232
+ try {
233
+ // Validate credentials early
234
+ getConfig();
235
+ }
236
+ catch {
237
+ return {
238
+ content: [
239
+ { type: 'text', text: 'Error: REVEALUI_API_URL and REVEALUI_API_TOKEN must be set' },
240
+ ],
241
+ isError: true,
242
+ };
243
+ }
244
+ try {
245
+ let data;
246
+ switch (toolName) {
247
+ // Layer 1
248
+ case 'memory_publish_fact': {
249
+ const args = request.params.arguments;
250
+ data = await apiPost('/api/sync/shared-facts', args);
251
+ break;
252
+ }
253
+ case 'memory_list_facts': {
254
+ const { session_id } = request.params.arguments;
255
+ data = await apiGet('/api/shapes/shared-facts', { session_id });
256
+ break;
257
+ }
258
+ // Layer 2
259
+ case 'memory_create_scratchpad': {
260
+ const { document_id, agent_id, title } = request.params.arguments;
261
+ data = await apiPost('/api/sync/yjs-document-patches', {
262
+ document_id,
263
+ agent_id,
264
+ patch_type: 'set_key',
265
+ path: 'title',
266
+ content: title ?? 'Shared Scratchpad',
267
+ });
268
+ break;
269
+ }
270
+ case 'memory_patch_scratchpad': {
271
+ const args = request.params.arguments;
272
+ data = await apiPost('/api/sync/yjs-document-patches', args);
273
+ break;
274
+ }
275
+ case 'memory_read_scratchpad': {
276
+ const { document_id } = request.params.arguments;
277
+ data = await apiGet('/api/shapes/yjs-documents', { document_id });
278
+ break;
279
+ }
280
+ // Layer 3
281
+ case 'memory_share': {
282
+ const args = request.params.arguments;
283
+ data = await apiPost('/api/sync/shared-memories', args);
284
+ break;
285
+ }
286
+ case 'memory_list_shared': {
287
+ const { session_scope } = request.params.arguments;
288
+ data = await apiGet('/api/shapes/shared-memories', { session_scope });
289
+ break;
290
+ }
291
+ case 'memory_reconcile': {
292
+ const args = request.params.arguments;
293
+ data = await apiPost('/api/sync/reconcile', args);
294
+ break;
295
+ }
296
+ default:
297
+ return {
298
+ content: [{ type: 'text', text: `Error: Unknown tool: ${toolName}` }],
299
+ isError: true,
300
+ };
301
+ }
302
+ return {
303
+ content: [
304
+ {
305
+ type: 'text',
306
+ text: JSON.stringify({
307
+ data,
308
+ _meta: {
309
+ durationMs: Date.now() - startTime,
310
+ server: 'revealui-memory',
311
+ tool: toolName,
312
+ timestamp: new Date().toISOString(),
313
+ },
314
+ }, null, 2),
315
+ },
316
+ ],
317
+ };
318
+ }
319
+ catch (err) {
320
+ return {
321
+ content: [
322
+ { type: 'text', text: `Error: ${err instanceof Error ? err.message : String(err)}` },
323
+ ],
324
+ isError: true,
325
+ };
326
+ }
327
+ });
328
+ async function main() {
329
+ if (!(await checkMcpLicense())) {
330
+ process.exit(1);
331
+ }
332
+ const transport = new StdioServerTransport();
333
+ await server.connect(transport);
334
+ }
335
+ main().catch((err) => {
336
+ logger.error('RevealUI Memory MCP error', err instanceof Error ? err : new Error(String(err)));
337
+ process.exit(1);
338
+ });
339
+ //# sourceMappingURL=revealui-memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"revealui-memory.js","sourceRoot":"","sources":["../../src/servers/revealui-memory.ts"],"names":[],"mappings":";AAEA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,2CAA2C,CAAC;AACnE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2CAA2C,CAAC;AACjF,OAAO,EAEL,qBAAqB,EACrB,sBAAsB,GAEvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,MAAM,EAAE,MAAM,qCAAqC,CAAC;AAC7D,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,8EAA8E;AAC9E,mEAAmE;AACnE,8EAA8E;AAE9E,IAAI,oBAAoB,GAA2B,EAAE,CAAC;AAEtD,MAAM,UAAU,cAAc,CAAC,KAA6B;IAC1D,oBAAoB,GAAG,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