slab-mcp 0.1.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/README.md +264 -0
- package/dist/client.d.ts +26 -0
- package/dist/client.js +100 -0
- package/dist/client.js.map +1 -0
- package/dist/config.d.ts +21 -0
- package/dist/config.js +34 -0
- package/dist/config.js.map +1 -0
- package/dist/context.d.ts +20 -0
- package/dist/context.js +39 -0
- package/dist/context.js.map +1 -0
- package/dist/errors.d.ts +38 -0
- package/dist/errors.js +76 -0
- package/dist/errors.js.map +1 -0
- package/dist/format.d.ts +64 -0
- package/dist/format.js +125 -0
- package/dist/format.js.map +1 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +52 -0
- package/dist/index.js.map +1 -0
- package/dist/prompts/index.d.ts +23 -0
- package/dist/prompts/index.js +104 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/resources/index.d.ts +25 -0
- package/dist/resources/index.js +60 -0
- package/dist/resources/index.js.map +1 -0
- package/dist/tools/catalog.d.ts +93 -0
- package/dist/tools/catalog.js +103 -0
- package/dist/tools/catalog.js.map +1 -0
- package/dist/tools/collection.d.ts +87 -0
- package/dist/tools/collection.js +130 -0
- package/dist/tools/collection.js.map +1 -0
- package/dist/tools/community.d.ts +10 -0
- package/dist/tools/community.js +74 -0
- package/dist/tools/community.js.map +1 -0
- package/dist/tools/filters.d.ts +51 -0
- package/dist/tools/filters.js +54 -0
- package/dist/tools/filters.js.map +1 -0
- package/dist/tools/index.d.ts +22 -0
- package/dist/tools/index.js +55 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/meta.d.ts +33 -0
- package/dist/tools/meta.js +98 -0
- package/dist/tools/meta.js.map +1 -0
- package/dist/tools/pricing.d.ts +30 -0
- package/dist/tools/pricing.js +90 -0
- package/dist/tools/pricing.js.map +1 -0
- package/dist/tools/types.d.ts +69 -0
- package/dist/tools/types.js +50 -0
- package/dist/tools/types.js.map +1 -0
- package/dist/tools/writes.d.ts +128 -0
- package/dist/tools/writes.js +168 -0
- package/dist/tools/writes.js.map +1 -0
- package/dist/types.d.ts +80 -0
- package/dist/types.js +11 -0
- package/dist/types.js.map +1 -0
- package/package.json +53 -0
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/** Catalog tools: finding cards, products, and what's in a product. */
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { join, money, pageHeader, text, facetLines } from '../format.js';
|
|
4
|
+
import { DEFAULT_LIMIT, cardFilterShape, paginationShape } from './filters.js';
|
|
5
|
+
import { READ_ONLY, defineTool } from './types.js';
|
|
6
|
+
/** One card on one line. UUID first — it is the only field the model must carry forward. */
|
|
7
|
+
export function cardLine(card) {
|
|
8
|
+
const players = (card.subjects ?? []).map((s) => join(' / ', s.name, s.team)).filter(Boolean).join(' + ');
|
|
9
|
+
const attrs = (card.attributes ?? []).map((a) => a.name).filter(Boolean).join(', ');
|
|
10
|
+
const fmv = card.market?.fair_market_value;
|
|
11
|
+
return join(' | ', card.uuid, join(' ', card.season ?? card.year, card.brand, card.set_name), card.subset, `#${card.card_number ?? '?'}`, players || undefined, card.finish ?? 'base', card.print_run ? `/${card.print_run}` : undefined, attrs || undefined, fmv !== null && fmv !== undefined
|
|
12
|
+
? `FMV ${money(fmv)}${card.market?.grade_key ? ` (${card.market.grade_key})` : ''}`
|
|
13
|
+
: undefined, card.owned_quantity ? `owned x${card.owned_quantity}` : undefined);
|
|
14
|
+
}
|
|
15
|
+
export const searchCards = defineTool({
|
|
16
|
+
name: 'search_cards',
|
|
17
|
+
title: 'Search the card catalog',
|
|
18
|
+
description: 'Search slab\'s catalog of trading cards. This is the entry point for nearly everything else: ' +
|
|
19
|
+
'the `uuid` on each result is what get_card_pricing and add_copy take, and there is no way to ' +
|
|
20
|
+
'look a card up by UUID directly, so search first and carry the UUID forward.\n\n' +
|
|
21
|
+
'A parallel is its own card — the same slot in a different finish — so a player in one set can ' +
|
|
22
|
+
'return dozens of rows. Narrow with `finish`, `base_only`, or `numbered_max` rather than paging ' +
|
|
23
|
+
'through them.\n\n' +
|
|
24
|
+
'Set `include_market` to attach each card\'s current fair market value. That costs real query ' +
|
|
25
|
+
'time, so leave it off when you are only identifying a card. Set `facets` to get counts per ' +
|
|
26
|
+
'dimension instead of guessing what to filter on next — the cheapest way to explore a big result set.',
|
|
27
|
+
inputSchema: z.object({
|
|
28
|
+
...cardFilterShape,
|
|
29
|
+
...paginationShape,
|
|
30
|
+
include_market: z.boolean().optional().describe('Attach fair market value to each card. Off by default; slower.'),
|
|
31
|
+
owned: z.boolean().optional().describe('true = only cards you own a copy of, false = only ones you do not.'),
|
|
32
|
+
facets: z
|
|
33
|
+
.array(z.string())
|
|
34
|
+
.optional()
|
|
35
|
+
.describe('Return per-value counts for these dimensions alongside the results. The dimensions each search accepts are served by get_vocab (`facet_dimensions`) — read them rather than assuming.'),
|
|
36
|
+
sort: z.string().optional().describe('Sort key: year, card_number, numbered, subject, brand, or set. Call get_vocab for the exact grammar.'),
|
|
37
|
+
}),
|
|
38
|
+
annotations: READ_ONLY,
|
|
39
|
+
mutates: false,
|
|
40
|
+
async handler(input, ctx) {
|
|
41
|
+
const { limit = DEFAULT_LIMIT, offset = 0, ...rest } = input;
|
|
42
|
+
const result = await ctx.client.request('POST', '/cards/search', {
|
|
43
|
+
body: { ...rest, limit, offset },
|
|
44
|
+
});
|
|
45
|
+
const items = result.items ?? [];
|
|
46
|
+
return text(pageHeader('cards', result.total, items.length, offset), '', ...items.map(cardLine), ...facetLines(result.facets));
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
export const searchSets = defineTool({
|
|
50
|
+
name: 'search_sets',
|
|
51
|
+
title: 'Search card products (sets)',
|
|
52
|
+
description: 'Find a release — a product like "2025-26 Upper Deck SP Authentic". Returns each set\'s UUID ' +
|
|
53
|
+
'(for get_set_detail) and slug (for the `set_slug` filter on search_cards), plus its card count ' +
|
|
54
|
+
'and current sealed hobby box price where one is known.\n\n' +
|
|
55
|
+
'Reach for this when the user names a product rather than a player, or when you need to scope a ' +
|
|
56
|
+
'card search to one release.',
|
|
57
|
+
inputSchema: z.object({
|
|
58
|
+
q: z.string().optional().describe('Set name, substring match (e.g. "sp authentic").'),
|
|
59
|
+
brand: z.array(z.string()).optional().describe('Brand name(s), any-of.'),
|
|
60
|
+
year: z.number().int().optional().describe('Season-start year — 2025 means 2025-26.'),
|
|
61
|
+
sport: z.string().optional().describe('Sport name.'),
|
|
62
|
+
...paginationShape,
|
|
63
|
+
}),
|
|
64
|
+
annotations: READ_ONLY,
|
|
65
|
+
mutates: false,
|
|
66
|
+
async handler(input, ctx) {
|
|
67
|
+
const { limit = DEFAULT_LIMIT, offset = 0, ...rest } = input;
|
|
68
|
+
const result = await ctx.client.request('POST', '/sets/search', {
|
|
69
|
+
body: { ...rest, limit, offset },
|
|
70
|
+
});
|
|
71
|
+
const items = result.items ?? [];
|
|
72
|
+
return text(pageHeader('sets', result.total, items.length, offset), '', ...items.map((set) => join(' | ', set.uuid, set.name ?? set.slug, set.slug, set.card_count ? `${set.card_count} cards` : undefined, set.box_price ? `box ${money(set.box_price)}` : undefined)));
|
|
73
|
+
},
|
|
74
|
+
});
|
|
75
|
+
export const getSetDetail = defineTool({
|
|
76
|
+
name: 'get_set_detail',
|
|
77
|
+
title: 'Sealed prices and top cards for a set',
|
|
78
|
+
description: 'Everything you need to reason about one product: its sealed SKUs (hobby box, case, blaster…) ' +
|
|
79
|
+
'with current market prices, and its most valuable single cards by fair market value.\n\n' +
|
|
80
|
+
'This is the pair of numbers behind "is this box worth ripping" — what the sealed product costs ' +
|
|
81
|
+
'against what the chase cards in it are worth. It is NOT a rip-EV calculation: it does not weight ' +
|
|
82
|
+
'those cards by pull odds, so do not present the top card\'s value as an expected return.\n\n' +
|
|
83
|
+
'`set_uuid` comes from search_sets.',
|
|
84
|
+
inputSchema: z.object({
|
|
85
|
+
set_uuid: z.string().describe('Set UUID, from search_sets.'),
|
|
86
|
+
top_cards: z.number().int().min(1).max(50).optional().describe('How many top cards to return. Default 10.'),
|
|
87
|
+
}),
|
|
88
|
+
annotations: READ_ONLY,
|
|
89
|
+
mutates: false,
|
|
90
|
+
async handler(input, ctx) {
|
|
91
|
+
const limit = input.top_cards ?? 10;
|
|
92
|
+
const [sealed, top] = await Promise.all([
|
|
93
|
+
ctx.client.request('GET', `/sets/${input.set_uuid}/sealed`),
|
|
94
|
+
ctx.client.request('GET', `/sets/${input.set_uuid}/top-cards`, {
|
|
95
|
+
query: { limit },
|
|
96
|
+
}),
|
|
97
|
+
]);
|
|
98
|
+
const sealedLines = (sealed ?? []).map((product) => join(' | ', String(product.uuid ?? ''), String(product.format ?? 'unknown format'), product.market_value != null ? `market ${money(product.market_value)}` : 'market —', product.msrp != null ? `MSRP ${money(product.msrp)}` : undefined));
|
|
99
|
+
return text('Sealed products:', ...(sealedLines.length ? sealedLines : [' (none — this set has no sealed SKUs loaded)']), '', `Top ${limit} cards by fair market value:`, ...((top.items ?? []).map(cardLine) ?? []));
|
|
100
|
+
},
|
|
101
|
+
});
|
|
102
|
+
export const catalogTools = [searchCards, searchSets, getSetDetail];
|
|
103
|
+
//# sourceMappingURL=catalog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../src/tools/catalog.ts"],"names":[],"mappings":"AAAA,uEAAuE;AAEvE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAEzE,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEnD,4FAA4F;AAC5F,MAAM,UAAU,QAAQ,CAAC,IAAa;IACpC,MAAM,OAAO,GAAG,CAAC,IAAI,CAAC,QAAQ,IAAI,EAAE,C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C3C,CAAC;IACJ,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,WAAW,EAAE,UAAU,EAAE,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/** Read tools for the user's own collection. */
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const searchCollection: import("./types.js").ToolModule<z.ZodObject<{
|
|
4
|
+
status: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
5
|
+
graded: z.ZodOptional<z.ZodBoolean>;
|
|
6
|
+
grading_company: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
7
|
+
acquisition_type: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
8
|
+
acquired_after: z.ZodOptional<z.ZodString>;
|
|
9
|
+
acquired_before: z.ZodOptional<z.ZodString>;
|
|
10
|
+
storage_location: z.ZodOptional<z.ZodString>;
|
|
11
|
+
facets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
12
|
+
sort: z.ZodOptional<z.ZodString>;
|
|
13
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
14
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
15
|
+
q: z.ZodOptional<z.ZodString>;
|
|
16
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
17
|
+
subject_exact: z.ZodOptional<z.ZodBoolean>;
|
|
18
|
+
card_number: z.ZodOptional<z.ZodString>;
|
|
19
|
+
set_slug: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
20
|
+
brand: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
21
|
+
subset: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
22
|
+
year: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
year_min: z.ZodOptional<z.ZodNumber>;
|
|
24
|
+
year_max: z.ZodOptional<z.ZodNumber>;
|
|
25
|
+
team: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
26
|
+
league: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
27
|
+
attribute: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
28
|
+
attribute_all: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
29
|
+
attribute_not: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
30
|
+
rookie: z.ZodOptional<z.ZodBoolean>;
|
|
31
|
+
auto: z.ZodOptional<z.ZodBoolean>;
|
|
32
|
+
relic: z.ZodOptional<z.ZodBoolean>;
|
|
33
|
+
finish: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
34
|
+
base_only: z.ZodOptional<z.ZodBoolean>;
|
|
35
|
+
parallel_only: z.ZodOptional<z.ZodBoolean>;
|
|
36
|
+
numbered_min: z.ZodOptional<z.ZodNumber>;
|
|
37
|
+
numbered_max: z.ZodOptional<z.ZodNumber>;
|
|
38
|
+
is_numbered: z.ZodOptional<z.ZodBoolean>;
|
|
39
|
+
is_1of1: z.ZodOptional<z.ZodBoolean>;
|
|
40
|
+
collector_uuid: z.ZodOptional<z.ZodString>;
|
|
41
|
+
}, z.core.$strip>>;
|
|
42
|
+
export declare const getDashboard: import("./types.js").ToolModule<z.ZodObject<{
|
|
43
|
+
collector_uuid: z.ZodOptional<z.ZodString>;
|
|
44
|
+
include_history: z.ZodOptional<z.ZodBoolean>;
|
|
45
|
+
}, z.core.$strip>>;
|
|
46
|
+
export declare const collectionTools: (import("./types.js").ToolModule<z.ZodObject<{
|
|
47
|
+
status: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
48
|
+
graded: z.ZodOptional<z.ZodBoolean>;
|
|
49
|
+
grading_company: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
50
|
+
acquisition_type: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
51
|
+
acquired_after: z.ZodOptional<z.ZodString>;
|
|
52
|
+
acquired_before: z.ZodOptional<z.ZodString>;
|
|
53
|
+
storage_location: z.ZodOptional<z.ZodString>;
|
|
54
|
+
facets: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
55
|
+
sort: z.ZodOptional<z.ZodString>;
|
|
56
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
57
|
+
offset: z.ZodOptional<z.ZodNumber>;
|
|
58
|
+
q: z.ZodOptional<z.ZodString>;
|
|
59
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
60
|
+
subject_exact: z.ZodOptional<z.ZodBoolean>;
|
|
61
|
+
card_number: z.ZodOptional<z.ZodString>;
|
|
62
|
+
set_slug: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
63
|
+
brand: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
64
|
+
subset: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
65
|
+
year: z.ZodOptional<z.ZodNumber>;
|
|
66
|
+
year_min: z.ZodOptional<z.ZodNumber>;
|
|
67
|
+
year_max: z.ZodOptional<z.ZodNumber>;
|
|
68
|
+
team: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
69
|
+
league: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
70
|
+
attribute: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
71
|
+
attribute_all: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
72
|
+
attribute_not: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
73
|
+
rookie: z.ZodOptional<z.ZodBoolean>;
|
|
74
|
+
auto: z.ZodOptional<z.ZodBoolean>;
|
|
75
|
+
relic: z.ZodOptional<z.ZodBoolean>;
|
|
76
|
+
finish: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
77
|
+
base_only: z.ZodOptional<z.ZodBoolean>;
|
|
78
|
+
parallel_only: z.ZodOptional<z.ZodBoolean>;
|
|
79
|
+
numbered_min: z.ZodOptional<z.ZodNumber>;
|
|
80
|
+
numbered_max: z.ZodOptional<z.ZodNumber>;
|
|
81
|
+
is_numbered: z.ZodOptional<z.ZodBoolean>;
|
|
82
|
+
is_1of1: z.ZodOptional<z.ZodBoolean>;
|
|
83
|
+
collector_uuid: z.ZodOptional<z.ZodString>;
|
|
84
|
+
}, z.core.$strip>> | import("./types.js").ToolModule<z.ZodObject<{
|
|
85
|
+
collector_uuid: z.ZodOptional<z.ZodString>;
|
|
86
|
+
include_history: z.ZodOptional<z.ZodBoolean>;
|
|
87
|
+
}, z.core.$strip>>)[];
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
/** Read tools for the user's own collection. */
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { facetLines, glossaryLines, join, metric, money, pageHeader, text } from '../format.js';
|
|
4
|
+
import { DEFAULT_LIMIT, cardFilterShape, paginationShape } from './filters.js';
|
|
5
|
+
import { READ_ONLY, defineTool } from './types.js';
|
|
6
|
+
const collectorArg = z
|
|
7
|
+
.string()
|
|
8
|
+
.optional()
|
|
9
|
+
.describe('Collector UUID. Omit it — the server uses the collector this API key acts for. Only pass one for a multi-collector account.');
|
|
10
|
+
function copyLine(copy) {
|
|
11
|
+
const card = copy.card;
|
|
12
|
+
const players = (card?.subjects ?? []).map((s) => s.name).filter(Boolean).join(' + ');
|
|
13
|
+
const grade = copy.grading_company ? `${copy.grading_company} ${copy.grade ?? ''}`.trim() : 'raw';
|
|
14
|
+
const fmv = copy.market?.fair_market_value;
|
|
15
|
+
return join(' | ', copy.uuid, join(' ', card?.season ?? card?.year, card?.brand, card?.set_name), card?.subset, `#${card?.card_number ?? '?'}`, players || undefined, card?.finish ?? 'base', copy.serial_number && card?.print_run ? `${copy.serial_number}/${card.print_run}` : card?.print_run ? `/${card.print_run}` : undefined, grade, copy.quantity && copy.quantity > 1 ? `x${copy.quantity}` : undefined, `cost ${money(copy.cost_basis)}`, `FMV ${money(fmv)}`, copy.status && copy.status !== 'in_collection' ? copy.status : undefined, copy.storage_location ?? undefined);
|
|
16
|
+
}
|
|
17
|
+
export const searchCollection = defineTool({
|
|
18
|
+
name: 'search_collection',
|
|
19
|
+
title: "Search the user's collection",
|
|
20
|
+
description: 'Search the physical copies the user owns. Takes the full card filter grammar from search_cards ' +
|
|
21
|
+
'plus copy-level filters (grade, status, acquisition, storage), and returns a financial summary ' +
|
|
22
|
+
'across the matched set.\n\n' +
|
|
23
|
+
'Each row is one physical copy, so the same card owned twice is two rows with two cost bases. ' +
|
|
24
|
+
'The `uuid` here is a COPY uuid — that is what update_copy and remove_copy take. The card\'s own ' +
|
|
25
|
+
'uuid is a different value.\n\n' +
|
|
26
|
+
'Money: `cost_basis` is what the copy cost all-in (acquisition plus grading, shipping, and any ' +
|
|
27
|
+
'other logged costs); FMV is the current appraisal. The gap between them is paper profit, not ' +
|
|
28
|
+
'realised — nothing is realised until the copy is sold.\n\n' +
|
|
29
|
+
'The result ends with a financial summary across every match, not just the page shown. Call ' +
|
|
30
|
+
"explain_metrics and use slab's own wording for those figures rather than paraphrasing them.",
|
|
31
|
+
inputSchema: z.object({
|
|
32
|
+
collector_uuid: collectorArg,
|
|
33
|
+
...cardFilterShape,
|
|
34
|
+
...paginationShape,
|
|
35
|
+
status: z.array(z.string()).optional().describe('Copy status, any-of: in_collection, for_trade, for_sale, sold.'),
|
|
36
|
+
graded: z.boolean().optional().describe('true = only professionally graded copies, false = only raw.'),
|
|
37
|
+
grading_company: z.array(z.string()).optional().describe('Grading company, any-of (PSA, BGS, SGC, CGC).'),
|
|
38
|
+
acquisition_type: z.array(z.string()).optional().describe('How it was acquired, any-of: purchase, pack_pull, trade, gift, other.'),
|
|
39
|
+
acquired_after: z.string().optional().describe('ISO date (YYYY-MM-DD) — copies acquired on or after this date.'),
|
|
40
|
+
acquired_before: z.string().optional().describe('ISO date (YYYY-MM-DD) — copies acquired on or before this date.'),
|
|
41
|
+
storage_location: z.string().optional().describe('Storage location, substring match.'),
|
|
42
|
+
facets: z
|
|
43
|
+
.array(z.string())
|
|
44
|
+
.optional()
|
|
45
|
+
.describe('Return per-value counts for these dimensions — collection search accepts card-level dimensions as well as copy-level ones. get_vocab (`facet_dimensions`) serves the accepted list per search; read it rather than assuming.'),
|
|
46
|
+
sort: z.string().optional().describe('Sort key. Call get_vocab for the grammar.'),
|
|
47
|
+
}),
|
|
48
|
+
annotations: READ_ONLY,
|
|
49
|
+
mutates: false,
|
|
50
|
+
async handler(input, ctx) {
|
|
51
|
+
const { collector_uuid, limit = DEFAULT_LIMIT, offset = 0, ...rest } = input;
|
|
52
|
+
const collector = await ctx.collector(collector_uuid);
|
|
53
|
+
const result = await ctx.client.request('POST', `/collectors/${collector}/collection/search`, { body: { ...rest, limit, offset } });
|
|
54
|
+
const items = result.items ?? [];
|
|
55
|
+
const summary = result.summary
|
|
56
|
+
? [
|
|
57
|
+
'',
|
|
58
|
+
'Financial summary across all matches:',
|
|
59
|
+
...Object.entries(result.summary).map(([k, v]) => ` ${k}: ${metric(k, v)}`),
|
|
60
|
+
'',
|
|
61
|
+
'Call explain_metrics before reporting any of these figures to the user.',
|
|
62
|
+
]
|
|
63
|
+
: [];
|
|
64
|
+
return text(pageHeader('copies', result.total, items.length, offset), '', ...items.map(copyLine), ...summary, ...facetLines(result.facets));
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
export const getDashboard = defineTool({
|
|
68
|
+
name: 'get_dashboard',
|
|
69
|
+
title: 'Collection dashboard and portfolio history',
|
|
70
|
+
description: "The headline numbers for the user's whole collection: total copies, cost basis, current market " +
|
|
71
|
+
'value, unrealised gain/loss, and the biggest movers.\n\n' +
|
|
72
|
+
'Optionally includes the portfolio value time series. That series is AS-OF: every point values ' +
|
|
73
|
+
'only the copies owned on that date, so it steps UP when the user buys a card. Differencing two ' +
|
|
74
|
+
'points therefore mixes purchases with price movement and is not a return — if the user asks how ' +
|
|
75
|
+
'their portfolio performed, use `portfolio_change_7d` from the dashboard, which holds the basket ' +
|
|
76
|
+
'constant and is pure appraisal drift.\n\n' +
|
|
77
|
+
"Every number here has a definition in slab's glossary, and the response embeds the ones it " +
|
|
78
|
+
'needs. Before you report a figure to the user, call explain_metrics and use that wording — ' +
|
|
79
|
+
'`priced_coverage`, `portfolio_roi`, and `portfolio_change_7d` in particular all mean something ' +
|
|
80
|
+
'narrower than their names suggest, and a plausible-sounding paraphrase of them is wrong.',
|
|
81
|
+
inputSchema: z.object({
|
|
82
|
+
collector_uuid: collectorArg,
|
|
83
|
+
include_history: z.boolean().optional().describe('Include the as-of portfolio value series. Default false.'),
|
|
84
|
+
}),
|
|
85
|
+
annotations: READ_ONLY,
|
|
86
|
+
mutates: false,
|
|
87
|
+
async handler(input, ctx) {
|
|
88
|
+
const collector = await ctx.collector(input.collector_uuid);
|
|
89
|
+
const dashboard = await ctx.client.request('GET', `/collectors/${collector}/dashboard`);
|
|
90
|
+
const lines = ['Collection dashboard:'];
|
|
91
|
+
for (const [key, value] of Object.entries(dashboard)) {
|
|
92
|
+
if (value === null || value === undefined || typeof value === 'object')
|
|
93
|
+
continue;
|
|
94
|
+
lines.push(` ${key}: ${metric(key, value)}`);
|
|
95
|
+
}
|
|
96
|
+
// The highlight lists are the most useful part of this payload and are
|
|
97
|
+
// what a user actually asks about ("what's my best card?").
|
|
98
|
+
//
|
|
99
|
+
// The uuid on these rows is a COPY uuid, not a card uuid — the dashboard
|
|
100
|
+
// is collector-scoped, so a highlight is one of the user's copies. The
|
|
101
|
+
// wire field is a bare `uuid` on a model called HighlightCard, so it is
|
|
102
|
+
// easy to mistake for a card id and feed to get_card_pricing, which 404s.
|
|
103
|
+
// Prefixing it here is what stops that.
|
|
104
|
+
for (const board of ['most_valuable', 'rarest', 'top_sets']) {
|
|
105
|
+
const rows = dashboard[board];
|
|
106
|
+
if (!Array.isArray(rows) || !rows.length)
|
|
107
|
+
continue;
|
|
108
|
+
lines.push('', `${board}:`);
|
|
109
|
+
for (const row of rows) {
|
|
110
|
+
lines.push(' ' +
|
|
111
|
+
join(' | ', typeof row.uuid === 'string' ? `copy:${row.uuid}` : undefined, Array.isArray(row.subjects) ? row.subjects.join(' + ') : row.label, row.set_name, row.card_number ? `#${row.card_number}` : undefined, row.finish ?? undefined, row.print_run ? `/${row.print_run}` : undefined, row.grade_key, row.fair_market_value != null ? money(row.fair_market_value) : undefined, row.count != null ? `${row.count} cards` : undefined));
|
|
112
|
+
}
|
|
113
|
+
if (board !== 'top_sets') {
|
|
114
|
+
lines.push(' (these are COPY uuids — pass them to update_copy/remove_copy. For pricing, find the ' +
|
|
115
|
+
'card with search_cards first; a copy uuid will 404 on get_card_pricing.)');
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// slab embeds the definitions for these boards in the payload itself.
|
|
119
|
+
lines.push(...glossaryLines(dashboard.glossary));
|
|
120
|
+
if (input.include_history) {
|
|
121
|
+
const history = await ctx.client.request('GET', `/collectors/${collector}/portfolio/history`);
|
|
122
|
+
const points = history.points ?? [];
|
|
123
|
+
lines.push('', `Portfolio value, as-of (${points.length} points). Steps up on purchases — not a return series:`);
|
|
124
|
+
lines.push(...points.map((p) => ` ${p.date} ${money(p.value)}${p.total_copies != null ? ` (${p.total_copies} copies)` : ''}`));
|
|
125
|
+
}
|
|
126
|
+
return text(...lines);
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
export const collectionTools = [searchCollection, getDashboard];
|
|
130
|
+
//# sourceMappingURL=collection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"collection.js","sourceRoot":"","sources":["../../src/tools/collection.ts"],"names":[],"mappings":"AAAA,gDAAgD;AAEhD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAGhG,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEnD,MAAM,YAAY,GAAG,CAAC;KACnB,MAAM,EAAE;KACR,QAAQ,EAAE;KACV,Q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AC;IACxB,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,gBAAgB,EAAE,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/** The public, aggregate picture across all of slab. */
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const getCommunity: import("./types.js").ToolModule<z.ZodObject<{
|
|
4
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
5
|
+
boards: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
6
|
+
}, z.core.$strip>>;
|
|
7
|
+
export declare const communityTools: import("./types.js").ToolModule<z.ZodObject<{
|
|
8
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
9
|
+
boards: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
10
|
+
}, z.core.$strip>>[];
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/** The public, aggregate picture across all of slab. */
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
import { glossaryLines, join, metric, money, text } from '../format.js';
|
|
4
|
+
import { READ_ONLY, defineTool } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Leaderboard rows vary in shape by board, and some nest the card under a
|
|
7
|
+
* `card` key while carrying their own count alongside it (`rarest_owned` is
|
|
8
|
+
* `{card: {...}, collector_count}`). Reading only top-level fields renders
|
|
9
|
+
* those boards as blank lines — which is what an earlier version of this did,
|
|
10
|
+
* silently, because a missing field formats as nothing rather than failing.
|
|
11
|
+
*/
|
|
12
|
+
function leaderboardLine(row) {
|
|
13
|
+
const card = (row.card ?? row);
|
|
14
|
+
const outer = row;
|
|
15
|
+
return (' ' +
|
|
16
|
+
join(' | ', typeof card.uuid === 'string' ? card.uuid : undefined, Array.isArray(card.subjects) ? card.subjects.join(' + ') : card.name, join(' ', card.season, card.set_name), card.subset, card.card_number ? `#${card.card_number}` : undefined, card.finish ?? undefined, card.print_run ? `/${card.print_run}` : undefined, card.fair_market_value != null ? money(card.fair_market_value) : undefined,
|
|
17
|
+
// Player-leaderboard measures. These come from counting real sales in a
|
|
18
|
+
// window — the comps lane — so they ARE market activity, unlike an
|
|
19
|
+
// appraisal difference.
|
|
20
|
+
outer.sales_30d != null ? `${outer.sales_30d} sales/30d (prev ${outer.sales_prev_30d ?? '?'})` : undefined, outer.dollar_volume_30d != null ? `volume ${money(outer.dollar_volume_30d)}` : undefined, outer.distinct_cards_30d != null ? `${outer.distinct_cards_30d} distinct cards` : undefined, outer.price_trend_pct != null ? `trend ${outer.price_trend_pct}%` : undefined, outer.collector_count != null ? `${outer.collector_count} collectors` : undefined, outer.owner_count != null ? `${outer.owner_count} owners` : undefined, outer.count != null ? `n=${outer.count}` : undefined));
|
|
21
|
+
}
|
|
22
|
+
export const getCommunity = defineTool({
|
|
23
|
+
name: 'get_community',
|
|
24
|
+
title: 'Community activity and leaderboards',
|
|
25
|
+
description: 'The public picture across all of slab in one call: catalog totals, a feed of recent activity, ' +
|
|
26
|
+
'and leaderboards — most valuable split by raw and graded, most-collected cards and players by ' +
|
|
27
|
+
'how many distinct collectors own them, hottest players, and rarest-owned by print run.\n\n' +
|
|
28
|
+
'Reach for this for "what is hot right now", "what is the rarest thing anyone owns", or to give ' +
|
|
29
|
+
"a user a sense of where their collection sits against everyone else's.\n\n" +
|
|
30
|
+
'Everything here is aggregate and anonymised by design: no collector identities and no ' +
|
|
31
|
+
"individual collectors' prices. Do not present any of it as being about a specific person.\n\n" +
|
|
32
|
+
"The response embeds slab's glossary entry for each leaderboard — use that wording when you " +
|
|
33
|
+
'explain a board rather than inferring what it measures from its name, and call explain_metrics ' +
|
|
34
|
+
'for anything the embedded set does not cover. "Hottest" in particular is computed from real ' +
|
|
35
|
+
'sales in a window, which is not the same thing as an appraisal moving.',
|
|
36
|
+
inputSchema: z.object({
|
|
37
|
+
limit: z.number().int().min(1).max(50).optional().describe('Rows per leaderboard. Default 10.'),
|
|
38
|
+
boards: z
|
|
39
|
+
.array(z.string())
|
|
40
|
+
.optional()
|
|
41
|
+
.describe('Only these boards, e.g. ["hottest_players","rarest_owned"]. Omit for all — the full payload is large.'),
|
|
42
|
+
}),
|
|
43
|
+
annotations: READ_ONLY,
|
|
44
|
+
mutates: false,
|
|
45
|
+
async handler(input, ctx) {
|
|
46
|
+
const board = await ctx.client.request('GET', '/community', {
|
|
47
|
+
query: { limit: input.limit ?? 10 },
|
|
48
|
+
});
|
|
49
|
+
const lines = [];
|
|
50
|
+
if (board.stats && (!input.boards || input.boards.includes('stats'))) {
|
|
51
|
+
lines.push('Catalog totals:');
|
|
52
|
+
for (const [key, value] of Object.entries(board.stats))
|
|
53
|
+
lines.push(` ${key}: ${metric(key, value)}`);
|
|
54
|
+
}
|
|
55
|
+
if (Array.isArray(board.ticker) && (!input.boards || input.boards.includes('ticker'))) {
|
|
56
|
+
lines.push('', 'Recent activity:');
|
|
57
|
+
lines.push(...board.ticker.map((entry) => ` ${entry}`));
|
|
58
|
+
}
|
|
59
|
+
const skip = new Set(['stats', 'ticker', 'glossary']);
|
|
60
|
+
for (const [name, value] of Object.entries(board)) {
|
|
61
|
+
if (skip.has(name) || !Array.isArray(value))
|
|
62
|
+
continue;
|
|
63
|
+
if (input.boards && !input.boards.includes(name))
|
|
64
|
+
continue;
|
|
65
|
+
lines.push('', `${name}:`);
|
|
66
|
+
lines.push(...value.map(leaderboardLine));
|
|
67
|
+
}
|
|
68
|
+
// slab ships the definitions with the data — render them, don't drop them.
|
|
69
|
+
lines.push(...glossaryLines(board.glossary));
|
|
70
|
+
return text(...lines);
|
|
71
|
+
},
|
|
72
|
+
});
|
|
73
|
+
export const communityTools = [getCommunity];
|
|
74
|
+
//# sourceMappingURL=community.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"community.js","sourceRoot":"","sources":["../../src/tools/community.ts"],"names":[],"mappings":"AAAA,wDAAwD;AAExD,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,aAAa,EA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AAM,IAAI,GAAG,IAAI,GAAG,CAAC,CAAC,OAAO,EAAE,QAAQ,EAAE,UAAU,CAAC,CAAC,CAAC;QACtD,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YAClD,IAAI,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;gBAAE,SAAS;YACtD,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC;gBAAE,SAAS;YAC3D,KAAK,CAAC,IAAI,CAAC,EAAE,EAAE,GAAG,IAAI,GAAG,CAAC,CAAC;YAC3B,KAAK,CAAC,IAAI,CAAC,GAAI,KAAwC,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC;QAChF,CAAC;QAED,2EAA2E;QAC3E,KAAK,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC;QAE7C,OAAO,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;IACxB,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,YAAY,CAAC,CAAC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared card filter grammar, defined once.
|
|
3
|
+
*
|
|
4
|
+
* This mirrors `CardFilter` in the slab wire contract, and both `search_cards`
|
|
5
|
+
* and `search_collection` spread it — the same seam the slab CLI keeps between
|
|
6
|
+
* `flags.py` and `CardFilter`, for the same reason: two copies of a filter
|
|
7
|
+
* grammar drift, and the drift shows up as a filter that silently does nothing.
|
|
8
|
+
*
|
|
9
|
+
* Note what these descriptions do NOT do: enumerate valid brands, teams,
|
|
10
|
+
* attributes, or finishes. Those are live catalog dimensions that grow every
|
|
11
|
+
* time a set is seeded, so a hardcoded copy here would rot. `get_vocab` and
|
|
12
|
+
* the `slab://vocab` resource serve the current values instead.
|
|
13
|
+
*
|
|
14
|
+
* The full grammar is in `GET /openapi.json` (exposed as `slab://openapi`);
|
|
15
|
+
* this is the well-trodden subset. Adding a filter is one line here and it
|
|
16
|
+
* appears in both search tools at once.
|
|
17
|
+
*/
|
|
18
|
+
import { z } from 'zod';
|
|
19
|
+
export declare const cardFilterShape: {
|
|
20
|
+
readonly q: z.ZodOptional<z.ZodString>;
|
|
21
|
+
readonly subject: z.ZodOptional<z.ZodString>;
|
|
22
|
+
readonly subject_exact: z.ZodOptional<z.ZodBoolean>;
|
|
23
|
+
readonly card_number: z.ZodOptional<z.ZodString>;
|
|
24
|
+
readonly set_slug: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
25
|
+
readonly brand: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
26
|
+
readonly subset: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
27
|
+
readonly year: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
readonly year_min: z.ZodOptional<z.ZodNumber>;
|
|
29
|
+
readonly year_max: z.ZodOptional<z.ZodNumber>;
|
|
30
|
+
readonly team: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
31
|
+
readonly league: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
32
|
+
readonly attribute: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
33
|
+
readonly attribute_all: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
34
|
+
readonly attribute_not: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
35
|
+
readonly rookie: z.ZodOptional<z.ZodBoolean>;
|
|
36
|
+
readonly auto: z.ZodOptional<z.ZodBoolean>;
|
|
37
|
+
readonly relic: z.ZodOptional<z.ZodBoolean>;
|
|
38
|
+
readonly finish: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
39
|
+
readonly base_only: z.ZodOptional<z.ZodBoolean>;
|
|
40
|
+
readonly parallel_only: z.ZodOptional<z.ZodBoolean>;
|
|
41
|
+
readonly numbered_min: z.ZodOptional<z.ZodNumber>;
|
|
42
|
+
readonly numbered_max: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
readonly is_numbered: z.ZodOptional<z.ZodBoolean>;
|
|
44
|
+
readonly is_1of1: z.ZodOptional<z.ZodBoolean>;
|
|
45
|
+
};
|
|
46
|
+
export declare const paginationShape: {
|
|
47
|
+
readonly limit: z.ZodOptional<z.ZodNumber>;
|
|
48
|
+
readonly offset: z.ZodOptional<z.ZodNumber>;
|
|
49
|
+
};
|
|
50
|
+
/** Default page size. Lower than the API's own default of 50, on purpose. */
|
|
51
|
+
export declare const DEFAULT_LIMIT = 25;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The shared card filter grammar, defined once.
|
|
3
|
+
*
|
|
4
|
+
* This mirrors `CardFilter` in the slab wire contract, and both `search_cards`
|
|
5
|
+
* and `search_collection` spread it — the same seam the slab CLI keeps between
|
|
6
|
+
* `flags.py` and `CardFilter`, for the same reason: two copies of a filter
|
|
7
|
+
* grammar drift, and the drift shows up as a filter that silently does nothing.
|
|
8
|
+
*
|
|
9
|
+
* Note what these descriptions do NOT do: enumerate valid brands, teams,
|
|
10
|
+
* attributes, or finishes. Those are live catalog dimensions that grow every
|
|
11
|
+
* time a set is seeded, so a hardcoded copy here would rot. `get_vocab` and
|
|
12
|
+
* the `slab://vocab` resource serve the current values instead.
|
|
13
|
+
*
|
|
14
|
+
* The full grammar is in `GET /openapi.json` (exposed as `slab://openapi`);
|
|
15
|
+
* this is the well-trodden subset. Adding a filter is one line here and it
|
|
16
|
+
* appears in both search tools at once.
|
|
17
|
+
*/
|
|
18
|
+
import { z } from 'zod';
|
|
19
|
+
/** A list-valued filter: any-of semantics. The API also accepts a CSV string. */
|
|
20
|
+
const list = (description) => z.array(z.string()).optional().describe(description);
|
|
21
|
+
export const cardFilterShape = {
|
|
22
|
+
q: z.string().optional().describe('Free text across player name, set name, and card number. Start here when the user gave you a phrase rather than structured criteria.'),
|
|
23
|
+
subject: z.string().optional().describe('Player name, case-insensitive substring match (e.g. "mcdavid").'),
|
|
24
|
+
subject_exact: z.boolean().optional().describe('Match `subject` exactly instead of as a substring.'),
|
|
25
|
+
card_number: z.string().optional().describe('Card number, exact match (e.g. "YG-201").'),
|
|
26
|
+
set_slug: list('Set slug(s), any-of. Precise catalog membership. Slugs come from search_sets.'),
|
|
27
|
+
brand: list('Brand name(s), any-of. Valid values come from get_vocab.'),
|
|
28
|
+
subset: list('Subset / insert name(s), any-of (e.g. "Young Guns").'),
|
|
29
|
+
year: z.number().int().optional().describe('Exact season-start year — 2025 means the 2025-26 season.'),
|
|
30
|
+
year_min: z.number().int().optional().describe('Minimum season-start year, inclusive.'),
|
|
31
|
+
year_max: z.number().int().optional().describe('Maximum season-start year, inclusive.'),
|
|
32
|
+
team: list('Team name(s), any-of — the team the player is shown with on the card.'),
|
|
33
|
+
league: list('League name(s), any-of.'),
|
|
34
|
+
attribute: list('Attribute name(s), any-of (e.g. "Rookie", "Autograph"). Valid values come from get_vocab.'),
|
|
35
|
+
attribute_all: list('Attribute name(s) the card must have ALL of.'),
|
|
36
|
+
attribute_not: list('Attribute name(s) to exclude.'),
|
|
37
|
+
rookie: z.boolean().optional().describe('Shortcut for attribute "Rookie".'),
|
|
38
|
+
auto: z.boolean().optional().describe('Shortcut for attribute "Autograph".'),
|
|
39
|
+
relic: z.boolean().optional().describe('Shortcut for attribute "Memorabilia".'),
|
|
40
|
+
finish: list('Finish / parallel name(s), any-of (e.g. "Rainbow"). Valid values come from get_vocab.'),
|
|
41
|
+
base_only: z.boolean().optional().describe('Only base printings (no finish).'),
|
|
42
|
+
parallel_only: z.boolean().optional().describe('Only parallels (cards that have a finish).'),
|
|
43
|
+
numbered_min: z.number().int().optional().describe('Print run at least this large.'),
|
|
44
|
+
numbered_max: z.number().int().optional().describe('Print run at most this large — the lever for "rare" (e.g. 25).'),
|
|
45
|
+
is_numbered: z.boolean().optional().describe('Only serial-numbered cards.'),
|
|
46
|
+
is_1of1: z.boolean().optional().describe('Only one-of-ones.'),
|
|
47
|
+
};
|
|
48
|
+
export const paginationShape = {
|
|
49
|
+
limit: z.number().int().min(1).max(200).optional().describe('Results per page, 1-200. Default 25. Keep this small — every row costs context.'),
|
|
50
|
+
offset: z.number().int().min(0).optional().describe('Rows to skip. Use with the total in the result header to page.'),
|
|
51
|
+
};
|
|
52
|
+
/** Default page size. Lower than the API's own default of 50, on purpose. */
|
|
53
|
+
export const DEFAULT_LIMIT = 25;
|
|
54
|
+
//# sourceMappingURL=filters.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filters.js","sourceRoot":"","sources":["../../src/tools/filters.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,iFAAiF;AACjF,MAAM,IAAI,GAAG,CAAC,WAAmB,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AAE3F,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,sIAAsI,CAAC;IACzK,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,iEAAiE,CAAC;IAC1G,aAAa,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,oDAAoD,CAAC;IACpG,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,2CAA2C,CAAC;IAExF,QAAQ,EAAE,IAAI,CAAC,+EAA+E,CAAC;IAC/F,KAAK,EA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,QAAQ,EAAE,CAAC,QAAQ,CAAC,gCAAgC,CAAC;IACpF,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gEAAgE,CAAC;IACpH,WAAW,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,6BAA6B,CAAC;IAC3E,OAAO,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,mBAAmB,CAAC;CACrD,CAAC;AAEX,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,KAAK,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,iFAAiF,CAAC;IAC9I,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,gEAAgE,CAAC;CAC7G,CAAC;AAEX,6EAA6E;AAC7E,MAAM,CAAC,MAAM,aAAa,GAAG,EAAE,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE REGISTRY.
|
|
3
|
+
*
|
|
4
|
+
* One array is the whole tool surface. Adding a tool is a module under
|
|
5
|
+
* `tools/` plus a line here; nothing downstream changes, because registration
|
|
6
|
+
* is a loop, not a sequence of hand-written `server.registerTool` calls.
|
|
7
|
+
*
|
|
8
|
+
* Write tools are a separate array only so the gate is structural: read tools
|
|
9
|
+
* are always registered, write tools only when the operator turned them on. A
|
|
10
|
+
* tool the server never registers is a tool a model cannot call, which is a
|
|
11
|
+
* stronger guarantee than any instruction in a description.
|
|
12
|
+
*/
|
|
13
|
+
import type { McpServer } from '@modelcontextprotocol/server';
|
|
14
|
+
import type { ToolContext } from '../context.js';
|
|
15
|
+
import type { ToolModule } from './types.js';
|
|
16
|
+
/** Always registered. */
|
|
17
|
+
export declare const READ_TOOLS: ToolModule[];
|
|
18
|
+
/** Registered only when SLAB_MCP_WRITE is on. */
|
|
19
|
+
export declare const WRITE_TOOLS: ToolModule[];
|
|
20
|
+
/** Everything, for tests and documentation. */
|
|
21
|
+
export declare const ALL_TOOLS: ToolModule[];
|
|
22
|
+
export declare function registerTools(server: McpServer, ctx: ToolContext): ToolModule[];
|