s3db.js 11.2.6 → 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/README.md +138 -0
- package/dist/s3db.cjs.js +2 -2
- package/dist/s3db.es.js +2 -2
- package/mcp/.env.example +117 -0
- package/mcp/{server.js → entrypoint.js} +1941 -683
- package/mcp/tools/bulk.js +112 -0
- package/mcp/tools/connection.js +228 -0
- package/mcp/tools/crud.js +579 -0
- package/mcp/tools/debugging.js +299 -0
- package/mcp/tools/export-import.js +281 -0
- package/mcp/tools/index.js +67 -0
- package/mcp/tools/partitions.js +223 -0
- package/mcp/tools/query.js +150 -0
- package/mcp/tools/resources.js +96 -0
- package/mcp/tools/stats.js +281 -0
- package/package.json +17 -7
- package/src/database.class.js +1 -1
package/README.md
CHANGED
|
@@ -110,6 +110,7 @@
|
|
|
110
110
|
- [🎣 Advanced Hooks System](#-advanced-hooks-system)
|
|
111
111
|
- [🧩 Resource Middlewares](#-resource-middlewares)
|
|
112
112
|
- [🎧 Event Listeners Configuration](#-event-listeners-configuration)
|
|
113
|
+
- [🤖 MCP Server](#-mcp-server)
|
|
113
114
|
- [🔧 Troubleshooting](#-troubleshooting)
|
|
114
115
|
- [📖 API Reference](#-api-reference)
|
|
115
116
|
|
|
@@ -1866,6 +1867,143 @@ await users.insert({ name: 'John' });
|
|
|
1866
1867
|
|
|
1867
1868
|
---
|
|
1868
1869
|
|
|
1870
|
+
## 🤖 MCP Server
|
|
1871
|
+
|
|
1872
|
+
S3DB includes a powerful **Model Context Protocol (MCP) server** that enables AI assistants like Claude to interact with your S3DB databases. The MCP server provides **28 specialized tools** for database operations, debugging, monitoring, and data management.
|
|
1873
|
+
|
|
1874
|
+
### ⚡ Quick Start with npx
|
|
1875
|
+
|
|
1876
|
+
**For Claude CLI** (one command setup):
|
|
1877
|
+
```bash
|
|
1878
|
+
claude mcp add s3db \
|
|
1879
|
+
--transport stdio \
|
|
1880
|
+
-- npx -y s3db.js s3db-mcp --transport=stdio
|
|
1881
|
+
```
|
|
1882
|
+
|
|
1883
|
+
**For Claude Desktop** - Add to `~/Library/Application Support/Claude/claude_desktop_config.json`:
|
|
1884
|
+
```json
|
|
1885
|
+
{
|
|
1886
|
+
"mcpServers": {
|
|
1887
|
+
"s3db": {
|
|
1888
|
+
"command": "npx",
|
|
1889
|
+
"args": ["-y", "s3db.js", "s3db-mcp", "--transport=sse"],
|
|
1890
|
+
"env": {
|
|
1891
|
+
"S3DB_CONNECTION_STRING": "s3://ACCESS_KEY:SECRET_KEY@bucket/databases/myapp",
|
|
1892
|
+
"S3DB_CACHE_ENABLED": "true",
|
|
1893
|
+
"S3DB_COSTS_ENABLED": "true"
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
}
|
|
1897
|
+
}
|
|
1898
|
+
```
|
|
1899
|
+
|
|
1900
|
+
**Standalone Server:**
|
|
1901
|
+
```bash
|
|
1902
|
+
# Start HTTP server
|
|
1903
|
+
npx s3db.js s3db-mcp --transport=sse
|
|
1904
|
+
```
|
|
1905
|
+
|
|
1906
|
+
📖 **Complete setup guides:**
|
|
1907
|
+
- [NPX Setup Guide](./mcp/NPX_SETUP.md) - Use with `npx` (recommended)
|
|
1908
|
+
- [Claude CLI Setup](./mcp/CLAUDE_CLI_SETUP.md) - Detailed configuration
|
|
1909
|
+
|
|
1910
|
+
### Available Tools
|
|
1911
|
+
|
|
1912
|
+
The MCP server provides 28 tools organized into 7 categories:
|
|
1913
|
+
|
|
1914
|
+
#### 🔌 **Connection Management** (3 tools)
|
|
1915
|
+
- `dbConnect` - Connect with cache and costs tracking
|
|
1916
|
+
- `dbDisconnect` - Graceful disconnection
|
|
1917
|
+
- `dbStatus` - Check connection status
|
|
1918
|
+
|
|
1919
|
+
#### 🔍 **Debugging Tools** (5 tools)
|
|
1920
|
+
- `dbInspectResource` - Deep resource inspection
|
|
1921
|
+
- `dbGetMetadata` - View raw metadata.json
|
|
1922
|
+
- `resourceValidate` - Validate data against schema
|
|
1923
|
+
- `dbHealthCheck` - Comprehensive health check
|
|
1924
|
+
- `resourceGetRaw` - View raw S3 object data
|
|
1925
|
+
|
|
1926
|
+
#### 📊 **Query & Filtering** (2 tools)
|
|
1927
|
+
- `resourceQuery` - Complex queries with filters
|
|
1928
|
+
- `resourceSearch` - Full-text search
|
|
1929
|
+
|
|
1930
|
+
#### 🔧 **Partition Management** (4 tools)
|
|
1931
|
+
- `resourceListPartitions` - List all partitions
|
|
1932
|
+
- `resourceListPartitionValues` - Get partition values
|
|
1933
|
+
- `dbFindOrphanedPartitions` - Detect orphaned partitions
|
|
1934
|
+
- `dbRemoveOrphanedPartitions` - Clean up orphaned partitions
|
|
1935
|
+
|
|
1936
|
+
#### 🚀 **Bulk Operations** (3 tools)
|
|
1937
|
+
- `resourceUpdateMany` - Update with filters
|
|
1938
|
+
- `resourceBulkUpsert` - Bulk upsert operations
|
|
1939
|
+
- `resourceDeleteAll` - Delete all documents
|
|
1940
|
+
|
|
1941
|
+
#### 💾 **Export/Import** (3 tools)
|
|
1942
|
+
- `resourceExport` - Export to JSON/CSV/NDJSON
|
|
1943
|
+
- `resourceImport` - Import from JSON/NDJSON
|
|
1944
|
+
- `dbBackupMetadata` - Create metadata backups
|
|
1945
|
+
|
|
1946
|
+
#### 📈 **Monitoring** (4 tools)
|
|
1947
|
+
- `dbGetStats` - Database statistics
|
|
1948
|
+
- `resourceGetStats` - Resource-specific stats
|
|
1949
|
+
- `cacheGetStats` - Cache performance metrics
|
|
1950
|
+
- `dbClearCache` - Clear cache
|
|
1951
|
+
|
|
1952
|
+
Plus **standard CRUD operations**: insert, get, update, delete, list, count, and more.
|
|
1953
|
+
|
|
1954
|
+
### Features
|
|
1955
|
+
|
|
1956
|
+
- ✅ **Automatic Performance**: Cache and cost tracking enabled by default
|
|
1957
|
+
- ✅ **Multiple Transports**: SSE for web clients, stdio for CLI
|
|
1958
|
+
- ✅ **Partition-Aware**: Intelligent caching with partition support
|
|
1959
|
+
- ✅ **Debugging**: Comprehensive tools for troubleshooting
|
|
1960
|
+
- ✅ **Bulk Operations**: Efficient batch processing
|
|
1961
|
+
- ✅ **Export/Import**: Data migration and backup
|
|
1962
|
+
|
|
1963
|
+
### Full Documentation
|
|
1964
|
+
|
|
1965
|
+
**Complete MCP documentation**: [**docs/mcp.md**](./docs/mcp.md)
|
|
1966
|
+
|
|
1967
|
+
Includes:
|
|
1968
|
+
- Tool reference with all 28 tools
|
|
1969
|
+
- Configuration examples (AWS, MinIO, DigitalOcean)
|
|
1970
|
+
- Docker deployment guides
|
|
1971
|
+
- Performance optimization
|
|
1972
|
+
- Troubleshooting
|
|
1973
|
+
- Security best practices
|
|
1974
|
+
|
|
1975
|
+
### Example Usage
|
|
1976
|
+
|
|
1977
|
+
```javascript
|
|
1978
|
+
// Connect to database
|
|
1979
|
+
await dbConnect({
|
|
1980
|
+
connectionString: "s3://bucket/databases/app",
|
|
1981
|
+
enableCache: true,
|
|
1982
|
+
enableCosts: true
|
|
1983
|
+
})
|
|
1984
|
+
|
|
1985
|
+
// Inspect resource
|
|
1986
|
+
await dbInspectResource({ resourceName: "users" })
|
|
1987
|
+
|
|
1988
|
+
// Query with filters
|
|
1989
|
+
await resourceQuery({
|
|
1990
|
+
resourceName: "users",
|
|
1991
|
+
filters: { status: "active", age: { $gt: 18 } }
|
|
1992
|
+
})
|
|
1993
|
+
|
|
1994
|
+
// Export data
|
|
1995
|
+
await resourceExport({
|
|
1996
|
+
resourceName: "users",
|
|
1997
|
+
format: "csv",
|
|
1998
|
+
filters: { status: "active" }
|
|
1999
|
+
})
|
|
2000
|
+
|
|
2001
|
+
// Check health
|
|
2002
|
+
await dbHealthCheck({ includeOrphanedPartitions: true })
|
|
2003
|
+
```
|
|
2004
|
+
|
|
2005
|
+
---
|
|
2006
|
+
|
|
1869
2007
|
## 📖 API Reference
|
|
1870
2008
|
|
|
1871
2009
|
### 📚 Core Classes Documentation
|
package/dist/s3db.cjs.js
CHANGED
|
@@ -15283,7 +15283,7 @@ class Database extends EventEmitter {
|
|
|
15283
15283
|
this.id = idGenerator(7);
|
|
15284
15284
|
this.version = "1";
|
|
15285
15285
|
this.s3dbVersion = (() => {
|
|
15286
|
-
const [ok, err, version] = tryFn(() => true ? "11.2
|
|
15286
|
+
const [ok, err, version] = tryFn(() => true ? "11.3.2" : "latest");
|
|
15287
15287
|
return ok ? version : "latest";
|
|
15288
15288
|
})();
|
|
15289
15289
|
this.resources = {};
|
|
@@ -16087,7 +16087,7 @@ class Database extends EventEmitter {
|
|
|
16087
16087
|
autoDecrypt: config.autoDecrypt !== void 0 ? config.autoDecrypt : true,
|
|
16088
16088
|
hooks: hooks || {},
|
|
16089
16089
|
versioningEnabled: this.versioningEnabled,
|
|
16090
|
-
strictValidation: this.strictValidation,
|
|
16090
|
+
strictValidation: config.strictValidation !== void 0 ? config.strictValidation : this.strictValidation,
|
|
16091
16091
|
map: config.map,
|
|
16092
16092
|
idGenerator: config.idGenerator,
|
|
16093
16093
|
idSize: config.idSize,
|
package/dist/s3db.es.js
CHANGED
|
@@ -15279,7 +15279,7 @@ class Database extends EventEmitter {
|
|
|
15279
15279
|
this.id = idGenerator(7);
|
|
15280
15280
|
this.version = "1";
|
|
15281
15281
|
this.s3dbVersion = (() => {
|
|
15282
|
-
const [ok, err, version] = tryFn(() => true ? "11.2
|
|
15282
|
+
const [ok, err, version] = tryFn(() => true ? "11.3.2" : "latest");
|
|
15283
15283
|
return ok ? version : "latest";
|
|
15284
15284
|
})();
|
|
15285
15285
|
this.resources = {};
|
|
@@ -16083,7 +16083,7 @@ class Database extends EventEmitter {
|
|
|
16083
16083
|
autoDecrypt: config.autoDecrypt !== void 0 ? config.autoDecrypt : true,
|
|
16084
16084
|
hooks: hooks || {},
|
|
16085
16085
|
versioningEnabled: this.versioningEnabled,
|
|
16086
|
-
strictValidation: this.strictValidation,
|
|
16086
|
+
strictValidation: config.strictValidation !== void 0 ? config.strictValidation : this.strictValidation,
|
|
16087
16087
|
map: config.map,
|
|
16088
16088
|
idGenerator: config.idGenerator,
|
|
16089
16089
|
idSize: config.idSize,
|
package/mcp/.env.example
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# ==============================================================================
|
|
2
|
+
# S3DB MCP Server Configuration
|
|
3
|
+
# ==============================================================================
|
|
4
|
+
|
|
5
|
+
# Server Configuration
|
|
6
|
+
NODE_ENV=development
|
|
7
|
+
MCP_SERVER_HOST=0.0.0.0
|
|
8
|
+
MCP_SERVER_PORT=8000
|
|
9
|
+
MCP_TRANSPORT=sse
|
|
10
|
+
|
|
11
|
+
# ==============================================================================
|
|
12
|
+
# S3DB Database Configuration
|
|
13
|
+
# ==============================================================================
|
|
14
|
+
|
|
15
|
+
# Primary S3DB connection string
|
|
16
|
+
# Format: s3://ACCESS_KEY:SECRET_KEY@BUCKET_NAME/database/path
|
|
17
|
+
# Example: s3://AKIAIOSFODNN7EXAMPLE:wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY@my-s3db-bucket/databases/production
|
|
18
|
+
S3DB_CONNECTION_STRING=s3://YOUR_ACCESS_KEY:YOUR_SECRET_KEY@YOUR_BUCKET/databases/development
|
|
19
|
+
|
|
20
|
+
# S3DB Options
|
|
21
|
+
S3DB_VERBOSE=false
|
|
22
|
+
S3DB_PARALLELISM=10
|
|
23
|
+
S3DB_PASSPHRASE=your-encryption-passphrase
|
|
24
|
+
S3DB_VERSIONING_ENABLED=false
|
|
25
|
+
|
|
26
|
+
# Plugin Configuration
|
|
27
|
+
S3DB_COSTS_ENABLED=true # Enable automatic S3 costs tracking
|
|
28
|
+
S3DB_CACHE_ENABLED=true # Enable cache for performance
|
|
29
|
+
S3DB_CACHE_DRIVER=memory # Cache driver: 'memory' or 'filesystem'
|
|
30
|
+
S3DB_CACHE_MAX_SIZE=1000 # Maximum items in memory cache (memory driver only)
|
|
31
|
+
S3DB_CACHE_TTL=300000 # Cache TTL in milliseconds (5 minutes)
|
|
32
|
+
S3DB_CACHE_DIRECTORY=./cache # Directory for filesystem cache (filesystem driver only)
|
|
33
|
+
S3DB_CACHE_PREFIX=s3db # Prefix for cache files (filesystem driver only)
|
|
34
|
+
|
|
35
|
+
# ==============================================================================
|
|
36
|
+
# AWS Configuration
|
|
37
|
+
# ==============================================================================
|
|
38
|
+
|
|
39
|
+
# AWS Credentials (required unless using IAM roles)
|
|
40
|
+
AWS_ACCESS_KEY_ID=AKIAIOSFODNN7EXAMPLE
|
|
41
|
+
AWS_SECRET_ACCESS_KEY=wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
|
|
42
|
+
AWS_SESSION_TOKEN=
|
|
43
|
+
AWS_REGION=us-east-1
|
|
44
|
+
|
|
45
|
+
# ==============================================================================
|
|
46
|
+
# S3-Compatible Services (MinIO, DigitalOcean Spaces, etc.)
|
|
47
|
+
# ==============================================================================
|
|
48
|
+
|
|
49
|
+
# Uncomment and configure for S3-compatible services
|
|
50
|
+
# S3_ENDPOINT=http://localhost:9000
|
|
51
|
+
# S3_FORCE_PATH_STYLE=true
|
|
52
|
+
|
|
53
|
+
# MinIO specific (for local testing)
|
|
54
|
+
# S3_ENDPOINT=http://minio:9000
|
|
55
|
+
# MINIO_ROOT_USER=minioadmin
|
|
56
|
+
# MINIO_ROOT_PASSWORD=minioadmin
|
|
57
|
+
|
|
58
|
+
# DigitalOcean Spaces example
|
|
59
|
+
# S3_ENDPOINT=https://nyc3.digitaloceanspaces.com
|
|
60
|
+
# S3_FORCE_PATH_STYLE=false
|
|
61
|
+
|
|
62
|
+
# ==============================================================================
|
|
63
|
+
# Development & Testing
|
|
64
|
+
# ==============================================================================
|
|
65
|
+
|
|
66
|
+
# LocalStack configuration (for local AWS testing)
|
|
67
|
+
# S3_ENDPOINT=http://localhost:4566
|
|
68
|
+
# S3_FORCE_PATH_STYLE=true
|
|
69
|
+
|
|
70
|
+
# Debug options
|
|
71
|
+
DEBUG=false
|
|
72
|
+
LOG_LEVEL=info
|
|
73
|
+
|
|
74
|
+
# ==============================================================================
|
|
75
|
+
# Example Connection Strings for Different Providers
|
|
76
|
+
# ==============================================================================
|
|
77
|
+
|
|
78
|
+
# AWS S3 (with credentials in connection string)
|
|
79
|
+
# S3DB_CONNECTION_STRING=s3://ACCESS_KEY:SECRET_KEY@bucket-name/databases/myapp
|
|
80
|
+
|
|
81
|
+
# AWS S3 (using IAM roles - no credentials needed)
|
|
82
|
+
# S3DB_CONNECTION_STRING=s3://bucket-name/databases/myapp
|
|
83
|
+
|
|
84
|
+
# MinIO local development
|
|
85
|
+
# S3DB_CONNECTION_STRING=s3://minioadmin:minioadmin@test-bucket/databases/dev?endpoint=http://localhost:9000&forcePathStyle=true
|
|
86
|
+
|
|
87
|
+
# DigitalOcean Spaces
|
|
88
|
+
# S3DB_CONNECTION_STRING=s3://DO_ACCESS_KEY:DO_SECRET_KEY@space-name/databases/prod?endpoint=https://nyc3.digitaloceanspaces.com
|
|
89
|
+
|
|
90
|
+
# LocalStack (local AWS simulation)
|
|
91
|
+
# S3DB_CONNECTION_STRING=s3://test:test@test-bucket/databases/local?endpoint=http://localhost:4566&forcePathStyle=true
|
|
92
|
+
|
|
93
|
+
# ==============================================================================
|
|
94
|
+
# Security Notes
|
|
95
|
+
# ==============================================================================
|
|
96
|
+
|
|
97
|
+
# IMPORTANT SECURITY CONSIDERATIONS:
|
|
98
|
+
# 1. Never commit real credentials to version control
|
|
99
|
+
# 2. Use IAM roles when possible instead of access keys
|
|
100
|
+
# 3. Rotate credentials regularly
|
|
101
|
+
# 4. Use least-privilege access policies
|
|
102
|
+
# 5. Enable S3 bucket encryption and versioning
|
|
103
|
+
# 6. Monitor access logs and CloudTrail events
|
|
104
|
+
# 7. Use strong passphrases for S3DB encryption
|
|
105
|
+
|
|
106
|
+
# ==============================================================================
|
|
107
|
+
# Production Recommendations
|
|
108
|
+
# ==============================================================================
|
|
109
|
+
|
|
110
|
+
# For production environments:
|
|
111
|
+
# - Use IAM roles instead of access keys when possible
|
|
112
|
+
# - Enable S3DB versioning for data protection
|
|
113
|
+
# - Use environment-specific bucket names
|
|
114
|
+
# - Enable comprehensive logging
|
|
115
|
+
# - Set up monitoring and alerting
|
|
116
|
+
# - Use encrypted connections (HTTPS)
|
|
117
|
+
# - Implement backup strategies
|