@j0hanz/superfetch 2.4.9 → 2.4.11
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/cache.d.ts +4 -0
- package/dist/cache.js +18 -0
- package/dist/mcp.js +3 -2
- package/package.json +1 -1
package/dist/cache.d.ts
CHANGED
|
@@ -41,6 +41,10 @@ export declare function get(cacheKey: string | null): CacheEntry | undefined;
|
|
|
41
41
|
export declare function set(cacheKey: string | null, content: string, metadata: CacheEntryMetadata): void;
|
|
42
42
|
export declare function keys(): readonly string[];
|
|
43
43
|
export declare function isEnabled(): boolean;
|
|
44
|
+
export declare function getRecentCachedUrls(): {
|
|
45
|
+
url: string;
|
|
46
|
+
title?: string;
|
|
47
|
+
}[];
|
|
44
48
|
export declare function registerCachedContentResource(server: McpServer, serverIcons?: McpIcon[]): void;
|
|
45
49
|
export declare function generateSafeFilename(url: string, title?: string, hashFallback?: string, extension?: string): string;
|
|
46
50
|
export declare function handleDownload(res: ServerResponse, namespace: string, hash: string): void;
|
package/dist/cache.js
CHANGED
|
@@ -273,6 +273,24 @@ export function keys() {
|
|
|
273
273
|
export function isEnabled() {
|
|
274
274
|
return store.isEnabled();
|
|
275
275
|
}
|
|
276
|
+
export function getRecentCachedUrls() {
|
|
277
|
+
const cacheKeys = store.keys();
|
|
278
|
+
const maxResults = 20;
|
|
279
|
+
const results = [];
|
|
280
|
+
for (let i = 0; i < Math.min(cacheKeys.length, maxResults); i++) {
|
|
281
|
+
const key = cacheKeys[i];
|
|
282
|
+
if (!key)
|
|
283
|
+
continue;
|
|
284
|
+
const entry = store.get(key);
|
|
285
|
+
if (entry) {
|
|
286
|
+
results.push({
|
|
287
|
+
url: entry.url,
|
|
288
|
+
...(entry.title ? { title: entry.title } : {}),
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
return results;
|
|
293
|
+
}
|
|
276
294
|
/* -------------------------------------------------------------------------------------------------
|
|
277
295
|
* MCP cached content resource (superfetch://cache/markdown/{urlHash})
|
|
278
296
|
* ------------------------------------------------------------------------------------------------- */
|
package/dist/mcp.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { readFile } from 'node:fs/promises';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
+
import { completable } from '@modelcontextprotocol/sdk/server/completable.js';
|
|
3
4
|
import { McpServer, ResourceTemplate, } from '@modelcontextprotocol/sdk/server/mcp.js';
|
|
4
5
|
import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
|
|
5
6
|
import { CallToolRequestSchema, ErrorCode, McpError, } from '@modelcontextprotocol/sdk/types.js';
|
|
6
|
-
import { registerCachedContentResource } from './cache.js';
|
|
7
|
+
import { getRecentCachedUrls, registerCachedContentResource, } from './cache.js';
|
|
7
8
|
import { config } from './config.js';
|
|
8
9
|
import { destroyAgents } from './fetch.js';
|
|
9
10
|
import { logError, logInfo, setMcpServer } from './observability.js';
|
|
@@ -397,7 +398,7 @@ function registerPrompts(server) {
|
|
|
397
398
|
title: 'Summarize Webpage',
|
|
398
399
|
description: 'Summarize the content of a webpage given its URL.',
|
|
399
400
|
argsSchema: {
|
|
400
|
-
url: z.string().describe('The URL to summarize'),
|
|
401
|
+
url: completable(z.string().describe('The URL to summarize'), () => getRecentCachedUrls().map((entry) => entry.url)),
|
|
401
402
|
},
|
|
402
403
|
}, (args) => ({
|
|
403
404
|
messages: [
|
package/package.json
CHANGED