@dypai-ai/mcp 1.3.1 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dypai-ai/mcp",
3
- "version": "1.3.1",
3
+ "version": "1.4.0",
4
4
  "description": "DYPAI MCP Server — AI agent toolkit for building and deploying full-stack apps",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
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 data = body ? JSON.stringify(body) : null
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 (data) headers["Content-Length"] = Buffer.byteLength(data)
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 (data) req.write(data)
68
+ if (payload) req.write(payload)
51
69
  req.end()
52
70
  })
53
71
  }