@yunsoft/yuncms-api 0.1.6 → 0.1.7
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 +2 -2
- package/src/mcp.js +1 -1
- package/src/pressure-limit.js +7 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yunsoft/yuncms-api",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "Express API runtime and bundled Studio server for YunCMS.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
"@modelcontextprotocol/node": "2.0.0",
|
|
36
36
|
"@modelcontextprotocol/server": "2.0.0",
|
|
37
37
|
"@node-saml/node-saml": "5.1.0",
|
|
38
|
-
"@yunsoft/yuncms-core": "0.1.
|
|
38
|
+
"@yunsoft/yuncms-core": "0.1.7",
|
|
39
39
|
"express": "5.2.1",
|
|
40
40
|
"ldapts": "9.0.0",
|
|
41
41
|
"openid-client": "6.8.7",
|
package/src/mcp.js
CHANGED
|
@@ -291,7 +291,7 @@ export function registerMcpTools(server, req, {
|
|
|
291
291
|
|
|
292
292
|
export function createRequestMcpServer(req, mcpConfig = {}) {
|
|
293
293
|
const server = new McpServer(
|
|
294
|
-
{ name: 'yuncms', version: '0.1.
|
|
294
|
+
{ name: 'yuncms', version: '0.1.7' },
|
|
295
295
|
{
|
|
296
296
|
instructions: mcpConfig.writesEnabled
|
|
297
297
|
? 'Use schema tools before item tools when the collection shape is unknown. YunCMS RBAC applies to every tool call.'
|
package/src/pressure-limit.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getHeapStatistics } from 'node:v8';
|
|
2
|
+
|
|
1
3
|
function assertPositiveInteger(value, name) {
|
|
2
4
|
if (!Number.isInteger(value) || value < 1) throw new Error(`${name} must be a positive integer`);
|
|
3
5
|
}
|
|
@@ -8,6 +10,7 @@ export function createPressureLimit({
|
|
|
8
10
|
maxHeapPercent = 95,
|
|
9
11
|
retryAfterSeconds = 1,
|
|
10
12
|
memoryUsage = () => process.memoryUsage(),
|
|
13
|
+
heapSizeLimit = () => getHeapStatistics().heap_size_limit,
|
|
11
14
|
} = {}) {
|
|
12
15
|
if (!enabled) return null;
|
|
13
16
|
assertPositiveInteger(maxConcurrent, 'Pressure maxConcurrent');
|
|
@@ -15,13 +18,15 @@ export function createPressureLimit({
|
|
|
15
18
|
if (maxHeapPercent > 100) throw new Error('Pressure maxHeapPercent cannot exceed 100');
|
|
16
19
|
assertPositiveInteger(retryAfterSeconds, 'Pressure retryAfterSeconds');
|
|
17
20
|
if (typeof memoryUsage !== 'function') throw new Error('Pressure memoryUsage must be a function');
|
|
21
|
+
if (typeof heapSizeLimit !== 'function') throw new Error('Pressure heapSizeLimit must be a function');
|
|
18
22
|
|
|
19
23
|
let inFlight = 0;
|
|
20
24
|
|
|
21
25
|
return (req, res, next) => {
|
|
22
26
|
const memory = memoryUsage();
|
|
23
|
-
const
|
|
24
|
-
|
|
27
|
+
const heapLimit = heapSizeLimit();
|
|
28
|
+
const heapPercent = Number.isFinite(heapLimit) && heapLimit > 0
|
|
29
|
+
? (memory.heapUsed / heapLimit) * 100
|
|
25
30
|
: 0;
|
|
26
31
|
const overloaded = inFlight >= maxConcurrent || heapPercent >= maxHeapPercent;
|
|
27
32
|
|