@j0hanz/fetch-url-mcp 1.12.7 → 1.12.8
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/http/auth.d.ts +2 -2
- package/dist/http/auth.d.ts.map +1 -1
- package/dist/http/auth.js +4 -5
- package/dist/http/index.d.ts +6 -0
- package/dist/http/index.d.ts.map +1 -0
- package/dist/http/index.js +5 -0
- package/dist/http/native.d.ts +73 -0
- package/dist/http/native.d.ts.map +1 -1
- package/dist/http/native.js +554 -10
- package/dist/http/rate-limit.d.ts +1 -1
- package/dist/http/rate-limit.d.ts.map +1 -1
- package/dist/http/rate-limit.js +3 -4
- package/dist/index.d.ts +17 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +67 -6
- package/dist/lib/config.js +2 -2
- package/dist/lib/core.d.ts +56 -4
- package/dist/lib/core.d.ts.map +1 -1
- package/dist/lib/core.js +155 -4
- package/dist/lib/error/classes.d.ts +19 -0
- package/dist/lib/error/classes.d.ts.map +1 -0
- package/dist/lib/error/classes.js +107 -0
- package/dist/lib/error/classify.d.ts +4 -0
- package/dist/lib/error/classify.d.ts.map +1 -0
- package/dist/lib/error/classify.js +154 -0
- package/dist/lib/error/codes.d.ts +23 -0
- package/dist/lib/error/codes.d.ts.map +1 -0
- package/dist/lib/error/codes.js +22 -0
- package/dist/lib/error/index.d.ts +6 -0
- package/dist/lib/error/index.d.ts.map +1 -0
- package/dist/lib/error/index.js +5 -0
- package/dist/lib/{error-messages.d.ts → error/messages.d.ts} +2 -2
- package/dist/lib/error/messages.d.ts.map +1 -0
- package/dist/lib/{error-messages.js → error/messages.js} +2 -2
- package/dist/lib/{tool-errors.d.ts → error/payload.d.ts} +7 -13
- package/dist/lib/error/payload.d.ts.map +1 -0
- package/dist/lib/error/payload.js +108 -0
- package/dist/lib/mcp-interop.d.ts.map +1 -1
- package/dist/lib/mcp-interop.js +4 -6
- package/dist/lib/net/http.d.ts.map +1 -0
- package/dist/lib/{http.js → net/http.js} +4 -7
- package/dist/lib/net/index.d.ts +4 -0
- package/dist/lib/net/index.d.ts.map +1 -0
- package/dist/lib/net/index.js +3 -0
- package/dist/lib/{fetch-pipeline.d.ts → net/pipeline.d.ts} +3 -3
- package/dist/lib/net/pipeline.d.ts.map +1 -0
- package/dist/lib/{fetch-pipeline.js → net/pipeline.js} +3 -5
- package/dist/lib/{url.d.ts → net/url.d.ts} +1 -1
- package/dist/lib/net/url.d.ts.map +1 -0
- package/dist/lib/{url.js → net/url.js} +3 -5
- package/dist/lib/utils.d.ts +2 -18
- package/dist/lib/utils.d.ts.map +1 -1
- package/dist/lib/utils.js +29 -104
- package/dist/resources/index.d.ts.map +1 -1
- package/dist/resources/index.js +8 -5
- package/dist/schemas.d.ts +1 -1
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +7 -9
- package/dist/tasks/index.d.ts +2 -0
- package/dist/tasks/index.d.ts.map +1 -0
- package/dist/tasks/index.js +1 -0
- package/dist/tasks/manager.d.ts +123 -1
- package/dist/tasks/manager.d.ts.map +1 -1
- package/dist/tasks/manager.js +745 -10
- package/dist/tools/{fetch-url.d.ts → index.d.ts} +4 -5
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/{fetch-url.js → index.js} +6 -8
- package/dist/transform/index.d.ts +279 -0
- package/dist/transform/index.d.ts.map +1 -0
- package/dist/transform/index.js +5234 -0
- package/package.json +2 -2
- package/dist/cli.d.ts +0 -19
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -65
- package/dist/http/health.d.ts +0 -8
- package/dist/http/health.d.ts.map +0 -1
- package/dist/http/health.js +0 -152
- package/dist/http/helpers.d.ts +0 -68
- package/dist/http/helpers.d.ts.map +0 -1
- package/dist/http/helpers.js +0 -402
- package/dist/lib/error-codes.d.ts +0 -13
- package/dist/lib/error-codes.d.ts.map +0 -1
- package/dist/lib/error-codes.js +0 -12
- package/dist/lib/error-messages.d.ts.map +0 -1
- package/dist/lib/fetch-pipeline.d.ts.map +0 -1
- package/dist/lib/http.d.ts.map +0 -1
- package/dist/lib/logger-names.d.ts +0 -16
- package/dist/lib/logger-names.d.ts.map +0 -1
- package/dist/lib/logger-names.js +0 -15
- package/dist/lib/session.d.ts +0 -44
- package/dist/lib/session.d.ts.map +0 -1
- package/dist/lib/session.js +0 -137
- package/dist/lib/tool-errors.d.ts.map +0 -1
- package/dist/lib/tool-errors.js +0 -253
- package/dist/lib/url.d.ts.map +0 -1
- package/dist/lib/zod.d.ts +0 -3
- package/dist/lib/zod.d.ts.map +0 -1
- package/dist/lib/zod.js +0 -27
- package/dist/tasks/call-contract.d.ts +0 -25
- package/dist/tasks/call-contract.d.ts.map +0 -1
- package/dist/tasks/call-contract.js +0 -59
- package/dist/tasks/execution.d.ts +0 -16
- package/dist/tasks/execution.d.ts.map +0 -1
- package/dist/tasks/execution.js +0 -241
- package/dist/tasks/handlers.d.ts +0 -11
- package/dist/tasks/handlers.d.ts.map +0 -1
- package/dist/tasks/handlers.js +0 -157
- package/dist/tasks/owner.d.ts +0 -43
- package/dist/tasks/owner.d.ts.map +0 -1
- package/dist/tasks/owner.js +0 -144
- package/dist/tasks/registry.d.ts +0 -20
- package/dist/tasks/registry.d.ts.map +0 -1
- package/dist/tasks/registry.js +0 -40
- package/dist/tasks/waiters.d.ts +0 -27
- package/dist/tasks/waiters.d.ts.map +0 -1
- package/dist/tasks/waiters.js +0 -114
- package/dist/tools/fetch-url.d.ts.map +0 -1
- package/dist/transform/dom-prep.d.ts +0 -16
- package/dist/transform/dom-prep.d.ts.map +0 -1
- package/dist/transform/dom-prep.js +0 -1287
- package/dist/transform/html-translators.d.ts +0 -5
- package/dist/transform/html-translators.d.ts.map +0 -1
- package/dist/transform/html-translators.js +0 -697
- package/dist/transform/markdown-cleanup.d.ts +0 -10
- package/dist/transform/markdown-cleanup.d.ts.map +0 -1
- package/dist/transform/markdown-cleanup.js +0 -542
- package/dist/transform/metadata.d.ts +0 -18
- package/dist/transform/metadata.d.ts.map +0 -1
- package/dist/transform/metadata.js +0 -462
- package/dist/transform/next-flight.d.ts +0 -2
- package/dist/transform/next-flight.d.ts.map +0 -1
- package/dist/transform/next-flight.js +0 -374
- package/dist/transform/shared.d.ts +0 -8
- package/dist/transform/shared.d.ts.map +0 -1
- package/dist/transform/shared.js +0 -137
- package/dist/transform/transform.d.ts +0 -38
- package/dist/transform/transform.d.ts.map +0 -1
- package/dist/transform/transform.js +0 -1042
- package/dist/transform/types.d.ts +0 -124
- package/dist/transform/types.d.ts.map +0 -1
- package/dist/transform/types.js +0 -5
- package/dist/transform/worker-pool.d.ts +0 -76
- package/dist/transform/worker-pool.d.ts.map +0 -1
- package/dist/transform/worker-pool.js +0 -725
- /package/dist/lib/{http.d.ts → net/http.d.ts} +0 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@j0hanz/fetch-url-mcp",
|
|
3
|
-
"version": "1.12.
|
|
3
|
+
"version": "1.12.8",
|
|
4
4
|
"mcpName": "io.github.j0hanz/fetch-url-mcp",
|
|
5
5
|
"description": "An MCP server that fetches web pages and converts them to clean, readable Markdown.",
|
|
6
6
|
"type": "module",
|
|
@@ -94,7 +94,7 @@
|
|
|
94
94
|
"eslint-plugin-de-morgan": "^2.1.1",
|
|
95
95
|
"eslint-plugin-depend": "^1.5.0",
|
|
96
96
|
"eslint-plugin-unused-imports": "^4.4.1",
|
|
97
|
-
"knip": "^6",
|
|
97
|
+
"knip": "^6.1.0",
|
|
98
98
|
"prettier": "^3.8.1",
|
|
99
99
|
"tsx": "^4.21.0",
|
|
100
100
|
"typescript": "^6.0.2",
|
package/dist/cli.d.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
interface CliValues {
|
|
2
|
-
readonly stdio: boolean;
|
|
3
|
-
readonly http: boolean;
|
|
4
|
-
readonly help: boolean;
|
|
5
|
-
readonly version: boolean;
|
|
6
|
-
}
|
|
7
|
-
interface CliParseSuccess {
|
|
8
|
-
readonly ok: true;
|
|
9
|
-
readonly values: CliValues;
|
|
10
|
-
}
|
|
11
|
-
interface CliParseFailure {
|
|
12
|
-
readonly ok: false;
|
|
13
|
-
readonly message: string;
|
|
14
|
-
}
|
|
15
|
-
type CliParseResult = CliParseSuccess | CliParseFailure;
|
|
16
|
-
export declare function renderCliUsage(): string;
|
|
17
|
-
export declare function parseCliArgs(args: readonly string[]): CliParseResult;
|
|
18
|
-
export {};
|
|
19
|
-
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAIA,UAAU,SAAS;IACjB,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;CAC3B;AAED,UAAU,eAAe;IACvB,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAClB,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;CAC5B;AAED,UAAU,eAAe;IACvB,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IACnB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,KAAK,cAAc,GAAG,eAAe,GAAG,eAAe,CAAC;AA2CxD,wBAAgB,cAAc,IAAI,MAAM,CAEvC;AAED,wBAAgB,YAAY,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,cAAc,CA2BpE"}
|
package/dist/cli.js
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { parseArgs } from 'node:util';
|
|
2
|
-
import { getErrorMessage } from './lib/utils.js';
|
|
3
|
-
const usageLines = [
|
|
4
|
-
'Fetch URL MCP server',
|
|
5
|
-
'',
|
|
6
|
-
'Usage:',
|
|
7
|
-
' fetch-url-mcp [--stdio|-s | --http] [--help|-h] [--version|-v]',
|
|
8
|
-
'',
|
|
9
|
-
'Options:',
|
|
10
|
-
' --stdio, -s Run in stdio mode (default).',
|
|
11
|
-
' --http Run in Streamable HTTP mode.',
|
|
12
|
-
' --help, -h Show this help message.',
|
|
13
|
-
' --version, -v Show server version.',
|
|
14
|
-
'',
|
|
15
|
-
];
|
|
16
|
-
const optionSchema = {
|
|
17
|
-
stdio: { type: 'boolean', short: 's', default: false },
|
|
18
|
-
http: { type: 'boolean', default: false },
|
|
19
|
-
help: { type: 'boolean', short: 'h', default: false },
|
|
20
|
-
version: { type: 'boolean', short: 'v', default: false },
|
|
21
|
-
};
|
|
22
|
-
function toBoolean(value) {
|
|
23
|
-
return value === true;
|
|
24
|
-
}
|
|
25
|
-
function readCliFlag(values, key) {
|
|
26
|
-
return toBoolean(values[key]);
|
|
27
|
-
}
|
|
28
|
-
function buildCliValues(values) {
|
|
29
|
-
return {
|
|
30
|
-
stdio: readCliFlag(values, 'stdio'),
|
|
31
|
-
http: readCliFlag(values, 'http'),
|
|
32
|
-
help: readCliFlag(values, 'help'),
|
|
33
|
-
version: readCliFlag(values, 'version'),
|
|
34
|
-
};
|
|
35
|
-
}
|
|
36
|
-
export function renderCliUsage() {
|
|
37
|
-
return `${usageLines.join('\n')}\n`;
|
|
38
|
-
}
|
|
39
|
-
export function parseCliArgs(args) {
|
|
40
|
-
try {
|
|
41
|
-
const { values } = parseArgs({
|
|
42
|
-
args: [...args],
|
|
43
|
-
options: optionSchema,
|
|
44
|
-
strict: true,
|
|
45
|
-
allowPositionals: false,
|
|
46
|
-
});
|
|
47
|
-
const cliValues = buildCliValues(values);
|
|
48
|
-
if (cliValues.stdio && cliValues.http) {
|
|
49
|
-
return {
|
|
50
|
-
ok: false,
|
|
51
|
-
message: 'Choose either --stdio or --http, not both',
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
return {
|
|
55
|
-
ok: true,
|
|
56
|
-
values: cliValues,
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
catch (error) {
|
|
60
|
-
return {
|
|
61
|
-
ok: false,
|
|
62
|
-
message: getErrorMessage(error),
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
}
|
package/dist/http/health.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import type { SessionStore } from '../lib/core.js';
|
|
2
|
-
import { type RequestContext } from './helpers.js';
|
|
3
|
-
export declare function resetEventLoopMonitoring(): void;
|
|
4
|
-
export declare function disableEventLoopMonitoring(): void;
|
|
5
|
-
export declare function isVerboseHealthRequest(ctx: RequestContext): boolean;
|
|
6
|
-
export declare function shouldHandleHealthRoute(ctx: RequestContext): boolean;
|
|
7
|
-
export declare function sendHealthRouteResponse(store: SessionStore, ctx: RequestContext, authPresent: boolean): boolean;
|
|
8
|
-
//# sourceMappingURL=health.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../src/http/health.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAGnD,OAAO,EAAE,KAAK,cAAc,EAAY,MAAM,cAAc,CAAC;AAY7D,wBAAgB,wBAAwB,IAAI,IAAI,CAI/C;AAED,wBAAgB,0BAA0B,IAAI,IAAI,CAEjD;AAqKD,wBAAgB,sBAAsB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAKnE;AAiCD,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,cAAc,GAAG,OAAO,CAEpE;AAED,wBAAgB,uBAAuB,CACrC,KAAK,EAAE,YAAY,EACnB,GAAG,EAAE,cAAc,EACnB,WAAW,EAAE,OAAO,GACnB,OAAO,CAOT"}
|
package/dist/http/health.js
DELETED
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
import { freemem, hostname, totalmem } from 'node:os';
|
|
2
|
-
import { monitorEventLoopDelay, performance } from 'node:perf_hooks';
|
|
3
|
-
import process from 'node:process';
|
|
4
|
-
import { config, serverVersion } from '../lib/core.js';
|
|
5
|
-
import { getTransformPoolStats } from '../transform/transform.js';
|
|
6
|
-
import { sendJson } from './helpers.js';
|
|
7
|
-
// ---------------------------------------------------------------------------
|
|
8
|
-
// Event-loop monitoring
|
|
9
|
-
// ---------------------------------------------------------------------------
|
|
10
|
-
const EVENT_LOOP_DELAY_RESOLUTION_MS = 20;
|
|
11
|
-
const eventLoopDelay = monitorEventLoopDelay({
|
|
12
|
-
resolution: EVENT_LOOP_DELAY_RESOLUTION_MS,
|
|
13
|
-
});
|
|
14
|
-
let lastEventLoopUtilization = performance.eventLoopUtilization();
|
|
15
|
-
export function resetEventLoopMonitoring() {
|
|
16
|
-
lastEventLoopUtilization = performance.eventLoopUtilization();
|
|
17
|
-
eventLoopDelay.reset();
|
|
18
|
-
eventLoopDelay.enable();
|
|
19
|
-
}
|
|
20
|
-
export function disableEventLoopMonitoring() {
|
|
21
|
-
eventLoopDelay.disable();
|
|
22
|
-
}
|
|
23
|
-
// ---------------------------------------------------------------------------
|
|
24
|
-
// Stats helpers
|
|
25
|
-
// ---------------------------------------------------------------------------
|
|
26
|
-
function roundTo(value, precision) {
|
|
27
|
-
const factor = 10 ** precision;
|
|
28
|
-
return Math.round(value * factor) / factor;
|
|
29
|
-
}
|
|
30
|
-
function formatEventLoopUtilization(snapshot) {
|
|
31
|
-
return {
|
|
32
|
-
utilization: roundTo(snapshot.utilization, 4),
|
|
33
|
-
activeMs: Math.round(snapshot.active),
|
|
34
|
-
idleMs: Math.round(snapshot.idle),
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
function toMs(valueNs) {
|
|
38
|
-
return roundTo(valueNs / 1_000_000, 3);
|
|
39
|
-
}
|
|
40
|
-
function getEventLoopStats() {
|
|
41
|
-
const current = performance.eventLoopUtilization();
|
|
42
|
-
const delta = performance.eventLoopUtilization(current, lastEventLoopUtilization);
|
|
43
|
-
lastEventLoopUtilization = current;
|
|
44
|
-
return {
|
|
45
|
-
utilization: {
|
|
46
|
-
total: formatEventLoopUtilization(current),
|
|
47
|
-
sinceLast: formatEventLoopUtilization(delta),
|
|
48
|
-
},
|
|
49
|
-
delay: {
|
|
50
|
-
minMs: toMs(eventLoopDelay.min),
|
|
51
|
-
maxMs: toMs(eventLoopDelay.max),
|
|
52
|
-
meanMs: toMs(eventLoopDelay.mean),
|
|
53
|
-
stddevMs: toMs(eventLoopDelay.stddev),
|
|
54
|
-
p50Ms: toMs(eventLoopDelay.percentile(50)),
|
|
55
|
-
p95Ms: toMs(eventLoopDelay.percentile(95)),
|
|
56
|
-
p99Ms: toMs(eventLoopDelay.percentile(99)),
|
|
57
|
-
},
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
function buildHealthResponse(store, includeDiagnostics) {
|
|
61
|
-
const base = {
|
|
62
|
-
status: 'ok',
|
|
63
|
-
version: serverVersion,
|
|
64
|
-
uptime: Math.floor(process.uptime()),
|
|
65
|
-
timestamp: new Date().toISOString(),
|
|
66
|
-
};
|
|
67
|
-
if (!includeDiagnostics)
|
|
68
|
-
return base;
|
|
69
|
-
const poolStats = getTransformPoolStats();
|
|
70
|
-
return {
|
|
71
|
-
...base,
|
|
72
|
-
os: {
|
|
73
|
-
hostname: hostname(),
|
|
74
|
-
platform: process.platform,
|
|
75
|
-
arch: process.arch,
|
|
76
|
-
memoryFree: freemem(),
|
|
77
|
-
memoryTotal: totalmem(),
|
|
78
|
-
},
|
|
79
|
-
process: {
|
|
80
|
-
pid: process.pid,
|
|
81
|
-
ppid: process.ppid,
|
|
82
|
-
memory: process.memoryUsage(),
|
|
83
|
-
cpu: process.cpuUsage(),
|
|
84
|
-
resource: process.resourceUsage(),
|
|
85
|
-
...(typeof process.availableMemory === 'function'
|
|
86
|
-
? { availableMemory: process.availableMemory() }
|
|
87
|
-
: {}),
|
|
88
|
-
...(typeof process.constrainedMemory === 'function'
|
|
89
|
-
? { constrainedMemory: process.constrainedMemory() }
|
|
90
|
-
: {}),
|
|
91
|
-
},
|
|
92
|
-
perf: getEventLoopStats(),
|
|
93
|
-
...(typeof process.getActiveResourcesInfo === 'function'
|
|
94
|
-
? { activeResources: process.getActiveResourcesInfo() }
|
|
95
|
-
: {}),
|
|
96
|
-
stats: {
|
|
97
|
-
activeSessions: store.size(),
|
|
98
|
-
workerPool: poolStats ?? {
|
|
99
|
-
queueDepth: 0,
|
|
100
|
-
activeWorkers: 0,
|
|
101
|
-
capacity: 0,
|
|
102
|
-
},
|
|
103
|
-
},
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
function sendHealth(store, res, includeDiagnostics) {
|
|
107
|
-
res.setHeader('Cache-Control', 'no-store');
|
|
108
|
-
sendJson(res, 200, buildHealthResponse(store, includeDiagnostics));
|
|
109
|
-
}
|
|
110
|
-
// ---------------------------------------------------------------------------
|
|
111
|
-
// Health route helpers
|
|
112
|
-
// ---------------------------------------------------------------------------
|
|
113
|
-
export function isVerboseHealthRequest(ctx) {
|
|
114
|
-
const value = ctx.url.searchParams.get('verbose');
|
|
115
|
-
if (!value)
|
|
116
|
-
return false;
|
|
117
|
-
const normalized = value.trim().toLowerCase();
|
|
118
|
-
return normalized === '1' || normalized === 'true';
|
|
119
|
-
}
|
|
120
|
-
function isHealthRoute(ctx) {
|
|
121
|
-
return ctx.method === 'GET' && ctx.url.pathname === '/health';
|
|
122
|
-
}
|
|
123
|
-
function isVerboseHealthRoute(ctx) {
|
|
124
|
-
return isHealthRoute(ctx) && isVerboseHealthRequest(ctx);
|
|
125
|
-
}
|
|
126
|
-
function ensureHealthAuthIfNeeded(ctx, authPresent) {
|
|
127
|
-
if (!isVerboseHealthRoute(ctx))
|
|
128
|
-
return true;
|
|
129
|
-
if (!config.security.allowRemote)
|
|
130
|
-
return true;
|
|
131
|
-
if (authPresent)
|
|
132
|
-
return true;
|
|
133
|
-
sendJson(ctx.res, 401, {
|
|
134
|
-
error: 'Authentication required for verbose health metrics',
|
|
135
|
-
});
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
function resolveHealthDiagnosticsMode(ctx, authPresent) {
|
|
139
|
-
return (isVerboseHealthRoute(ctx) && (authPresent || !config.security.allowRemote));
|
|
140
|
-
}
|
|
141
|
-
export function shouldHandleHealthRoute(ctx) {
|
|
142
|
-
return isHealthRoute(ctx);
|
|
143
|
-
}
|
|
144
|
-
export function sendHealthRouteResponse(store, ctx, authPresent) {
|
|
145
|
-
if (!shouldHandleHealthRoute(ctx))
|
|
146
|
-
return false;
|
|
147
|
-
if (!ensureHealthAuthIfNeeded(ctx, authPresent))
|
|
148
|
-
return true;
|
|
149
|
-
const includeDiagnostics = resolveHealthDiagnosticsMode(ctx, authPresent);
|
|
150
|
-
sendHealth(store, ctx.res, includeDiagnostics);
|
|
151
|
-
return true;
|
|
152
|
-
}
|
package/dist/http/helpers.d.ts
DELETED
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
import type { IncomingMessage, Server, ServerResponse } from 'node:http';
|
|
2
|
-
import type { Server as HttpsServer } from 'node:https';
|
|
3
|
-
import type { AuthInfo } from '@modelcontextprotocol/sdk/server/auth/types.js';
|
|
4
|
-
import type { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
5
|
-
import type { StreamableHTTPServerTransport } from '@modelcontextprotocol/sdk/server/streamableHttp.js';
|
|
6
|
-
import type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
|
|
7
|
-
import type { JsonRpcId } from '../lib/mcp-interop.js';
|
|
8
|
-
export type NetworkServer = Server | HttpsServer;
|
|
9
|
-
export interface RequestContext {
|
|
10
|
-
req: IncomingMessage;
|
|
11
|
-
res: ServerResponse;
|
|
12
|
-
url: URL;
|
|
13
|
-
method: string | undefined;
|
|
14
|
-
ip: string | null;
|
|
15
|
-
body: unknown;
|
|
16
|
-
signal?: AbortSignal;
|
|
17
|
-
}
|
|
18
|
-
export interface AuthenticatedContext extends RequestContext {
|
|
19
|
-
auth: AuthInfo;
|
|
20
|
-
}
|
|
21
|
-
export declare function sendJson(res: ServerResponse, status: number, body: unknown): void;
|
|
22
|
-
export declare function sendEmpty(res: ServerResponse, status: number): void;
|
|
23
|
-
export declare function sendError(res: ServerResponse, _code: number, message: string, status?: number, _id?: JsonRpcId | null): void;
|
|
24
|
-
export declare function getHeaderValue(req: IncomingMessage, name: string): string | null;
|
|
25
|
-
export declare function getMcpSessionId(req: IncomingMessage): string | null;
|
|
26
|
-
export declare function findDuplicateSingleValueHeader(req: IncomingMessage): string | null;
|
|
27
|
-
export declare function drainRequest(req: IncomingMessage): void;
|
|
28
|
-
export declare function createRequestAbortSignal(req: IncomingMessage): {
|
|
29
|
-
signal: AbortSignal;
|
|
30
|
-
cleanup: () => void;
|
|
31
|
-
};
|
|
32
|
-
export declare function registerInboundBlockList(server: NetworkServer): void;
|
|
33
|
-
export declare function buildRequestContext(req: IncomingMessage, res: ServerResponse, signal?: AbortSignal): RequestContext | null;
|
|
34
|
-
export declare function closeTransportBestEffort(transport: {
|
|
35
|
-
close: () => Promise<unknown>;
|
|
36
|
-
}, context: string): Promise<void>;
|
|
37
|
-
export declare function closeMcpServerBestEffort(server: McpServer, context: string): Promise<void>;
|
|
38
|
-
export declare function createTransportAdapter(transportImpl: StreamableHTTPServerTransport): Transport;
|
|
39
|
-
type JsonBodyErrorKind = 'payload-too-large' | 'invalid-json' | 'read-failed';
|
|
40
|
-
export declare class JsonBodyError extends Error {
|
|
41
|
-
readonly kind: JsonBodyErrorKind;
|
|
42
|
-
constructor(kind: JsonBodyErrorKind, message: string);
|
|
43
|
-
}
|
|
44
|
-
export declare function isJsonBodyError(error: unknown): error is JsonBodyError;
|
|
45
|
-
export declare const DEFAULT_BODY_LIMIT_BYTES: number;
|
|
46
|
-
declare class JsonBodyReader {
|
|
47
|
-
read(req: IncomingMessage, limit?: number, signal?: AbortSignal): Promise<unknown>;
|
|
48
|
-
private readBody;
|
|
49
|
-
private collectChunks;
|
|
50
|
-
private normalizeChunk;
|
|
51
|
-
}
|
|
52
|
-
export declare const jsonBodyReader: JsonBodyReader;
|
|
53
|
-
interface SessionRecordLike {
|
|
54
|
-
server: McpServer;
|
|
55
|
-
transport: StreamableHTTPServerTransport;
|
|
56
|
-
}
|
|
57
|
-
interface SessionTeardownOptions {
|
|
58
|
-
cancelMessage: string;
|
|
59
|
-
closeServerReason?: string;
|
|
60
|
-
closeTransportReason?: string;
|
|
61
|
-
unregisterByServer?: boolean;
|
|
62
|
-
awaitClose?: boolean;
|
|
63
|
-
}
|
|
64
|
-
export declare function teardownSessionResources(session: SessionRecordLike, options: SessionTeardownOptions): Promise<void>;
|
|
65
|
-
export declare function teardownUnregisteredSessionResources(session: SessionRecordLike, context: string): Promise<void>;
|
|
66
|
-
export declare function teardownSessionRegistration(server: McpServer): void;
|
|
67
|
-
export {};
|
|
68
|
-
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/http/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACzE,OAAO,KAAK,EAAE,MAAM,IAAI,WAAW,EAAE,MAAM,YAAY,CAAC;AAKxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gDAAgD,CAAC;AAC/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACzE,OAAO,KAAK,EAAE,6BAA6B,EAAE,MAAM,oDAAoD,CAAC;AACxG,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+CAA+C,CAAC;AAS/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAQvD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG,WAAW,CAAC;AAcjD,MAAM,WAAW,cAAc;IAC7B,GAAG,EAAE,eAAe,CAAC;IACrB,GAAG,EAAE,cAAc,CAAC;IACpB,GAAG,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