s3db.js 11.3.1 ā 11.3.2
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/dist/s3db.cjs.js +1 -1
- package/dist/s3db.es.js +1 -1
- package/package.json +1 -1
- package/mcp/CLAUDE_CLI_SETUP.md +0 -302
- package/mcp/Dockerfile +0 -45
- package/mcp/Makefile +0 -162
- package/mcp/NPX_SETUP.md +0 -327
- package/mcp/PUBLISHING.md +0 -281
- package/mcp/README.md +0 -125
- package/mcp/docker-compose.yml +0 -120
- package/mcp/examples/test-filesystem-cache.js +0 -147
- package/mcp/examples/test-mcp.js +0 -433
- package/mcp/package.json +0 -66
package/mcp/examples/test-mcp.js
DELETED
|
@@ -1,433 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* S3DB MCP Server Test Script
|
|
5
|
-
*
|
|
6
|
-
* This script demonstrates how to test the S3DB MCP server functionality
|
|
7
|
-
* by making direct tool calls and showing the expected responses.
|
|
8
|
-
*/
|
|
9
|
-
|
|
10
|
-
import { createRequire } from 'module';
|
|
11
|
-
const require = createRequire(import.meta.url);
|
|
12
|
-
|
|
13
|
-
// Mock MCP client for testing
|
|
14
|
-
class MockMCPClient {
|
|
15
|
-
constructor(serverUrl) {
|
|
16
|
-
this.serverUrl = serverUrl;
|
|
17
|
-
this.tools = [];
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
async initialize() {
|
|
21
|
-
console.log('š Initializing MCP Client...');
|
|
22
|
-
console.log(`š” Server URL: ${this.serverUrl}`);
|
|
23
|
-
|
|
24
|
-
// In a real implementation, this would connect to the MCP server
|
|
25
|
-
// and fetch the available tools
|
|
26
|
-
this.tools = [
|
|
27
|
-
'dbConnect', 'dbDisconnect', 'dbStatus', 'dbCreateResource', 'dbListResources', 'dbGetStats', 'dbClearCache',
|
|
28
|
-
'resourceInsert', 'resourceGet', 'resourceUpdate', 'resourceDelete', 'resourceList'
|
|
29
|
-
];
|
|
30
|
-
|
|
31
|
-
console.log(`ā
Found ${this.tools.length} available tools`);
|
|
32
|
-
return this.tools;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
async callTool(name, args = {}) {
|
|
36
|
-
console.log(`\nš§ Calling tool: ${name}`);
|
|
37
|
-
console.log(`š„ Arguments:`, JSON.stringify(args, null, 2));
|
|
38
|
-
|
|
39
|
-
// Mock successful responses for demonstration
|
|
40
|
-
const mockResponses = {
|
|
41
|
-
dbConnect: {
|
|
42
|
-
success: true,
|
|
43
|
-
message: 'Connected to S3DB database',
|
|
44
|
-
status: {
|
|
45
|
-
connected: true,
|
|
46
|
-
bucket: 'test-bucket',
|
|
47
|
-
keyPrefix: 'databases/test',
|
|
48
|
-
version: '7.2.1'
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
|
|
52
|
-
dbStatus: {
|
|
53
|
-
connected: true,
|
|
54
|
-
bucket: 'test-bucket',
|
|
55
|
-
keyPrefix: 'databases/test',
|
|
56
|
-
version: '7.2.1',
|
|
57
|
-
resourceCount: 2,
|
|
58
|
-
resources: ['users', 'posts']
|
|
59
|
-
},
|
|
60
|
-
|
|
61
|
-
dbCreateResource: {
|
|
62
|
-
success: true,
|
|
63
|
-
resource: {
|
|
64
|
-
name: args.name,
|
|
65
|
-
behavior: args.behavior || 'user-managed',
|
|
66
|
-
attributes: args.attributes,
|
|
67
|
-
partitions: args.partitions || {},
|
|
68
|
-
timestamps: args.timestamps || false
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
|
|
72
|
-
dbListResources: {
|
|
73
|
-
success: true,
|
|
74
|
-
resources: [
|
|
75
|
-
{ name: 'users' },
|
|
76
|
-
{ name: 'posts' }
|
|
77
|
-
],
|
|
78
|
-
count: 2
|
|
79
|
-
},
|
|
80
|
-
|
|
81
|
-
resourceInsert: {
|
|
82
|
-
success: true,
|
|
83
|
-
data: {
|
|
84
|
-
id: 'doc_' + Math.random().toString(36).substr(2, 9),
|
|
85
|
-
...args.data,
|
|
86
|
-
createdAt: new Date().toISOString(),
|
|
87
|
-
updatedAt: new Date().toISOString()
|
|
88
|
-
}
|
|
89
|
-
},
|
|
90
|
-
|
|
91
|
-
resourceGet: {
|
|
92
|
-
success: true,
|
|
93
|
-
data: {
|
|
94
|
-
id: args.id,
|
|
95
|
-
name: 'John Doe',
|
|
96
|
-
email: 'john@example.com',
|
|
97
|
-
createdAt: '2024-01-15T10:30:00Z',
|
|
98
|
-
updatedAt: '2024-01-15T10:30:00Z'
|
|
99
|
-
}
|
|
100
|
-
},
|
|
101
|
-
|
|
102
|
-
resourceList: {
|
|
103
|
-
success: true,
|
|
104
|
-
data: [
|
|
105
|
-
{
|
|
106
|
-
id: 'doc_123',
|
|
107
|
-
name: 'John Doe',
|
|
108
|
-
email: 'john@example.com',
|
|
109
|
-
createdAt: '2024-01-15T10:30:00Z'
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
id: 'doc_456',
|
|
113
|
-
name: 'Jane Smith',
|
|
114
|
-
email: 'jane@example.com',
|
|
115
|
-
createdAt: '2024-01-15T11:30:00Z'
|
|
116
|
-
}
|
|
117
|
-
],
|
|
118
|
-
count: 2,
|
|
119
|
-
pagination: {
|
|
120
|
-
limit: args.limit || 100,
|
|
121
|
-
offset: args.offset || 0,
|
|
122
|
-
hasMore: false
|
|
123
|
-
}
|
|
124
|
-
},
|
|
125
|
-
|
|
126
|
-
resourceCount: {
|
|
127
|
-
success: true,
|
|
128
|
-
count: 42,
|
|
129
|
-
resource: args.resourceName
|
|
130
|
-
},
|
|
131
|
-
|
|
132
|
-
dbGetStats: {
|
|
133
|
-
success: true,
|
|
134
|
-
stats: {
|
|
135
|
-
database: {
|
|
136
|
-
connected: true,
|
|
137
|
-
bucket: 'test-bucket',
|
|
138
|
-
keyPrefix: 'databases/test',
|
|
139
|
-
version: '7.2.1',
|
|
140
|
-
resourceCount: 2,
|
|
141
|
-
resources: ['users', 'posts']
|
|
142
|
-
},
|
|
143
|
-
costs: {
|
|
144
|
-
total: 0.000042,
|
|
145
|
-
totalRequests: 156,
|
|
146
|
-
requestsByType: { get: 89, put: 45, list: 12, delete: 10 },
|
|
147
|
-
eventsByType: { GetObjectCommand: 89, PutObjectCommand: 45 },
|
|
148
|
-
estimatedCostUSD: 0.000042
|
|
149
|
-
},
|
|
150
|
-
cache: {
|
|
151
|
-
enabled: true,
|
|
152
|
-
driver: 'FilesystemCache',
|
|
153
|
-
size: 23,
|
|
154
|
-
directory: './test-cache',
|
|
155
|
-
ttl: 300000,
|
|
156
|
-
keyCount: 23,
|
|
157
|
-
sampleKeys: ['resource=users/action=list.json.gz', 'resource=posts/action=count.json.gz']
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
},
|
|
161
|
-
|
|
162
|
-
dbClearCache: {
|
|
163
|
-
success: true,
|
|
164
|
-
message: args.resourceName
|
|
165
|
-
? `Cache cleared for resource: ${args.resourceName}`
|
|
166
|
-
: 'All cache cleared'
|
|
167
|
-
}
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
const response = mockResponses[name] || { success: false, error: 'Tool not found' };
|
|
171
|
-
|
|
172
|
-
console.log(`š¤ Response:`, JSON.stringify(response, null, 2));
|
|
173
|
-
return response;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
// Test scenarios
|
|
178
|
-
async function runTests() {
|
|
179
|
-
console.log('š§Ŗ S3DB MCP Server Test Suite');
|
|
180
|
-
console.log('================================\n');
|
|
181
|
-
|
|
182
|
-
const client = new MockMCPClient('http://localhost:8000/sse');
|
|
183
|
-
|
|
184
|
-
try {
|
|
185
|
-
// Initialize client
|
|
186
|
-
await client.initialize();
|
|
187
|
-
|
|
188
|
-
// Test 1: Connect to database
|
|
189
|
-
console.log('\nš Test 1: Database Connection');
|
|
190
|
-
console.log('-------------------------------');
|
|
191
|
-
await client.callTool('dbConnect', {
|
|
192
|
-
connectionString: 's3://test-key:test-secret@test-bucket/databases/demo',
|
|
193
|
-
verbose: false,
|
|
194
|
-
parallelism: 10,
|
|
195
|
-
enableCache: true,
|
|
196
|
-
enableCosts: true,
|
|
197
|
-
cacheDriver: 'filesystem', // Test filesystem cache
|
|
198
|
-
cacheDirectory: './test-cache',
|
|
199
|
-
cachePrefix: 'test',
|
|
200
|
-
cacheTtl: 300000
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
// Test 2: Check database status
|
|
204
|
-
console.log('\nš Test 2: Database Status');
|
|
205
|
-
console.log('---------------------------');
|
|
206
|
-
await client.callTool('dbStatus');
|
|
207
|
-
|
|
208
|
-
// Test 3: Create a resource
|
|
209
|
-
console.log('\nš Test 3: Create Resource');
|
|
210
|
-
console.log('---------------------------');
|
|
211
|
-
await client.callTool('dbCreateResource', {
|
|
212
|
-
name: 'users',
|
|
213
|
-
attributes: {
|
|
214
|
-
name: 'string|required',
|
|
215
|
-
email: 'email|required|unique',
|
|
216
|
-
age: 'number|positive',
|
|
217
|
-
profile: {
|
|
218
|
-
bio: 'string|optional',
|
|
219
|
-
avatar: 'url|optional'
|
|
220
|
-
}
|
|
221
|
-
},
|
|
222
|
-
behavior: 'user-managed',
|
|
223
|
-
timestamps: true,
|
|
224
|
-
partitions: {
|
|
225
|
-
byAge: {
|
|
226
|
-
fields: { ageGroup: 'string' }
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
});
|
|
230
|
-
|
|
231
|
-
// Test 4: List resources
|
|
232
|
-
console.log('\nš Test 4: List Resources');
|
|
233
|
-
console.log('--------------------------');
|
|
234
|
-
await client.callTool('dbListResources');
|
|
235
|
-
|
|
236
|
-
// Test 5: Insert data
|
|
237
|
-
console.log('\nš Test 5: Insert Document');
|
|
238
|
-
console.log('---------------------------');
|
|
239
|
-
await client.callTool('resourceInsert', {
|
|
240
|
-
resourceName: 'users',
|
|
241
|
-
data: {
|
|
242
|
-
name: 'John Doe',
|
|
243
|
-
email: 'john@example.com',
|
|
244
|
-
age: 30,
|
|
245
|
-
profile: {
|
|
246
|
-
bio: 'Software developer and AI enthusiast',
|
|
247
|
-
avatar: 'https://example.com/avatar.jpg'
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
// Test 6: Get document
|
|
253
|
-
console.log('\nš Test 6: Get Document');
|
|
254
|
-
console.log('------------------------');
|
|
255
|
-
await client.callTool('resourceGet', {
|
|
256
|
-
resourceName: 'users',
|
|
257
|
-
id: 'doc_123'
|
|
258
|
-
});
|
|
259
|
-
|
|
260
|
-
// Test 7: List documents
|
|
261
|
-
console.log('\nš Test 7: List Documents');
|
|
262
|
-
console.log('--------------------------');
|
|
263
|
-
await client.callTool('resourceList', {
|
|
264
|
-
resourceName: 'users',
|
|
265
|
-
limit: 10,
|
|
266
|
-
offset: 0
|
|
267
|
-
});
|
|
268
|
-
|
|
269
|
-
// Test 8: Count documents
|
|
270
|
-
console.log('\nš Test 8: Count Documents');
|
|
271
|
-
console.log('---------------------------');
|
|
272
|
-
await client.callTool('resourceCount', {
|
|
273
|
-
resourceName: 'users'
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
// Test 9: Get database statistics
|
|
277
|
-
console.log('\nš Test 9: Database Statistics');
|
|
278
|
-
console.log('-------------------------------');
|
|
279
|
-
await client.callTool('dbGetStats');
|
|
280
|
-
|
|
281
|
-
// Test 10: Clear cache
|
|
282
|
-
console.log('\nš Test 10: Clear Cache');
|
|
283
|
-
console.log('------------------------');
|
|
284
|
-
await client.callTool('dbClearCache', {
|
|
285
|
-
resourceName: 'users'
|
|
286
|
-
});
|
|
287
|
-
|
|
288
|
-
console.log('\nā
All tests completed successfully!');
|
|
289
|
-
console.log('\nš” To run against a real S3DB MCP server:');
|
|
290
|
-
console.log(' 1. Start the server: npm start');
|
|
291
|
-
console.log(' 2. Configure your .env file');
|
|
292
|
-
console.log(' 3. Use a real MCP client to connect');
|
|
293
|
-
|
|
294
|
-
} catch (error) {
|
|
295
|
-
console.error('\nā Test failed:', error.message);
|
|
296
|
-
process.exit(1);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
// Real MCP client example (commented out - requires actual MCP client library)
|
|
301
|
-
async function realMCPExample() {
|
|
302
|
-
console.log('\nš Real MCP Client Example');
|
|
303
|
-
console.log('===========================');
|
|
304
|
-
|
|
305
|
-
console.log(`
|
|
306
|
-
This is how you would connect to a real S3DB MCP server:
|
|
307
|
-
|
|
308
|
-
import { MCPClient } from '@modelcontextprotocol/client';
|
|
309
|
-
|
|
310
|
-
const client = new MCPClient({
|
|
311
|
-
transport: 'sse',
|
|
312
|
-
url: 'http://localhost:8000/sse'
|
|
313
|
-
});
|
|
314
|
-
|
|
315
|
-
await client.connect();
|
|
316
|
-
|
|
317
|
-
// Connect to S3DB
|
|
318
|
-
const result = await client.callTool('dbConnect', {
|
|
319
|
-
connectionString: process.env.S3DB_CONNECTION_STRING
|
|
320
|
-
});
|
|
321
|
-
|
|
322
|
-
// Create a resource
|
|
323
|
-
await client.callTool('dbCreateResource', {
|
|
324
|
-
name: 'products',
|
|
325
|
-
attributes: {
|
|
326
|
-
name: 'string|required',
|
|
327
|
-
price: 'number|positive|required',
|
|
328
|
-
category: 'string|required'
|
|
329
|
-
},
|
|
330
|
-
timestamps: true
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
// Insert data
|
|
334
|
-
await client.callTool('resourceInsert', {
|
|
335
|
-
resourceName: 'products',
|
|
336
|
-
data: {
|
|
337
|
-
name: 'Laptop Pro',
|
|
338
|
-
price: 1299.99,
|
|
339
|
-
category: 'electronics'
|
|
340
|
-
}
|
|
341
|
-
});
|
|
342
|
-
`);
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
// Configuration examples
|
|
346
|
-
function showConfigurationExamples() {
|
|
347
|
-
console.log('\nāļø Configuration Examples');
|
|
348
|
-
console.log('===========================');
|
|
349
|
-
|
|
350
|
-
console.log(`
|
|
351
|
-
# AWS S3 Configuration
|
|
352
|
-
S3DB_CONNECTION_STRING=s3://ACCESS_KEY:SECRET_KEY@bucket/databases/myapp
|
|
353
|
-
|
|
354
|
-
# MinIO Configuration (local development)
|
|
355
|
-
S3DB_CONNECTION_STRING=s3://minioadmin:minioadmin@test-bucket/databases/dev?endpoint=http://localhost:9000&forcePathStyle=true
|
|
356
|
-
|
|
357
|
-
# DigitalOcean Spaces Configuration
|
|
358
|
-
S3DB_CONNECTION_STRING=s3://DO_KEY:DO_SECRET@space-name/databases/prod?endpoint=https://nyc3.digitaloceanspaces.com
|
|
359
|
-
|
|
360
|
-
# Claude Desktop Configuration (claude_desktop_config.json)
|
|
361
|
-
{
|
|
362
|
-
"mcpServers": {
|
|
363
|
-
"s3db": {
|
|
364
|
-
"transport": "sse",
|
|
365
|
-
"url": "http://localhost:8000/sse"
|
|
366
|
-
}
|
|
367
|
-
}
|
|
368
|
-
}
|
|
369
|
-
|
|
370
|
-
# Cursor IDE Configuration
|
|
371
|
-
{
|
|
372
|
-
"mcpServers": {
|
|
373
|
-
"s3db": {
|
|
374
|
-
"url": "http://localhost:8000/sse"
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
`);
|
|
379
|
-
}
|
|
380
|
-
|
|
381
|
-
// Main execution
|
|
382
|
-
async function main() {
|
|
383
|
-
const args = process.argv.slice(2);
|
|
384
|
-
|
|
385
|
-
if (args.includes('--help') || args.includes('-h')) {
|
|
386
|
-
console.log(`
|
|
387
|
-
S3DB MCP Server Test Script
|
|
388
|
-
|
|
389
|
-
Usage:
|
|
390
|
-
node test-mcp.js [options]
|
|
391
|
-
|
|
392
|
-
Options:
|
|
393
|
-
--help, -h Show this help message
|
|
394
|
-
--config Show configuration examples
|
|
395
|
-
--real Show real MCP client examples
|
|
396
|
-
|
|
397
|
-
Examples:
|
|
398
|
-
node test-mcp.js # Run mock tests
|
|
399
|
-
node test-mcp.js --config # Show configuration examples
|
|
400
|
-
node test-mcp.js --real # Show real client examples
|
|
401
|
-
`);
|
|
402
|
-
return;
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
if (args.includes('--config')) {
|
|
406
|
-
showConfigurationExamples();
|
|
407
|
-
return;
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
if (args.includes('--real')) {
|
|
411
|
-
await realMCPExample();
|
|
412
|
-
return;
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
// Run the test suite
|
|
416
|
-
await runTests();
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
// Handle errors
|
|
420
|
-
process.on('unhandledRejection', (error) => {
|
|
421
|
-
console.error('ā Unhandled rejection:', error);
|
|
422
|
-
process.exit(1);
|
|
423
|
-
});
|
|
424
|
-
|
|
425
|
-
process.on('uncaughtException', (error) => {
|
|
426
|
-
console.error('ā Uncaught exception:', error);
|
|
427
|
-
process.exit(1);
|
|
428
|
-
});
|
|
429
|
-
|
|
430
|
-
// Run main function
|
|
431
|
-
if (import.meta.url === `file://${process.argv[1]}`) {
|
|
432
|
-
main().catch(console.error);
|
|
433
|
-
}
|
package/mcp/package.json
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "s3db-mcp-server",
|
|
3
|
-
"version": "1.0.0",
|
|
4
|
-
"description": "Model Context Protocol (MCP) server for S3DB - Transform AWS S3 into a powerful document database",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"main": "s3db_mcp_server.js",
|
|
7
|
-
"bin": {
|
|
8
|
-
"s3db-mcp": "./s3db_mcp_server.js"
|
|
9
|
-
},
|
|
10
|
-
"scripts": {
|
|
11
|
-
"start": "node s3db_mcp_server.js",
|
|
12
|
-
"start:sse": "node s3db_mcp_server.js --transport=sse",
|
|
13
|
-
"start:stdio": "node s3db_mcp_server.js --transport=stdio",
|
|
14
|
-
"dev": "node --watch s3db_mcp_server.js --transport=sse",
|
|
15
|
-
"docker:build": "docker build -t s3db-mcp-server .",
|
|
16
|
-
"docker:run": "docker run -p 8000:8000 --env-file .env s3db-mcp-server",
|
|
17
|
-
"docker:compose": "docker compose up",
|
|
18
|
-
"docker:compose:build": "docker compose up --build",
|
|
19
|
-
"test": "echo 'Tests coming soon!' && exit 0"
|
|
20
|
-
},
|
|
21
|
-
"keywords": [
|
|
22
|
-
"mcp",
|
|
23
|
-
"model-context-protocol",
|
|
24
|
-
"s3db",
|
|
25
|
-
"s3",
|
|
26
|
-
"aws",
|
|
27
|
-
"database",
|
|
28
|
-
"document-database",
|
|
29
|
-
"ai-agent",
|
|
30
|
-
"llm"
|
|
31
|
-
],
|
|
32
|
-
"author": "S3DB Community",
|
|
33
|
-
"license": "UNLICENSED",
|
|
34
|
-
"repository": {
|
|
35
|
-
"type": "git",
|
|
36
|
-
"url": "git+https://github.com/forattini-dev/s3db.js.git",
|
|
37
|
-
"directory": "mcp-server"
|
|
38
|
-
},
|
|
39
|
-
"bugs": {
|
|
40
|
-
"url": "https://github.com/forattini-dev/s3db.js/issues"
|
|
41
|
-
},
|
|
42
|
-
"homepage": "https://github.com/forattini-dev/s3db.js/tree/main/mcp-server#readme",
|
|
43
|
-
"engines": {
|
|
44
|
-
"node": ">=18.0.0"
|
|
45
|
-
},
|
|
46
|
-
"dependencies": {
|
|
47
|
-
"@modelcontextprotocol/sdk": "^1.0.0",
|
|
48
|
-
"s3db.js": "^7.2.1",
|
|
49
|
-
"dotenv": "^16.4.5"
|
|
50
|
-
},
|
|
51
|
-
"devDependencies": {
|
|
52
|
-
"@types/node": "^20.11.0"
|
|
53
|
-
},
|
|
54
|
-
"files": [
|
|
55
|
-
"s3db_mcp_server.js",
|
|
56
|
-
"README.md",
|
|
57
|
-
"Dockerfile",
|
|
58
|
-
"docker-compose.yml",
|
|
59
|
-
".env.example",
|
|
60
|
-
"Makefile",
|
|
61
|
-
"examples/"
|
|
62
|
-
],
|
|
63
|
-
"publishConfig": {
|
|
64
|
-
"access": "public"
|
|
65
|
-
}
|
|
66
|
-
}
|