@squadrules/mcp 5.21.0 → 5.22.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/.tsbuildinfo +1 -1
- package/dist/embed-docs/mem/adapter-migration.md +1 -1
- package/dist/embed-docs/mem/author-adapter.md +1 -1
- package/dist/embed-docs/mem/bulk-insert-adapters-via-cli.md +1 -1
- package/dist/embed-docs/mem/challenge-type-guide.md +1 -1
- package/dist/embed-docs/mem/critic-loop-guide.md +1 -1
- package/dist/embed-docs/mem/critic-loop.md +1 -1
- package/dist/embed-docs/mem/protocol-linking-guide.md +1 -1
- package/dist/embed-docs/mem/refine-search.md +1 -1
- package/dist/resources/docs-resources.d.ts.map +1 -1
- package/dist/resources/docs-resources.js +7 -1
- package/dist/resources/docs-resources.js.map +1 -1
- package/dist/resources/embedded-mcp-resources.js +8 -8
- package/dist/resources/prompt-resources.d.ts.map +1 -1
- package/dist/resources/prompt-resources.js +7 -1
- package/dist/resources/prompt-resources.js.map +1 -1
- package/dist/runtime-lock.json +2 -2
- package/dist/server.d.ts.map +1 -1
- package/dist/server.js +136 -4
- package/dist/server.js.map +1 -1
- package/dist/tools/activate.d.ts.map +1 -1
- package/dist/tools/activate.js +5 -1
- package/dist/tools/activate.js.map +1 -1
- package/dist/tools/forward-register.d.ts.map +1 -1
- package/dist/tools/forward-register.js +5 -1
- package/dist/tools/forward-register.js.map +1 -1
- package/dist/ui/assets/{AccountPage-B2T89Atk.js → AccountPage-BL-DpBiv.js} +1 -1
- package/dist/ui/assets/{index-32Gsose4.js → index-BenjvYIQ.js} +2 -2
- package/dist/ui/index.html +1 -1
- package/dist/utils/pagination.d.ts +57 -0
- package/dist/utils/pagination.d.ts.map +1 -0
- package/dist/utils/pagination.js +88 -0
- package/dist/utils/pagination.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cursor-based pagination utilities for MCP list operations.
|
|
3
|
+
*
|
|
4
|
+
* Implements the 2026-07-28 spec pagination model:
|
|
5
|
+
* - Opaque cursor tokens (base64-encoded JSON)
|
|
6
|
+
* - Server-determined page sizes
|
|
7
|
+
* - nextCursor field in responses when more results exist
|
|
8
|
+
* - Cache metadata (ttlMs, cacheScope) on all list/read responses
|
|
9
|
+
*/
|
|
10
|
+
import { getBuildVersion } from '../utils/build-version.js';
|
|
11
|
+
/** Default page size for list operations */
|
|
12
|
+
export const DEFAULT_PAGE_SIZE = 50;
|
|
13
|
+
/** Cache TTL for embedded docs (5 minutes) */
|
|
14
|
+
export const EMBEDDED_DOCS_TTL_MS = 300_000;
|
|
15
|
+
/** Cache TTL for adapter content (30 seconds - bounded for store mutations) */
|
|
16
|
+
export const ADAPTER_CONTENT_TTL_MS = 30_000;
|
|
17
|
+
/** Cache scope for embedded docs (public - build-fresh) */
|
|
18
|
+
export const EMBEDDED_DOCS_CACHE_SCOPE = 'public';
|
|
19
|
+
/** Cache scope for adapter content (private - user-specific) */
|
|
20
|
+
export const ADAPTER_CONTENT_CACHE_SCOPE = 'private';
|
|
21
|
+
/**
|
|
22
|
+
* Encode a cursor from an offset position
|
|
23
|
+
*/
|
|
24
|
+
export function encodeCursor(offset) {
|
|
25
|
+
const payload = { offset };
|
|
26
|
+
return Buffer.from(JSON.stringify(payload)).toString('base64');
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Decode a cursor to get the offset position
|
|
30
|
+
* Returns 0 if cursor is invalid or missing
|
|
31
|
+
*/
|
|
32
|
+
export function decodeCursor(cursor) {
|
|
33
|
+
if (!cursor)
|
|
34
|
+
return 0;
|
|
35
|
+
try {
|
|
36
|
+
const decoded = Buffer.from(cursor, 'base64').toString('utf-8');
|
|
37
|
+
const payload = JSON.parse(decoded);
|
|
38
|
+
return typeof payload.offset === 'number' && payload.offset >= 0 ? payload.offset : 0;
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
return 0;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Paginate an array of items based on cursor
|
|
46
|
+
* @returns The page of items and the next cursor (if more items exist)
|
|
47
|
+
*/
|
|
48
|
+
export function paginateItems(items, cursor, pageSize = DEFAULT_PAGE_SIZE) {
|
|
49
|
+
const offset = decodeCursor(cursor);
|
|
50
|
+
const page = items.slice(offset, offset + pageSize);
|
|
51
|
+
const hasMore = offset + pageSize < items.length;
|
|
52
|
+
return {
|
|
53
|
+
page,
|
|
54
|
+
...(hasMore && { nextCursor: encodeCursor(offset + pageSize) })
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Build cache metadata for embedded docs (resources, prompts from codebase)
|
|
59
|
+
* These are build-fresh and can be cached publicly
|
|
60
|
+
*/
|
|
61
|
+
export function buildEmbeddedDocsCacheMetadata() {
|
|
62
|
+
return {
|
|
63
|
+
ttlMs: EMBEDDED_DOCS_TTL_MS,
|
|
64
|
+
cacheScope: EMBEDDED_DOCS_CACHE_SCOPE
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Build cache metadata for adapter content (reached through activate/forward)
|
|
69
|
+
* These are user-specific and have bounded TTL for store mutations
|
|
70
|
+
*/
|
|
71
|
+
export function buildAdapterContentCacheMetadata() {
|
|
72
|
+
return {
|
|
73
|
+
ttlMs: ADAPTER_CONTENT_TTL_MS,
|
|
74
|
+
cacheScope: ADAPTER_CONTENT_CACHE_SCOPE
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Build cache metadata for server info (included in _meta)
|
|
79
|
+
*/
|
|
80
|
+
export function buildServerInfoMeta() {
|
|
81
|
+
return {
|
|
82
|
+
'io.modelcontextprotocol/serverInfo': {
|
|
83
|
+
name: 'SquadRules',
|
|
84
|
+
version: getBuildVersion()
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=pagination.js.map
|
|
@@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