@j0hanz/fetch-url-mcp 1.4.0 → 1.5.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/dist/cli.d.ts +2 -3
- package/dist/cli.js +1 -2
- package/dist/http/auth.d.ts +5 -3
- package/dist/http/auth.js +64 -15
- package/dist/http/health.d.ts +1 -2
- package/dist/http/health.js +7 -18
- package/dist/http/helpers.d.ts +3 -4
- package/dist/http/helpers.js +21 -21
- package/dist/http/native.d.ts +0 -1
- package/dist/http/native.js +34 -26
- package/dist/http/rate-limit.d.ts +0 -1
- package/dist/http/rate-limit.js +3 -4
- package/dist/index.d.ts +0 -1
- package/dist/index.js +17 -18
- package/dist/lib/{markdown-cleanup.d.ts → content.d.ts} +4 -2
- package/dist/lib/content.js +1356 -0
- package/dist/lib/core.d.ts +253 -0
- package/dist/lib/core.js +1228 -0
- package/dist/lib/{tool-pipeline.d.ts → fetch-pipeline.d.ts} +1 -2
- package/dist/lib/{tool-pipeline.js → fetch-pipeline.js} +10 -19
- package/dist/lib/{fetch.d.ts → http.d.ts} +7 -9
- package/dist/lib/{fetch.js → http.js} +706 -944
- package/dist/lib/mcp-tools.d.ts +28 -0
- package/dist/lib/mcp-tools.js +107 -0
- package/dist/lib/{tool-progress.d.ts → progress.d.ts} +0 -1
- package/dist/lib/{tool-progress.js → progress.js} +8 -13
- package/dist/lib/task-handlers.d.ts +5 -0
- package/dist/lib/{mcp.js → task-handlers.js} +56 -12
- package/dist/lib/url.d.ts +70 -0
- package/dist/lib/url.js +686 -0
- package/dist/lib/utils.d.ts +58 -0
- package/dist/lib/utils.js +304 -0
- package/dist/prompts/index.d.ts +0 -1
- package/dist/prompts/index.js +0 -1
- package/dist/resources/index.d.ts +0 -1
- package/dist/resources/index.js +74 -33
- package/dist/resources/instructions.d.ts +0 -1
- package/dist/resources/instructions.js +2 -2
- package/dist/schemas/inputs.d.ts +0 -1
- package/dist/schemas/inputs.js +2 -3
- package/dist/schemas/outputs.d.ts +0 -1
- package/dist/schemas/outputs.js +1 -2
- package/dist/server.d.ts +0 -1
- package/dist/server.js +16 -26
- package/dist/tasks/execution.d.ts +0 -1
- package/dist/tasks/execution.js +27 -24
- package/dist/tasks/manager.d.ts +7 -3
- package/dist/tasks/manager.js +53 -34
- package/dist/tasks/owner.d.ts +1 -2
- package/dist/tasks/owner.js +1 -2
- package/dist/tasks/tool-registry.d.ts +1 -2
- package/dist/tasks/tool-registry.js +0 -1
- package/dist/tools/fetch-url.d.ts +1 -2
- package/dist/tools/fetch-url.js +39 -31
- package/dist/tools/index.d.ts +0 -1
- package/dist/tools/index.js +0 -1
- package/dist/transform/html-translators.d.ts +1 -0
- package/dist/transform/html-translators.js +454 -0
- package/dist/transform/metadata.d.ts +4 -0
- package/dist/transform/metadata.js +183 -0
- package/dist/transform/transform.d.ts +0 -1
- package/dist/transform/transform.js +24 -641
- package/dist/transform/types.d.ts +9 -11
- package/dist/transform/types.js +0 -1
- package/dist/transform/worker-pool.d.ts +0 -1
- package/dist/transform/worker-pool.js +7 -16
- package/dist/transform/workers/shared.d.ts +0 -1
- package/dist/transform/workers/shared.js +1 -2
- package/dist/transform/workers/transform-child.d.ts +0 -1
- package/dist/transform/workers/transform-child.js +0 -1
- package/dist/transform/workers/transform-worker.d.ts +0 -1
- package/dist/transform/workers/transform-worker.js +0 -1
- package/package.json +6 -3
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js.map +0 -1
- package/dist/http/auth.d.ts.map +0 -1
- package/dist/http/auth.js.map +0 -1
- package/dist/http/health.d.ts.map +0 -1
- package/dist/http/health.js.map +0 -1
- package/dist/http/helpers.d.ts.map +0 -1
- package/dist/http/helpers.js.map +0 -1
- package/dist/http/native.d.ts.map +0 -1
- package/dist/http/native.js.map +0 -1
- package/dist/http/rate-limit.d.ts.map +0 -1
- package/dist/http/rate-limit.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/lib/cache.d.ts +0 -54
- package/dist/lib/cache.d.ts.map +0 -1
- package/dist/lib/cache.js +0 -264
- package/dist/lib/cache.js.map +0 -1
- package/dist/lib/config.d.ts +0 -143
- package/dist/lib/config.d.ts.map +0 -1
- package/dist/lib/config.js +0 -476
- package/dist/lib/config.js.map +0 -1
- package/dist/lib/crypto.d.ts +0 -4
- package/dist/lib/crypto.d.ts.map +0 -1
- package/dist/lib/crypto.js +0 -56
- package/dist/lib/crypto.js.map +0 -1
- package/dist/lib/dom-noise-removal.d.ts +0 -2
- package/dist/lib/dom-noise-removal.d.ts.map +0 -1
- package/dist/lib/dom-noise-removal.js +0 -494
- package/dist/lib/dom-noise-removal.js.map +0 -1
- package/dist/lib/download.d.ts +0 -4
- package/dist/lib/download.d.ts.map +0 -1
- package/dist/lib/download.js +0 -106
- package/dist/lib/download.js.map +0 -1
- package/dist/lib/errors.d.ts +0 -14
- package/dist/lib/errors.d.ts.map +0 -1
- package/dist/lib/errors.js +0 -72
- package/dist/lib/errors.js.map +0 -1
- package/dist/lib/fetch-content.d.ts +0 -5
- package/dist/lib/fetch-content.d.ts.map +0 -1
- package/dist/lib/fetch-content.js +0 -164
- package/dist/lib/fetch-content.js.map +0 -1
- package/dist/lib/fetch-stream.d.ts +0 -5
- package/dist/lib/fetch-stream.d.ts.map +0 -1
- package/dist/lib/fetch-stream.js +0 -29
- package/dist/lib/fetch-stream.js.map +0 -1
- package/dist/lib/fetch.d.ts.map +0 -1
- package/dist/lib/fetch.js.map +0 -1
- package/dist/lib/host-normalization.d.ts +0 -2
- package/dist/lib/host-normalization.d.ts.map +0 -1
- package/dist/lib/host-normalization.js +0 -91
- package/dist/lib/host-normalization.js.map +0 -1
- package/dist/lib/ip-blocklist.d.ts +0 -9
- package/dist/lib/ip-blocklist.d.ts.map +0 -1
- package/dist/lib/ip-blocklist.js +0 -79
- package/dist/lib/ip-blocklist.js.map +0 -1
- package/dist/lib/json.d.ts +0 -2
- package/dist/lib/json.d.ts.map +0 -1
- package/dist/lib/json.js +0 -45
- package/dist/lib/json.js.map +0 -1
- package/dist/lib/language-detection.d.ts +0 -3
- package/dist/lib/language-detection.d.ts.map +0 -1
- package/dist/lib/language-detection.js +0 -355
- package/dist/lib/language-detection.js.map +0 -1
- package/dist/lib/markdown-cleanup.d.ts.map +0 -1
- package/dist/lib/markdown-cleanup.js +0 -532
- package/dist/lib/markdown-cleanup.js.map +0 -1
- package/dist/lib/mcp-lifecycle.d.ts +0 -5
- package/dist/lib/mcp-lifecycle.d.ts.map +0 -1
- package/dist/lib/mcp-lifecycle.js +0 -51
- package/dist/lib/mcp-lifecycle.js.map +0 -1
- package/dist/lib/mcp-validator.d.ts +0 -17
- package/dist/lib/mcp-validator.d.ts.map +0 -1
- package/dist/lib/mcp-validator.js +0 -45
- package/dist/lib/mcp-validator.js.map +0 -1
- package/dist/lib/mcp.d.ts +0 -4
- package/dist/lib/mcp.d.ts.map +0 -1
- package/dist/lib/mcp.js.map +0 -1
- package/dist/lib/observability.d.ts +0 -23
- package/dist/lib/observability.d.ts.map +0 -1
- package/dist/lib/observability.js +0 -238
- package/dist/lib/observability.js.map +0 -1
- package/dist/lib/server-tuning.d.ts +0 -15
- package/dist/lib/server-tuning.d.ts.map +0 -1
- package/dist/lib/server-tuning.js +0 -49
- package/dist/lib/server-tuning.js.map +0 -1
- package/dist/lib/session.d.ts +0 -45
- package/dist/lib/session.d.ts.map +0 -1
- package/dist/lib/session.js +0 -263
- package/dist/lib/session.js.map +0 -1
- package/dist/lib/timer-utils.d.ts +0 -13
- package/dist/lib/timer-utils.d.ts.map +0 -1
- package/dist/lib/timer-utils.js +0 -44
- package/dist/lib/timer-utils.js.map +0 -1
- package/dist/lib/tool-errors.d.ts +0 -12
- package/dist/lib/tool-errors.d.ts.map +0 -1
- package/dist/lib/tool-errors.js +0 -55
- package/dist/lib/tool-errors.js.map +0 -1
- package/dist/lib/tool-pipeline.d.ts.map +0 -1
- package/dist/lib/tool-pipeline.js.map +0 -1
- package/dist/lib/tool-progress.d.ts.map +0 -1
- package/dist/lib/tool-progress.js.map +0 -1
- package/dist/lib/type-guards.d.ts +0 -16
- package/dist/lib/type-guards.d.ts.map +0 -1
- package/dist/lib/type-guards.js +0 -13
- package/dist/lib/type-guards.js.map +0 -1
- package/dist/prompts/index.d.ts.map +0 -1
- package/dist/prompts/index.js.map +0 -1
- package/dist/resources/index.d.ts.map +0 -1
- package/dist/resources/index.js.map +0 -1
- package/dist/resources/instructions.d.ts.map +0 -1
- package/dist/resources/instructions.js.map +0 -1
- package/dist/schemas/inputs.d.ts.map +0 -1
- package/dist/schemas/inputs.js.map +0 -1
- package/dist/schemas/outputs.d.ts.map +0 -1
- package/dist/schemas/outputs.js.map +0 -1
- package/dist/server.d.ts.map +0 -1
- package/dist/server.js.map +0 -1
- package/dist/tasks/execution.d.ts.map +0 -1
- package/dist/tasks/execution.js.map +0 -1
- package/dist/tasks/manager.d.ts.map +0 -1
- package/dist/tasks/manager.js.map +0 -1
- package/dist/tasks/owner.d.ts.map +0 -1
- package/dist/tasks/owner.js.map +0 -1
- package/dist/tasks/tool-registry.d.ts.map +0 -1
- package/dist/tasks/tool-registry.js.map +0 -1
- package/dist/tools/fetch-url.d.ts.map +0 -1
- package/dist/tools/fetch-url.js.map +0 -1
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js.map +0 -1
- package/dist/transform/transform.d.ts.map +0 -1
- package/dist/transform/transform.js.map +0 -1
- package/dist/transform/types.d.ts.map +0 -1
- package/dist/transform/types.js.map +0 -1
- package/dist/transform/worker-pool.d.ts.map +0 -1
- package/dist/transform/worker-pool.js.map +0 -1
- package/dist/transform/workers/shared.d.ts.map +0 -1
- package/dist/transform/workers/shared.js.map +0 -1
- package/dist/transform/workers/transform-child.d.ts.map +0 -1
- package/dist/transform/workers/transform-child.js.map +0 -1
- package/dist/transform/workers/transform-worker.d.ts.map +0 -1
- package/dist/transform/workers/transform-worker.js.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type MarkdownTransformResult } from '../transform/types.js';
|
|
2
2
|
type JsonRecord = Record<string, unknown>;
|
|
3
3
|
export declare function readString(obj: unknown, key: string): string | undefined;
|
|
4
4
|
export declare function readNestedRecord(obj: unknown, keys: readonly string[]): JsonRecord | undefined;
|
|
@@ -68,4 +68,3 @@ export declare function performSharedFetch(options: SharedFetchOptions, deps?: S
|
|
|
68
68
|
inlineResult: InlineContentResult;
|
|
69
69
|
}>;
|
|
70
70
|
export {};
|
|
71
|
-
//# sourceMappingURL=tool-pipeline.d.ts.map
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import * as cache from './cache.js';
|
|
3
2
|
import { transformBufferToMarkdown } from '../transform/transform.js';
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { fetchNormalizedUrlBuffer, normalizeUrl, transformToRawUrl, } from './
|
|
7
|
-
import {
|
|
8
|
-
import { isObject } from './type-guards.js';
|
|
3
|
+
import {} from '../transform/types.js';
|
|
4
|
+
import { config, createCacheKey, get, isEnabled, logDebug, logWarn, set, } from './core.js';
|
|
5
|
+
import { fetchNormalizedUrlBuffer, normalizeUrl, transformToRawUrl, } from './http.js';
|
|
6
|
+
import { getErrorMessage, isObject } from './utils.js';
|
|
9
7
|
function asRecord(value) {
|
|
10
8
|
return isObject(value) ? value : undefined;
|
|
11
9
|
}
|
|
@@ -38,7 +36,7 @@ export function withSignal(signal) {
|
|
|
38
36
|
return signal === undefined ? {} : { signal };
|
|
39
37
|
}
|
|
40
38
|
/* -------------------------------------------------------------------------------------------------
|
|
41
|
-
* Inline content
|
|
39
|
+
* Inline content truncation
|
|
42
40
|
* ------------------------------------------------------------------------------------------------- */
|
|
43
41
|
export const TRUNCATION_MARKER = '...[truncated]';
|
|
44
42
|
function getOpenCodeFence(content) {
|
|
@@ -171,9 +169,6 @@ function logRawUrlTransformation(resolvedUrl) {
|
|
|
171
169
|
original: resolvedUrl.originalUrl,
|
|
172
170
|
});
|
|
173
171
|
}
|
|
174
|
-
/* -------------------------------------------------------------------------------------------------
|
|
175
|
-
* Cache helpers
|
|
176
|
-
* ------------------------------------------------------------------------------------------------- */
|
|
177
172
|
function extractTitle(value) {
|
|
178
173
|
return readString(value, 'title');
|
|
179
174
|
}
|
|
@@ -200,7 +195,7 @@ function attemptCacheRetrieval(params) {
|
|
|
200
195
|
const { cacheKey, deserialize, cacheNamespace, normalizedUrl } = params;
|
|
201
196
|
if (!cacheKey)
|
|
202
197
|
return null;
|
|
203
|
-
const cached =
|
|
198
|
+
const cached = get(cacheKey);
|
|
204
199
|
if (!cached)
|
|
205
200
|
return null;
|
|
206
201
|
if (!deserialize) {
|
|
@@ -239,7 +234,7 @@ function persistCache(params) {
|
|
|
239
234
|
...(title === undefined ? {} : { title }),
|
|
240
235
|
};
|
|
241
236
|
try {
|
|
242
|
-
|
|
237
|
+
set(cacheKey, serializer(data), metadata, force ? { force: true } : undefined);
|
|
243
238
|
}
|
|
244
239
|
catch (error) {
|
|
245
240
|
logWarn('Failed to persist cache entry', {
|
|
@@ -249,13 +244,10 @@ function persistCache(params) {
|
|
|
249
244
|
});
|
|
250
245
|
}
|
|
251
246
|
}
|
|
252
|
-
/* -------------------------------------------------------------------------------------------------
|
|
253
|
-
* Pipeline executor
|
|
254
|
-
* ------------------------------------------------------------------------------------------------- */
|
|
255
247
|
export async function executeFetchPipeline(options) {
|
|
256
248
|
const resolvedUrl = resolveNormalizedUrl(options.url);
|
|
257
249
|
logRawUrlTransformation(resolvedUrl);
|
|
258
|
-
const cacheKey =
|
|
250
|
+
const cacheKey = createCacheKey(options.cacheNamespace, resolvedUrl.normalizedUrl, options.cacheVary);
|
|
259
251
|
if (!options.forceRefresh) {
|
|
260
252
|
const cachedResult = attemptCacheRetrieval({
|
|
261
253
|
cacheKey,
|
|
@@ -272,7 +264,7 @@ export async function executeFetchPipeline(options) {
|
|
|
272
264
|
const resolvedFinalUrl = finalUrl || resolvedUrl.normalizedUrl;
|
|
273
265
|
const transformUrl = resolvedFinalUrl;
|
|
274
266
|
const data = await options.transform({ buffer, encoding, ...(truncated ? { truncated: true } : {}) }, transformUrl);
|
|
275
|
-
if (
|
|
267
|
+
if (isEnabled()) {
|
|
276
268
|
persistCache({
|
|
277
269
|
cacheKey,
|
|
278
270
|
data,
|
|
@@ -281,7 +273,7 @@ export async function executeFetchPipeline(options) {
|
|
|
281
273
|
cacheNamespace: options.cacheNamespace,
|
|
282
274
|
});
|
|
283
275
|
if (finalUrl && finalUrl !== resolvedUrl.normalizedUrl) {
|
|
284
|
-
const finalCacheKey =
|
|
276
|
+
const finalCacheKey = createCacheKey(options.cacheNamespace, finalUrl, options.cacheVary);
|
|
285
277
|
if (finalCacheKey && finalCacheKey !== cacheKey) {
|
|
286
278
|
persistCache({
|
|
287
279
|
cacheKey: finalCacheKey,
|
|
@@ -388,4 +380,3 @@ export async function performSharedFetch(options, deps = {}) {
|
|
|
388
380
|
const inlineResult = applyInlineContentLimit(pipeline.data.content, options.maxInlineChars);
|
|
389
381
|
return { pipeline, inlineResult };
|
|
390
382
|
}
|
|
391
|
-
//# sourceMappingURL=tool-pipeline.js.map
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
readonly url: string;
|
|
6
|
-
readonly transformed: boolean;
|
|
7
|
-
readonly platform?: string;
|
|
8
|
-
}
|
|
1
|
+
import { type ServerResponse } from 'node:http';
|
|
2
|
+
import { type TransformResult } from './url.js';
|
|
3
|
+
export declare function generateSafeFilename(url: string, title?: string, hashFallback?: string, extension?: string): string;
|
|
4
|
+
export declare function handleDownload(res: ServerResponse, namespace: string, hash: string): void;
|
|
9
5
|
interface FetchTelemetryContext {
|
|
10
6
|
requestId: string;
|
|
11
7
|
startTime: number;
|
|
@@ -14,6 +10,9 @@ interface FetchTelemetryContext {
|
|
|
14
10
|
contextRequestId?: string;
|
|
15
11
|
operationId?: string;
|
|
16
12
|
}
|
|
13
|
+
interface FetchOptions {
|
|
14
|
+
signal?: AbortSignal;
|
|
15
|
+
}
|
|
17
16
|
export declare function isBlockedIp(ip: string): boolean;
|
|
18
17
|
export declare function normalizeUrl(urlString: string): {
|
|
19
18
|
normalizedUrl: string;
|
|
@@ -41,4 +40,3 @@ export declare function fetchNormalizedUrlBuffer(normalizedUrl: string, options?
|
|
|
41
40
|
finalUrl: string;
|
|
42
41
|
}>;
|
|
43
42
|
export {};
|
|
44
|
-
//# sourceMappingURL=fetch.d.ts.map
|