@prmichaelsen/remember-mcp 0.1.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.
- package/.env.example +65 -0
- package/AGENT.md +840 -0
- package/README.md +72 -0
- package/agent/design/.gitkeep +0 -0
- package/agent/design/access-control-result-pattern.md +458 -0
- package/agent/design/action-audit-memory-types.md +637 -0
- package/agent/design/common-template-fields.md +282 -0
- package/agent/design/complete-tool-set.md +407 -0
- package/agent/design/content-types-expansion.md +521 -0
- package/agent/design/cross-database-id-strategy.md +358 -0
- package/agent/design/default-template-library.md +423 -0
- package/agent/design/firestore-wrapper-analysis.md +606 -0
- package/agent/design/llm-provider-abstraction.md +691 -0
- package/agent/design/location-handling-architecture.md +523 -0
- package/agent/design/memory-templates-design.md +364 -0
- package/agent/design/permissions-storage-architecture.md +680 -0
- package/agent/design/relationship-storage-strategy.md +361 -0
- package/agent/design/remember-mcp-implementation-tasks.md +417 -0
- package/agent/design/remember-mcp-progress.yaml +141 -0
- package/agent/design/requirements-enhancements.md +468 -0
- package/agent/design/requirements.md +56 -0
- package/agent/design/template-storage-strategy.md +412 -0
- package/agent/design/template-suggestion-system.md +853 -0
- package/agent/design/trust-escalation-prevention.md +343 -0
- package/agent/design/trust-system-implementation.md +592 -0
- package/agent/design/user-preferences.md +683 -0
- package/agent/design/weaviate-collection-strategy.md +461 -0
- package/agent/milestones/.gitkeep +0 -0
- package/agent/milestones/milestone-1-project-foundation.md +121 -0
- package/agent/milestones/milestone-2-core-memory-system.md +150 -0
- package/agent/milestones/milestone-3-relationships-graph.md +116 -0
- package/agent/milestones/milestone-4-user-preferences.md +103 -0
- package/agent/milestones/milestone-5-template-system.md +126 -0
- package/agent/milestones/milestone-6-auth-multi-tenancy.md +124 -0
- package/agent/milestones/milestone-7-trust-permissions.md +133 -0
- package/agent/milestones/milestone-8-testing-quality.md +137 -0
- package/agent/milestones/milestone-9-deployment-documentation.md +147 -0
- package/agent/patterns/.gitkeep +0 -0
- package/agent/patterns/bootstrap.md +1271 -0
- package/agent/patterns/firebase-admin-sdk-v8-usage.md +950 -0
- package/agent/patterns/firestore-users-pattern-best-practices.md +347 -0
- package/agent/patterns/library-services.md +454 -0
- package/agent/patterns/testing-colocated.md +316 -0
- package/agent/progress.yaml +395 -0
- package/agent/tasks/.gitkeep +0 -0
- package/agent/tasks/task-1-initialize-project-structure.md +266 -0
- package/agent/tasks/task-2-install-dependencies.md +199 -0
- package/agent/tasks/task-3-setup-weaviate-client.md +330 -0
- package/agent/tasks/task-4-setup-firestore-client.md +362 -0
- package/agent/tasks/task-5-create-basic-mcp-server.md +114 -0
- package/agent/tasks/task-6-create-integration-tests.md +195 -0
- package/agent/tasks/task-7-finalize-milestone-1.md +363 -0
- package/agent/tasks/task-8-setup-utility-scripts.md +382 -0
- package/agent/tasks/task-9-create-server-factory.md +404 -0
- package/dist/config.d.ts +26 -0
- package/dist/constants/content-types.d.ts +60 -0
- package/dist/firestore/init.d.ts +14 -0
- package/dist/firestore/paths.d.ts +53 -0
- package/dist/firestore/paths.spec.d.ts +2 -0
- package/dist/server-factory.d.ts +40 -0
- package/dist/server-factory.js +1741 -0
- package/dist/server-factory.spec.d.ts +2 -0
- package/dist/server.d.ts +3 -0
- package/dist/server.js +1690 -0
- package/dist/tools/create-memory.d.ts +94 -0
- package/dist/tools/delete-memory.d.ts +47 -0
- package/dist/tools/search-memory.d.ts +88 -0
- package/dist/types/memory.d.ts +183 -0
- package/dist/utils/logger.d.ts +7 -0
- package/dist/weaviate/client.d.ts +39 -0
- package/dist/weaviate/client.spec.d.ts +2 -0
- package/dist/weaviate/schema.d.ts +29 -0
- package/esbuild.build.js +60 -0
- package/esbuild.watch.js +25 -0
- package/jest.config.js +31 -0
- package/jest.e2e.config.js +17 -0
- package/package.json +68 -0
- package/src/.gitkeep +0 -0
- package/src/config.ts +56 -0
- package/src/constants/content-types.ts +454 -0
- package/src/firestore/init.ts +68 -0
- package/src/firestore/paths.spec.ts +75 -0
- package/src/firestore/paths.ts +124 -0
- package/src/server-factory.spec.ts +60 -0
- package/src/server-factory.ts +215 -0
- package/src/server.ts +243 -0
- package/src/tools/create-memory.ts +198 -0
- package/src/tools/delete-memory.ts +126 -0
- package/src/tools/search-memory.ts +216 -0
- package/src/types/memory.ts +276 -0
- package/src/utils/logger.ts +42 -0
- package/src/weaviate/client.spec.ts +58 -0
- package/src/weaviate/client.ts +114 -0
- package/src/weaviate/schema.ts +288 -0
- package/tsconfig.json +26 -0
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
# Task 9: Create Server Factory for mcp-auth Compatibility
|
|
2
|
+
|
|
3
|
+
**Milestone**: M1 - Project Foundation
|
|
4
|
+
**Estimated Time**: 2 hours
|
|
5
|
+
**Dependencies**: Task 5 ✅
|
|
6
|
+
**Status**: Not Started
|
|
7
|
+
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Objective
|
|
11
|
+
|
|
12
|
+
Create a server factory function that exports a `createServer(accessToken, userId, options?)` function compatible with mcp-auth wrapping pattern. This enables the server to be wrapped by mcp-auth for multi-tenant production deployments.
|
|
13
|
+
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
## Background
|
|
17
|
+
|
|
18
|
+
According to [`agent/patterns/bootstrap.md`](../patterns/bootstrap.md) and mcp-auth documentation, servers should export a factory function that:
|
|
19
|
+
- Accepts `(accessToken: string, userId: string, options?: ServerOptions)`
|
|
20
|
+
- Returns a configured `Server` instance (not connected to transport)
|
|
21
|
+
- Creates isolated instances with no shared state
|
|
22
|
+
- Scopes all operations to the provided userId
|
|
23
|
+
|
|
24
|
+
This pattern enables:
|
|
25
|
+
- ✅ Multi-tenant deployments via mcp-auth
|
|
26
|
+
- ✅ SSE/HTTP transports (not just stdio)
|
|
27
|
+
- ✅ Per-user server instances
|
|
28
|
+
- ✅ Integration with agentbase.me platform
|
|
29
|
+
|
|
30
|
+
---
|
|
31
|
+
|
|
32
|
+
## Steps
|
|
33
|
+
|
|
34
|
+
### 1. Create Server Factory
|
|
35
|
+
|
|
36
|
+
**src/server-factory.ts**:
|
|
37
|
+
```typescript
|
|
38
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
39
|
+
import {
|
|
40
|
+
CallToolRequestSchema,
|
|
41
|
+
ListToolsRequestSchema,
|
|
42
|
+
ErrorCode,
|
|
43
|
+
McpError,
|
|
44
|
+
} from '@modelcontextprotocol/sdk/types.js';
|
|
45
|
+
import { getWeaviateClient } from './weaviate/client.js';
|
|
46
|
+
import { logger } from './utils/logger.js';
|
|
47
|
+
|
|
48
|
+
export interface ServerOptions {
|
|
49
|
+
name?: string;
|
|
50
|
+
version?: string;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Create a server instance for a specific user/tenant
|
|
55
|
+
*
|
|
56
|
+
* This factory function is compatible with mcp-auth wrapping pattern.
|
|
57
|
+
* It creates isolated server instances with no shared state.
|
|
58
|
+
*
|
|
59
|
+
* @param accessToken - User's access token (not used yet, reserved for future external APIs)
|
|
60
|
+
* @param userId - User identifier for scoping operations
|
|
61
|
+
* @param options - Optional server configuration
|
|
62
|
+
* @returns Configured MCP Server instance (not connected to transport)
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* // Direct usage
|
|
67
|
+
* const server = createServer('token', 'user123');
|
|
68
|
+
* const transport = new StdioServerTransport();
|
|
69
|
+
* await server.connect(transport);
|
|
70
|
+
*
|
|
71
|
+
* // With mcp-auth
|
|
72
|
+
* import { wrapServer } from '@prmichaelsen/mcp-auth';
|
|
73
|
+
* const wrapped = wrapServer({
|
|
74
|
+
* serverFactory: createServer,
|
|
75
|
+
* authProvider: new JWTAuthProvider({ ... }),
|
|
76
|
+
* tokenResolver: new APITokenResolver({ ... }),
|
|
77
|
+
* resourceType: 'remember',
|
|
78
|
+
* transport: { type: 'sse', port: 3000 }
|
|
79
|
+
* });
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export function createServer(
|
|
83
|
+
accessToken: string,
|
|
84
|
+
userId: string,
|
|
85
|
+
options: ServerOptions = {}
|
|
86
|
+
): Server {
|
|
87
|
+
if (!accessToken) {
|
|
88
|
+
throw new Error('accessToken is required');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (!userId) {
|
|
92
|
+
throw new Error('userId is required');
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
logger.debug('Creating server instance', { userId });
|
|
96
|
+
|
|
97
|
+
// Create MCP server
|
|
98
|
+
const server = new Server(
|
|
99
|
+
{
|
|
100
|
+
name: options.name || 'remember-mcp',
|
|
101
|
+
version: options.version || '0.1.0',
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
capabilities: {
|
|
105
|
+
tools: {},
|
|
106
|
+
},
|
|
107
|
+
}
|
|
108
|
+
);
|
|
109
|
+
|
|
110
|
+
// Register handlers with userId scope
|
|
111
|
+
registerHandlers(server, userId, accessToken);
|
|
112
|
+
|
|
113
|
+
return server;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* Register MCP handlers scoped to userId
|
|
118
|
+
*/
|
|
119
|
+
function registerHandlers(server: Server, userId: string, accessToken: string): void {
|
|
120
|
+
// List available tools
|
|
121
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => {
|
|
122
|
+
return {
|
|
123
|
+
tools: [
|
|
124
|
+
{
|
|
125
|
+
name: 'health_check',
|
|
126
|
+
description: 'Check server health and database connections',
|
|
127
|
+
inputSchema: {
|
|
128
|
+
type: 'object',
|
|
129
|
+
properties: {},
|
|
130
|
+
},
|
|
131
|
+
},
|
|
132
|
+
],
|
|
133
|
+
};
|
|
134
|
+
});
|
|
135
|
+
|
|
136
|
+
// Handle tool calls
|
|
137
|
+
server.setRequestHandler(CallToolRequestSchema, async (request) => {
|
|
138
|
+
const { name, arguments: args } = request.params;
|
|
139
|
+
|
|
140
|
+
try {
|
|
141
|
+
let result: string;
|
|
142
|
+
|
|
143
|
+
switch (name) {
|
|
144
|
+
case 'health_check':
|
|
145
|
+
result = await handleHealthCheck(userId);
|
|
146
|
+
break;
|
|
147
|
+
|
|
148
|
+
default:
|
|
149
|
+
throw new McpError(
|
|
150
|
+
ErrorCode.MethodNotFound,
|
|
151
|
+
`Unknown tool: ${name}`
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
return {
|
|
156
|
+
content: [
|
|
157
|
+
{
|
|
158
|
+
type: 'text',
|
|
159
|
+
text: result,
|
|
160
|
+
},
|
|
161
|
+
],
|
|
162
|
+
};
|
|
163
|
+
} catch (error) {
|
|
164
|
+
if (error instanceof McpError) {
|
|
165
|
+
throw error;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
logger.error(`Tool execution failed for ${name}:`, error);
|
|
169
|
+
throw new McpError(
|
|
170
|
+
ErrorCode.InternalError,
|
|
171
|
+
`Tool execution failed: ${error instanceof Error ? error.message : String(error)}`
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Health check handler (scoped to userId)
|
|
179
|
+
*/
|
|
180
|
+
async function handleHealthCheck(userId: string): Promise<string> {
|
|
181
|
+
const health = {
|
|
182
|
+
status: 'healthy',
|
|
183
|
+
timestamp: new Date().toISOString(),
|
|
184
|
+
userId: userId,
|
|
185
|
+
server: {
|
|
186
|
+
name: 'remember-mcp',
|
|
187
|
+
version: '0.1.0',
|
|
188
|
+
},
|
|
189
|
+
databases: {
|
|
190
|
+
weaviate: {
|
|
191
|
+
connected: false,
|
|
192
|
+
userCollection: `Memory_${userId}`,
|
|
193
|
+
},
|
|
194
|
+
firestore: {
|
|
195
|
+
connected: false,
|
|
196
|
+
userPath: `users/${userId}`,
|
|
197
|
+
},
|
|
198
|
+
},
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
try {
|
|
202
|
+
// Test Weaviate connection
|
|
203
|
+
const weaviateClient = getWeaviateClient();
|
|
204
|
+
health.databases.weaviate.connected = await weaviateClient.isReady();
|
|
205
|
+
} catch (error) {
|
|
206
|
+
logger.error('Weaviate health check failed:', error);
|
|
207
|
+
health.databases.weaviate.connected = false;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
try {
|
|
211
|
+
// Test Firestore connection (import dynamically to avoid initialization issues)
|
|
212
|
+
const { testFirestoreConnection } = await import('./firestore/init.js');
|
|
213
|
+
health.databases.firestore.connected = await testFirestoreConnection();
|
|
214
|
+
} catch (error) {
|
|
215
|
+
logger.error('Firestore health check failed:', error);
|
|
216
|
+
health.databases.firestore.connected = false;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
// Overall status
|
|
220
|
+
const allHealthy =
|
|
221
|
+
health.databases.weaviate.connected &&
|
|
222
|
+
health.databases.firestore.connected;
|
|
223
|
+
|
|
224
|
+
health.status = allHealthy ? 'healthy' : 'degraded';
|
|
225
|
+
|
|
226
|
+
return JSON.stringify(health, null, 2);
|
|
227
|
+
}
|
|
228
|
+
```
|
|
229
|
+
|
|
230
|
+
### 2. Update package.json Exports
|
|
231
|
+
|
|
232
|
+
**package.json**:
|
|
233
|
+
```json
|
|
234
|
+
{
|
|
235
|
+
"main": "dist/server.js",
|
|
236
|
+
"exports": {
|
|
237
|
+
".": {
|
|
238
|
+
"types": "./dist/server.d.ts",
|
|
239
|
+
"import": "./dist/server.js"
|
|
240
|
+
},
|
|
241
|
+
"./factory": {
|
|
242
|
+
"types": "./dist/server-factory.d.ts",
|
|
243
|
+
"import": "./dist/server-factory.js"
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
```
|
|
248
|
+
|
|
249
|
+
### 3. Update esbuild.build.js
|
|
250
|
+
|
|
251
|
+
**esbuild.build.js**:
|
|
252
|
+
```javascript
|
|
253
|
+
import * as esbuild from 'esbuild';
|
|
254
|
+
|
|
255
|
+
// Build standalone server (bundled)
|
|
256
|
+
await esbuild.build({
|
|
257
|
+
entryPoints: ['src/server.ts'],
|
|
258
|
+
bundle: true,
|
|
259
|
+
platform: 'node',
|
|
260
|
+
target: 'node20',
|
|
261
|
+
format: 'esm',
|
|
262
|
+
outfile: 'dist/server.js',
|
|
263
|
+
sourcemap: true,
|
|
264
|
+
external: [
|
|
265
|
+
'weaviate-client',
|
|
266
|
+
'@prmichaelsen/firebase-admin-sdk-v8',
|
|
267
|
+
'@modelcontextprotocol/sdk'
|
|
268
|
+
],
|
|
269
|
+
banner: {
|
|
270
|
+
js: "import { createRequire } from 'module'; const require = createRequire(import.meta.url);"
|
|
271
|
+
},
|
|
272
|
+
alias: {
|
|
273
|
+
'@': './src'
|
|
274
|
+
}
|
|
275
|
+
});
|
|
276
|
+
|
|
277
|
+
// Build factory for library usage (unbundled)
|
|
278
|
+
await esbuild.build({
|
|
279
|
+
entryPoints: ['src/server-factory.ts'],
|
|
280
|
+
bundle: false,
|
|
281
|
+
platform: 'node',
|
|
282
|
+
target: 'node20',
|
|
283
|
+
format: 'esm',
|
|
284
|
+
outdir: 'dist',
|
|
285
|
+
outbase: 'src',
|
|
286
|
+
sourcemap: true,
|
|
287
|
+
alias: {
|
|
288
|
+
'@': './src'
|
|
289
|
+
}
|
|
290
|
+
});
|
|
291
|
+
|
|
292
|
+
console.log('✓ Build complete');
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### 4. Create Unit Tests
|
|
296
|
+
|
|
297
|
+
**src/server-factory.spec.ts**:
|
|
298
|
+
```typescript
|
|
299
|
+
import { describe, it, expect } from '@jest/globals';
|
|
300
|
+
import { createServer } from './server-factory.js';
|
|
301
|
+
|
|
302
|
+
describe('Server Factory', () => {
|
|
303
|
+
it('should create server instance', () => {
|
|
304
|
+
const server = createServer('test-token', 'user123');
|
|
305
|
+
expect(server).toBeDefined();
|
|
306
|
+
});
|
|
307
|
+
|
|
308
|
+
it('should require accessToken', () => {
|
|
309
|
+
expect(() => createServer('', 'user123')).toThrow('accessToken is required');
|
|
310
|
+
});
|
|
311
|
+
|
|
312
|
+
it('should require userId', () => {
|
|
313
|
+
expect(() => createServer('token', '')).toThrow('userId is required');
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
it('should accept custom options', () => {
|
|
317
|
+
const server = createServer('token', 'user123', {
|
|
318
|
+
name: 'custom-name',
|
|
319
|
+
version: '2.0.0'
|
|
320
|
+
});
|
|
321
|
+
expect(server).toBeDefined();
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### 5. Update README.md
|
|
327
|
+
|
|
328
|
+
**README.md** - Add usage section:
|
|
329
|
+
```markdown
|
|
330
|
+
## Usage
|
|
331
|
+
|
|
332
|
+
### Standalone (stdio)
|
|
333
|
+
```bash
|
|
334
|
+
npm start
|
|
335
|
+
```
|
|
336
|
+
|
|
337
|
+
### With mcp-auth (multi-tenant)
|
|
338
|
+
```typescript
|
|
339
|
+
import { wrapServer, JWTAuthProvider, APITokenResolver } from '@prmichaelsen/mcp-auth';
|
|
340
|
+
import { createServer } from '@prmichaelsen/remember-mcp/factory';
|
|
341
|
+
|
|
342
|
+
const wrapped = wrapServer({
|
|
343
|
+
serverFactory: createServer,
|
|
344
|
+
authProvider: new JWTAuthProvider({ jwtSecret: process.env.JWT_SECRET }),
|
|
345
|
+
tokenResolver: new APITokenResolver({
|
|
346
|
+
tenantManagerUrl: process.env.TENANT_MANAGER_URL
|
|
347
|
+
}),
|
|
348
|
+
resourceType: 'remember',
|
|
349
|
+
transport: { type: 'sse', port: 3000 }
|
|
350
|
+
});
|
|
351
|
+
|
|
352
|
+
await wrapped.start();
|
|
353
|
+
```
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
---
|
|
357
|
+
|
|
358
|
+
## Verification
|
|
359
|
+
|
|
360
|
+
- [ ] src/server-factory.ts created
|
|
361
|
+
- [ ] Exports createServer function with correct signature
|
|
362
|
+
- [ ] Server instances are isolated (no shared state)
|
|
363
|
+
- [ ] All operations scoped to userId
|
|
364
|
+
- [ ] package.json exports updated
|
|
365
|
+
- [ ] esbuild builds both server.js and server-factory.js
|
|
366
|
+
- [ ] Unit tests passing
|
|
367
|
+
- [ ] TypeScript compiles without errors
|
|
368
|
+
- [ ] README.md updated with usage examples
|
|
369
|
+
|
|
370
|
+
---
|
|
371
|
+
|
|
372
|
+
## Testing
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
# Type check
|
|
376
|
+
npm run typecheck
|
|
377
|
+
|
|
378
|
+
# Build
|
|
379
|
+
npm run build
|
|
380
|
+
|
|
381
|
+
# Test
|
|
382
|
+
npm test
|
|
383
|
+
|
|
384
|
+
# Verify exports
|
|
385
|
+
node -e "import('./dist/server-factory.js').then(m => console.log(typeof m.createServer))"
|
|
386
|
+
# Should output: function
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
---
|
|
390
|
+
|
|
391
|
+
## Next Task
|
|
392
|
+
|
|
393
|
+
Task 6: Create Integration Tests
|
|
394
|
+
|
|
395
|
+
---
|
|
396
|
+
|
|
397
|
+
## Notes
|
|
398
|
+
|
|
399
|
+
This task makes remember-mcp compatible with mcp-auth for production multi-tenant deployments while maintaining the standalone server for local development and testing.
|
|
400
|
+
|
|
401
|
+
**Key Design**:
|
|
402
|
+
- `src/server.ts` - Standalone server with stdio (for local dev)
|
|
403
|
+
- `src/server-factory.ts` - Factory function (for mcp-auth wrapping)
|
|
404
|
+
- Both patterns supported simultaneously
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const config: {
|
|
2
|
+
readonly weaviate: {
|
|
3
|
+
readonly url: string;
|
|
4
|
+
readonly apiKey: string;
|
|
5
|
+
};
|
|
6
|
+
readonly openai: {
|
|
7
|
+
readonly apiKey: string;
|
|
8
|
+
};
|
|
9
|
+
readonly firebase: {
|
|
10
|
+
readonly serviceAccount: string;
|
|
11
|
+
readonly projectId: string;
|
|
12
|
+
};
|
|
13
|
+
readonly server: {
|
|
14
|
+
readonly port: number;
|
|
15
|
+
readonly nodeEnv: string;
|
|
16
|
+
readonly logLevel: string;
|
|
17
|
+
};
|
|
18
|
+
readonly mcp: {
|
|
19
|
+
readonly transport: string;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Validate required configuration
|
|
24
|
+
*/
|
|
25
|
+
export declare function validateConfig(): void;
|
|
26
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Content type constants and descriptions
|
|
3
|
+
* Based on agent/design/content-types-expansion.md and default-template-library.md
|
|
4
|
+
*/
|
|
5
|
+
import type { ContentType } from '../types/memory.js';
|
|
6
|
+
/**
|
|
7
|
+
* All available content types
|
|
8
|
+
*/
|
|
9
|
+
export declare const CONTENT_TYPES: readonly ContentType[];
|
|
10
|
+
/**
|
|
11
|
+
* Content type metadata
|
|
12
|
+
*/
|
|
13
|
+
export interface ContentTypeMetadata {
|
|
14
|
+
name: ContentType;
|
|
15
|
+
category: string;
|
|
16
|
+
description: string;
|
|
17
|
+
examples: string[];
|
|
18
|
+
common_fields?: string[];
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Comprehensive content type descriptions
|
|
22
|
+
*/
|
|
23
|
+
export declare const CONTENT_TYPE_METADATA: Record<ContentType, ContentTypeMetadata>;
|
|
24
|
+
/**
|
|
25
|
+
* Content type categories
|
|
26
|
+
*/
|
|
27
|
+
export declare const CONTENT_TYPE_CATEGORIES: {
|
|
28
|
+
readonly core: readonly ["code", "note", "documentation", "reference"];
|
|
29
|
+
readonly task: readonly ["todo", "checklist", "project", "goal", "habit"];
|
|
30
|
+
readonly communication: readonly ["email", "conversation", "meeting", "person"];
|
|
31
|
+
readonly content: readonly ["article", "webpage", "social", "presentation", "spreadsheet", "pdf"];
|
|
32
|
+
readonly media: readonly ["image", "video", "audio", "transcript"];
|
|
33
|
+
readonly creative: readonly ["screenplay", "recipe", "idea", "quote"];
|
|
34
|
+
readonly personal: readonly ["journal", "memory", "event"];
|
|
35
|
+
readonly organizational: readonly ["bookmark", "form", "location"];
|
|
36
|
+
readonly business: readonly ["invoice", "contract"];
|
|
37
|
+
readonly system: readonly ["system", "action", "audit", "history"];
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* Get content type metadata
|
|
41
|
+
*/
|
|
42
|
+
export declare function getContentTypeMetadata(type: ContentType): ContentTypeMetadata;
|
|
43
|
+
/**
|
|
44
|
+
* Get content types by category
|
|
45
|
+
*/
|
|
46
|
+
export declare function getContentTypesByCategory(category: keyof typeof CONTENT_TYPE_CATEGORIES): ContentType[];
|
|
47
|
+
/**
|
|
48
|
+
* Validate content type
|
|
49
|
+
*/
|
|
50
|
+
export declare function isValidContentType(type: string): type is ContentType;
|
|
51
|
+
/**
|
|
52
|
+
* Get content type description for LLM prompts
|
|
53
|
+
* Generated dynamically from CONTENT_TYPE_METADATA
|
|
54
|
+
*/
|
|
55
|
+
export declare function getContentTypeDescription(): string;
|
|
56
|
+
/**
|
|
57
|
+
* Default content type
|
|
58
|
+
*/
|
|
59
|
+
export declare const DEFAULT_CONTENT_TYPE: ContentType;
|
|
60
|
+
//# sourceMappingURL=content-types.d.ts.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Initialize Firebase Admin SDK
|
|
3
|
+
*/
|
|
4
|
+
export declare function initFirestore(): void;
|
|
5
|
+
/**
|
|
6
|
+
* Check if Firestore is initialized
|
|
7
|
+
*/
|
|
8
|
+
export declare function isFirestoreInitialized(): boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Test Firestore connection
|
|
11
|
+
*/
|
|
12
|
+
export declare function testFirestoreConnection(): Promise<boolean>;
|
|
13
|
+
export { getDocument, setDocument, addDocument, updateDocument, deleteDocument, queryDocuments, batchWrite, FieldValue, verifyIdToken, type QueryOptions, } from '@prmichaelsen/firebase-admin-sdk-v8';
|
|
14
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Firestore collection path helpers
|
|
3
|
+
* Following the environment-based prefix + users subcollection pattern
|
|
4
|
+
*
|
|
5
|
+
* Pattern from agentbase.me:
|
|
6
|
+
* - Environment prefix: e0.remember-mcp (dev), remember-mcp (prod)
|
|
7
|
+
* - User-scoped data: {BASE}.users/{user_id}/* (per agent/patterns/firestore-users-pattern-best-practices.md)
|
|
8
|
+
* - Shared data: {BASE}.templates/default, {BASE}.user-permissions
|
|
9
|
+
*/
|
|
10
|
+
export declare const BASE: string;
|
|
11
|
+
/**
|
|
12
|
+
* Get path to user preferences document
|
|
13
|
+
* Pattern: {BASE}.users/{user_id}/preferences
|
|
14
|
+
*/
|
|
15
|
+
export declare function getUserPreferencesPath(userId: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Get path to user's templates collection
|
|
18
|
+
* Pattern: {BASE}.users/{user_id}/templates
|
|
19
|
+
*/
|
|
20
|
+
export declare function getUserTemplatesPath(userId: string): string;
|
|
21
|
+
/**
|
|
22
|
+
* Get path to user's access logs collection
|
|
23
|
+
* Pattern: {BASE}.users/{user_id}/access-logs
|
|
24
|
+
*/
|
|
25
|
+
export declare function getUserAccessLogsPath(userId: string): string;
|
|
26
|
+
/**
|
|
27
|
+
* Get path to user's trust relationships collection
|
|
28
|
+
* Pattern: {BASE}.users/{user_id}/trust-relationships
|
|
29
|
+
*/
|
|
30
|
+
export declare function getUserTrustRelationshipsPath(userId: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Get path to user's allowed accessors collection (permissions)
|
|
33
|
+
* Pattern: {BASE}.user-permissions/{owner_user_id}/allowed-accessors
|
|
34
|
+
*
|
|
35
|
+
* Note: Outside users/ because it involves two users (owner + accessor)
|
|
36
|
+
*/
|
|
37
|
+
export declare function getUserPermissionsPath(ownerUserId: string): string;
|
|
38
|
+
/**
|
|
39
|
+
* Get path to specific permission document
|
|
40
|
+
* Pattern: {BASE}.user-permissions/{owner_user_id}/allowed-accessors/{accessor_user_id}
|
|
41
|
+
*/
|
|
42
|
+
export declare function getUserPermissionPath(ownerUserId: string, accessorUserId: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* Get path to default templates collection
|
|
45
|
+
* Pattern: {BASE}.templates/default
|
|
46
|
+
*/
|
|
47
|
+
export declare function getDefaultTemplatesPath(): string;
|
|
48
|
+
/**
|
|
49
|
+
* Get path to specific default template
|
|
50
|
+
* Pattern: {BASE}.templates/default/{template_id}
|
|
51
|
+
*/
|
|
52
|
+
export declare function getDefaultTemplatePath(templateId: string): string;
|
|
53
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server factory for mcp-auth compatibility
|
|
3
|
+
* Creates isolated server instances per user/tenant
|
|
4
|
+
*/
|
|
5
|
+
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
6
|
+
export interface ServerOptions {
|
|
7
|
+
name?: string;
|
|
8
|
+
version?: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Create a server instance for a specific user/tenant
|
|
12
|
+
*
|
|
13
|
+
* This factory function is compatible with mcp-auth wrapping pattern.
|
|
14
|
+
* It creates isolated server instances with no shared state.
|
|
15
|
+
*
|
|
16
|
+
* @param accessToken - User's access token (reserved for future external APIs)
|
|
17
|
+
* @param userId - User identifier for scoping operations
|
|
18
|
+
* @param options - Optional server configuration
|
|
19
|
+
* @returns Configured MCP Server instance (not connected to transport)
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* ```typescript
|
|
23
|
+
* // Direct usage
|
|
24
|
+
* const server = createServer('token', 'user123');
|
|
25
|
+
* const transport = new StdioServerTransport();
|
|
26
|
+
* await server.connect(transport);
|
|
27
|
+
*
|
|
28
|
+
* // With mcp-auth
|
|
29
|
+
* import { wrapServer } from '@prmichaelsen/mcp-auth';
|
|
30
|
+
* const wrapped = wrapServer({
|
|
31
|
+
* serverFactory: createServer,
|
|
32
|
+
* authProvider: new JWTAuthProvider({ ... }),
|
|
33
|
+
* tokenResolver: new APITokenResolver({ ... }),
|
|
34
|
+
* resourceType: 'remember',
|
|
35
|
+
* transport: { type: 'sse', port: 3000 }
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function createServer(accessToken: string, userId: string, options?: ServerOptions): Server;
|
|
40
|
+
//# sourceMappingURL=server-factory.d.ts.map
|