@dypai-ai/mcp 1.3.0 → 1.4.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/package.json +1 -1
- package/src/api.js +21 -3
- package/src/index.js +402 -347
- package/src/tools/deploy.js +450 -103
- package/src/tools/storage.js +289 -0
- package/src/tools/sync/describe.js +4 -2
- package/src/tools/sync/planner.js +8 -3
- package/src/tools/sync/pull.js +32 -4
- package/src/tools/sync/schema-dump.js +7 -1
- package/src/tools/sync.js +23 -1
package/package.json
CHANGED
package/src/api.js
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* DYPAI API Client — HTTP client for the DYPAI control plane.
|
|
3
3
|
* All MCP tools that need backend data go through here.
|
|
4
|
+
*
|
|
5
|
+
* Bodies are gzip-compressed when > 1 KB. Typical deploy payloads
|
|
6
|
+
* (30 MB JSON) compress to ~8 MB — same savings as ZIP with zero
|
|
7
|
+
* format changes. The API must accept Content-Encoding: gzip.
|
|
4
8
|
*/
|
|
5
9
|
|
|
6
10
|
import https from "https"
|
|
7
11
|
import http from "http"
|
|
12
|
+
import { gzipSync } from "zlib"
|
|
8
13
|
|
|
9
14
|
const DEFAULT_API_URL = "https://dyapi.dypai.dev"
|
|
15
|
+
const GZIP_THRESHOLD = 1024 // only compress bodies > 1 KB
|
|
10
16
|
|
|
11
17
|
function getConfig() {
|
|
12
18
|
return {
|
|
@@ -22,12 +28,24 @@ export function request(method, path, body) {
|
|
|
22
28
|
return new Promise((resolve, reject) => {
|
|
23
29
|
const parsed = new URL(url)
|
|
24
30
|
const mod = parsed.protocol === "https:" ? https : http
|
|
25
|
-
const
|
|
31
|
+
const jsonStr = body ? JSON.stringify(body) : null
|
|
32
|
+
|
|
33
|
+
let payload = jsonStr ? Buffer.from(jsonStr) : null
|
|
34
|
+
let useGzip = false
|
|
35
|
+
|
|
36
|
+
if (payload && payload.length > GZIP_THRESHOLD) {
|
|
37
|
+
payload = gzipSync(payload)
|
|
38
|
+
useGzip = true
|
|
39
|
+
}
|
|
40
|
+
|
|
26
41
|
const headers = {
|
|
27
42
|
Authorization: `Bearer ${token}`,
|
|
28
43
|
"Content-Type": "application/json",
|
|
29
44
|
}
|
|
30
|
-
if (
|
|
45
|
+
if (payload) {
|
|
46
|
+
headers["Content-Length"] = payload.length
|
|
47
|
+
if (useGzip) headers["Content-Encoding"] = "gzip"
|
|
48
|
+
}
|
|
31
49
|
|
|
32
50
|
const req = mod.request({
|
|
33
51
|
hostname: parsed.hostname,
|
|
@@ -47,7 +65,7 @@ export function request(method, path, body) {
|
|
|
47
65
|
})
|
|
48
66
|
})
|
|
49
67
|
req.on("error", reject)
|
|
50
|
-
if (
|
|
68
|
+
if (payload) req.write(payload)
|
|
51
69
|
req.end()
|
|
52
70
|
})
|
|
53
71
|
}
|