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,55 @@
|
|
|
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 { toToolError } from '../errors.js';
|
|
14
|
+
import { catalogTools } from './catalog.js';
|
|
15
|
+
import { collectionTools } from './collection.js';
|
|
16
|
+
import { communityTools } from './community.js';
|
|
17
|
+
import { metaTools } from './meta.js';
|
|
18
|
+
import { pricingTools } from './pricing.js';
|
|
19
|
+
import { writeTools } from './writes.js';
|
|
20
|
+
/** Always registered. */
|
|
21
|
+
export const READ_TOOLS = [
|
|
22
|
+
...catalogTools,
|
|
23
|
+
...pricingTools,
|
|
24
|
+
...collectionTools,
|
|
25
|
+
...communityTools,
|
|
26
|
+
...metaTools,
|
|
27
|
+
];
|
|
28
|
+
/** Registered only when SLAB_MCP_WRITE is on. */
|
|
29
|
+
export const WRITE_TOOLS = [...writeTools];
|
|
30
|
+
/** Everything, for tests and documentation. */
|
|
31
|
+
export const ALL_TOOLS = [...READ_TOOLS, ...WRITE_TOOLS];
|
|
32
|
+
export function registerTools(server, ctx) {
|
|
33
|
+
const active = ctx.config.writesEnabled ? ALL_TOOLS : READ_TOOLS;
|
|
34
|
+
for (const tool of active) {
|
|
35
|
+
server.registerTool(tool.name, {
|
|
36
|
+
title: tool.title,
|
|
37
|
+
description: tool.description,
|
|
38
|
+
inputSchema: tool.inputSchema,
|
|
39
|
+
annotations: tool.annotations,
|
|
40
|
+
},
|
|
41
|
+
// Every handler is wrapped once, here. An unhandled throw in a tool
|
|
42
|
+
// would otherwise surface as a protocol error the model cannot read;
|
|
43
|
+
// toToolError turns it into a result it can act on.
|
|
44
|
+
(async (args) => {
|
|
45
|
+
try {
|
|
46
|
+
return await tool.handler(args, ctx);
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
return toToolError(err);
|
|
50
|
+
}
|
|
51
|
+
}));
|
|
52
|
+
}
|
|
53
|
+
return active;
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,yBAAyB;AACzB,MAAM,CAAC,MAAM,UAAU,GAAiB;IACtC,GAAG,YAAY;IACf,GAAG,YAAY;IACf,GAAG,eAAe;IAClB,GAAG,cAAc;IACjB,GAAG,SAAS;CACb,CAAC;AAEF,iDAAiD;AACjD,MAAM,CAAC,MAAM,WAAW,GAAiB,CAAC,GAAG,UAAU,CAAC,CAAC;AAEzD,+CAA+C;AAC/C,MAAM,CAAC,MAAM,SAAS,GAAiB,CAAC,GAAG,UAAU,EAAE,GAAG,WAAW,CAAC,CAAC;AAEvE,MAAM,UAAU,aAAa,CAAC,MAAiB,EAAE,GAAgB;IAC/D,MAAM,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,UAAU,CAAC;IAEjE,KAAK,MAAM,IAAI,IAAI,MAAM,EAAE,CAAC;QAC1B,MAAM,CAAC,YAAY,CACjB,IAAI,CAAC,IAAI,EACT;YACE,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,WAAW,EAAE,IAAI,CAAC,WAAW;YAC7B,WAAW,EAAE,IAAI,CAAC,WAAoB;YACtC,WAAW,EAAE,IAAI,CAAC,WAAW;SAC9B;QACD,oEAAoE;QACpE,qEAAqE;QACrE,oDAAoD;QACpD,CAAC,KAAK,EAAE,IAAa,EAAE,EAAE;YACvB,IAAI,CAAC;gBACH,OAAO,MAAM,IAAI,CAAC,OAAO,CAAC,IAAa,EAAE,GAAG,CAAC,CAAC;YAChD,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,WAAW,CAAC,GAAG,CAAC,CAAC;YAC1B,CAAC;QACH,CAAC,CAAU,CACZ,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vocabulary and glossary tools — the two anti-drift devices, as tools.
|
|
3
|
+
*
|
|
4
|
+
* slab serves both of these rather than documenting them, and this server
|
|
5
|
+
* follows that: no tool description here lists brands, teams, attributes, or
|
|
6
|
+
* finishes, and none writes its own definition of a metric. A list copied into
|
|
7
|
+
* this repo would be stale the next time a set is seeded, and a hand-written
|
|
8
|
+
* gloss of `priced_coverage` would drift from the one the portal and CLI show.
|
|
9
|
+
*
|
|
10
|
+
* They are two tools, not one, because they answer different questions and a
|
|
11
|
+
* model picks tools by name: `get_vocab` is "what may I send", and
|
|
12
|
+
* `explain_metrics` is "what does this number mean". Folding them together
|
|
13
|
+
* meant an agent asked to explain a figure never thought to look in "vocab".
|
|
14
|
+
*
|
|
15
|
+
* Both are also exposed as resources (`slab://vocab`, `slab://glossary`) for
|
|
16
|
+
* clients that can pull context without a tool call.
|
|
17
|
+
*/
|
|
18
|
+
import { z } from 'zod';
|
|
19
|
+
export declare const getVocab: import("./types.js").ToolModule<z.ZodObject<{
|
|
20
|
+
fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
21
|
+
}, z.core.$strip>>;
|
|
22
|
+
export declare const explainMetrics: import("./types.js").ToolModule<z.ZodObject<{
|
|
23
|
+
ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
24
|
+
search: z.ZodOptional<z.ZodString>;
|
|
25
|
+
detail: z.ZodOptional<z.ZodBoolean>;
|
|
26
|
+
}, z.core.$strip>>;
|
|
27
|
+
export declare const metaTools: (import("./types.js").ToolModule<z.ZodObject<{
|
|
28
|
+
fields: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
29
|
+
}, z.core.$strip>> | import("./types.js").ToolModule<z.ZodObject<{
|
|
30
|
+
ids: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
31
|
+
search: z.ZodOptional<z.ZodString>;
|
|
32
|
+
detail: z.ZodOptional<z.ZodBoolean>;
|
|
33
|
+
}, z.core.$strip>>)[];
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vocabulary and glossary tools — the two anti-drift devices, as tools.
|
|
3
|
+
*
|
|
4
|
+
* slab serves both of these rather than documenting them, and this server
|
|
5
|
+
* follows that: no tool description here lists brands, teams, attributes, or
|
|
6
|
+
* finishes, and none writes its own definition of a metric. A list copied into
|
|
7
|
+
* this repo would be stale the next time a set is seeded, and a hand-written
|
|
8
|
+
* gloss of `priced_coverage` would drift from the one the portal and CLI show.
|
|
9
|
+
*
|
|
10
|
+
* They are two tools, not one, because they answer different questions and a
|
|
11
|
+
* model picks tools by name: `get_vocab` is "what may I send", and
|
|
12
|
+
* `explain_metrics` is "what does this number mean". Folding them together
|
|
13
|
+
* meant an agent asked to explain a figure never thought to look in "vocab".
|
|
14
|
+
*
|
|
15
|
+
* Both are also exposed as resources (`slab://vocab`, `slab://glossary`) for
|
|
16
|
+
* clients that can pull context without a tool call.
|
|
17
|
+
*/
|
|
18
|
+
import { z } from 'zod';
|
|
19
|
+
import { text } from '../format.js';
|
|
20
|
+
import { READ_ONLY, defineTool } from './types.js';
|
|
21
|
+
export const getVocab = defineTool({
|
|
22
|
+
name: 'get_vocab',
|
|
23
|
+
title: 'Values the API accepts',
|
|
24
|
+
description: 'Every value slab will accept: copy statuses, acquisition types, cost categories, grades, ' +
|
|
25
|
+
'sealed formats, sort grammars, and the LIVE catalog dimensions — every attribute and grading ' +
|
|
26
|
+
'company that exists right now.\n\n' +
|
|
27
|
+
'Call this before guessing a filter value, and call it again rather than trusting a value you ' +
|
|
28
|
+
'saw earlier in a long session. Attributes and grading companies grow whenever new products are ' +
|
|
29
|
+
'ingested, which is exactly why no tool description in this server lists them. A filter value ' +
|
|
30
|
+
'that is nearly right returns zero rows and no error — indistinguishable from "there are none", ' +
|
|
31
|
+
'so a wrong guess reads as a confident, wrong answer.\n\n' +
|
|
32
|
+
'For what a returned NUMBER means rather than what a value may be, use explain_metrics.',
|
|
33
|
+
inputSchema: z.object({
|
|
34
|
+
fields: z
|
|
35
|
+
.array(z.string())
|
|
36
|
+
.optional()
|
|
37
|
+
.describe('Return only these vocabulary lists (e.g. ["copy_statuses","attributes"]). Omit for all of them.'),
|
|
38
|
+
}),
|
|
39
|
+
annotations: READ_ONLY,
|
|
40
|
+
mutates: false,
|
|
41
|
+
async handler(input, ctx) {
|
|
42
|
+
const vocab = await ctx.client.request('GET', '/vocab');
|
|
43
|
+
const wanted = input.fields?.length
|
|
44
|
+
? Object.fromEntries(Object.entries(vocab).filter(([k]) => input.fields.includes(k)))
|
|
45
|
+
: vocab;
|
|
46
|
+
const unknown = (input.fields ?? []).filter((f) => !(f in vocab));
|
|
47
|
+
return text('Accepted values, live from the catalog — do not cache these across sessions:', JSON.stringify(wanted, null, 1), unknown.length ? `\nNo such vocabulary list: ${unknown.join(', ')}. Available: ${Object.keys(vocab).join(', ')}.` : '');
|
|
48
|
+
},
|
|
49
|
+
});
|
|
50
|
+
export const explainMetrics = defineTool({
|
|
51
|
+
name: 'explain_metrics',
|
|
52
|
+
title: 'What a slab number means',
|
|
53
|
+
description: "Plain-language definitions for every number slab reports, in slab's own words — each with a " +
|
|
54
|
+
'label, a one-line summary, and the caveats that make it easy to misread.\n\n' +
|
|
55
|
+
'Use this whenever you report a figure you have not explained before, and whenever a user asks ' +
|
|
56
|
+
'what something means — "what is cost basis", "what does priced coverage tell me", "is my ROI ' +
|
|
57
|
+
'good". Quote or closely follow this wording instead of composing your own. There is exactly ' +
|
|
58
|
+
'one source of truth for it, shared by the API, the portal, and the CLI, so an explanation you ' +
|
|
59
|
+
'take from here matches what the user sees everywhere else in slab; one you invent will not.\n\n' +
|
|
60
|
+
'It matters most for the numbers that mislead quietly: which values rest on a thin sample, why ' +
|
|
61
|
+
'a price series tracks an appraisal rather than the month\'s sales, and why the portfolio series ' +
|
|
62
|
+
'is not a return.\n\n' +
|
|
63
|
+
'Ids are namespaced (`dashboard.most_valuable`, `community.hottest_players`). Pass `ids` for ' +
|
|
64
|
+
'specific ones, `search` to find them by keyword, or neither for everything.',
|
|
65
|
+
inputSchema: z.object({
|
|
66
|
+
ids: z.array(z.string()).optional().describe('Specific metric ids, e.g. ["dashboard.rarest"]. Omit to get all.'),
|
|
67
|
+
search: z.string().optional().describe('Case-insensitive keyword match across id, label, and summary — use when you know the concept but not the id.'),
|
|
68
|
+
detail: z.boolean().optional().describe('Include the longer caveat text, not just the one-line summary. Default true.'),
|
|
69
|
+
}),
|
|
70
|
+
annotations: READ_ONLY,
|
|
71
|
+
mutates: false,
|
|
72
|
+
async handler(input, ctx) {
|
|
73
|
+
const glossary = await ctx.client.request('GET', '/glossary');
|
|
74
|
+
const detail = input.detail ?? true;
|
|
75
|
+
let entries = Object.entries(glossary);
|
|
76
|
+
if (input.ids?.length)
|
|
77
|
+
entries = entries.filter(([id]) => input.ids.includes(id));
|
|
78
|
+
if (input.search) {
|
|
79
|
+
const needle = input.search.toLowerCase();
|
|
80
|
+
entries = entries.filter(([id, info]) => `${id} ${info.label ?? ''} ${info.summary ?? ''}`.toLowerCase().includes(needle));
|
|
81
|
+
}
|
|
82
|
+
if (!entries.length) {
|
|
83
|
+
return text('No metric matched.', `Known ids: ${Object.keys(glossary).join(', ')}`);
|
|
84
|
+
}
|
|
85
|
+
const lines = [];
|
|
86
|
+
for (const [id, info] of entries) {
|
|
87
|
+
lines.push(`${id} — ${info.label ?? id}`);
|
|
88
|
+
if (info.summary)
|
|
89
|
+
lines.push(` ${info.summary}`);
|
|
90
|
+
if (detail && info.detail)
|
|
91
|
+
lines.push(` ${info.detail}`);
|
|
92
|
+
lines.push('');
|
|
93
|
+
}
|
|
94
|
+
return text(...lines);
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
export const metaTools = [getVocab, explainMetrics];
|
|
98
|
+
//# sourceMappingURL=meta.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"meta.js","sourceRoot":"","sources":["../../src/tools/meta.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAEpC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAEnD,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC;IACjC,IAAI,EAAE,WAAW;IACjB,KAAK,EAAE,wBAAwB;IAC/B,WAAW,EACT,2FAA2F;QAC3F,+FAA+F;QAC/F,oCAAoC;QACpC,+FAA+F;QAC/F,iGAAiG;QACjG,+FAA+F;QAC/F,iGAAiG;QACjG,0DAA0D;QAC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AAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,EAAE,EAAE,CACtC,GAAG,EAAE,IAAI,IAAI,CAAC,KAAK,IAAI,EAAE,IAAI,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC,WAAW,EAAE,CAAC,QAAQ,CAAC,MAAM,CAAC,CACjF,CAAC;QACJ,CAAC;QAED,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACpB,OAAO,IAAI,CACT,oBAAoB,EACpB,cAAc,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CACjD,CAAC;QACJ,CAAC;QAED,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,KAAK,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,OAAO,EAAE,CAAC;YACjC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,MAAM,IAAI,CAAC,KAAK,IAAI,EAAE,EAAE,CAAC,CAAC;YAC1C,IAAI,IAAI,CAAC,OAAO;gBAAE,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;YAClD,IAAI,MAAM,IAAI,IAAI,CAAC,MAAM;gBAAE,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;YAC1D,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QACjB,CAAC;QACD,OAAO,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;IACxB,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,QAAQ,EAAE,cAAc,CAAC,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pricing tools.
|
|
3
|
+
*
|
|
4
|
+
* These carry the load-bearing caveat of the whole slab data model, so it is
|
|
5
|
+
* written into the tool description rather than left to the caller to infer:
|
|
6
|
+
* a price snapshot is a trailing-90-day trimmed-median appraisal, so
|
|
7
|
+
* differencing two snapshots measures how the appraisal drifted, not what the
|
|
8
|
+
* market did. An agent that says "this card is up 12% this month" from
|
|
9
|
+
* `price_change_30d` has stated something false, confidently, about someone's
|
|
10
|
+
* money — the description exists to stop exactly that.
|
|
11
|
+
*/
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
export declare const getCardPricing: import("./types.js").ToolModule<z.ZodObject<{
|
|
14
|
+
card_uuid: z.ZodString;
|
|
15
|
+
grade_key: z.ZodOptional<z.ZodString>;
|
|
16
|
+
include_comps: z.ZodOptional<z.ZodBoolean>;
|
|
17
|
+
comps_limit: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
include_history: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
+
history_start: z.ZodOptional<z.ZodString>;
|
|
20
|
+
history_end: z.ZodOptional<z.ZodString>;
|
|
21
|
+
}, z.core.$strip>>;
|
|
22
|
+
export declare const pricingTools: import("./types.js").ToolModule<z.ZodObject<{
|
|
23
|
+
card_uuid: z.ZodString;
|
|
24
|
+
grade_key: z.ZodOptional<z.ZodString>;
|
|
25
|
+
include_comps: z.ZodOptional<z.ZodBoolean>;
|
|
26
|
+
comps_limit: z.ZodOptional<z.ZodNumber>;
|
|
27
|
+
include_history: z.ZodOptional<z.ZodBoolean>;
|
|
28
|
+
history_start: z.ZodOptional<z.ZodString>;
|
|
29
|
+
history_end: z.ZodOptional<z.ZodString>;
|
|
30
|
+
}, z.core.$strip>>[];
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pricing tools.
|
|
3
|
+
*
|
|
4
|
+
* These carry the load-bearing caveat of the whole slab data model, so it is
|
|
5
|
+
* written into the tool description rather than left to the caller to infer:
|
|
6
|
+
* a price snapshot is a trailing-90-day trimmed-median appraisal, so
|
|
7
|
+
* differencing two snapshots measures how the appraisal drifted, not what the
|
|
8
|
+
* market did. An agent that says "this card is up 12% this month" from
|
|
9
|
+
* `price_change_30d` has stated something false, confidently, about someone's
|
|
10
|
+
* money — the description exists to stop exactly that.
|
|
11
|
+
*/
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
import { join, money, text } from '../format.js';
|
|
14
|
+
import { READ_ONLY, defineTool } from './types.js';
|
|
15
|
+
export const getCardPricing = defineTool({
|
|
16
|
+
name: 'get_card_pricing',
|
|
17
|
+
title: 'Pricing for one card',
|
|
18
|
+
description: 'What one card is worth, and the individual sales behind that number. `card_uuid` comes from ' +
|
|
19
|
+
'search_cards.\n\n' +
|
|
20
|
+
'Returns a fair market value per price key — a (finish, grade) pair, so a RAW copy and a PSA 10 ' +
|
|
21
|
+
'of the same card are priced separately — plus, optionally, the recent comparable sales and a ' +
|
|
22
|
+
'daily value series.\n\n' +
|
|
23
|
+
'READ THIS BEFORE QUOTING A PERCENTAGE. A fair market value is a trimmed median of the trailing ' +
|
|
24
|
+
'90 days of sales, recomputed daily. Two of those snapshots a month apart share most of their ' +
|
|
25
|
+
'underlying sales, so `price_change_30d` is how the APPRAISAL drifted — smooth, lagged, roughly ' +
|
|
26
|
+
'a 90-day memory. It is not the market\'s move over 30 days, and reporting it as one is wrong. ' +
|
|
27
|
+
'If the user asks what actually happened in a window, set `include_comps` and count the real ' +
|
|
28
|
+
'sales in that window instead.\n\n' +
|
|
29
|
+
'`sample_size` is how many sales a value rests on. A value drawn from two sales is a guess; say ' +
|
|
30
|
+
'so rather than quoting it flat.\n\n' +
|
|
31
|
+
'Call explain_metrics for the exact meaning of fair market value, appraisal drift, and sample ' +
|
|
32
|
+
"size before explaining any of them to the user — use slab's wording, not your own.",
|
|
33
|
+
inputSchema: z.object({
|
|
34
|
+
card_uuid: z.string().describe('Card UUID, from search_cards.'),
|
|
35
|
+
grade_key: z
|
|
36
|
+
.string()
|
|
37
|
+
.optional()
|
|
38
|
+
.describe('Restrict to one price key, e.g. "RAW" or "PSA10". Omit for every key with data. Call get_vocab for valid keys.'),
|
|
39
|
+
include_comps: z.boolean().optional().describe('Include the individual recent sales. Default true — this is the evidence behind the value.'),
|
|
40
|
+
comps_limit: z.number().int().min(1).max(100).optional().describe('How many recent sales to return. Default 15.'),
|
|
41
|
+
include_history: z.boolean().optional().describe('Include the daily value series. Default false; it is the largest part of the response.'),
|
|
42
|
+
history_start: z.string().optional().describe('ISO date (YYYY-MM-DD) to start the series.'),
|
|
43
|
+
history_end: z.string().optional().describe('ISO date (YYYY-MM-DD) to end the series.'),
|
|
44
|
+
}),
|
|
45
|
+
annotations: READ_ONLY,
|
|
46
|
+
mutates: false,
|
|
47
|
+
async handler(input, ctx) {
|
|
48
|
+
const { card_uuid } = input;
|
|
49
|
+
const includeComps = input.include_comps ?? true;
|
|
50
|
+
const compsLimit = input.comps_limit ?? 15;
|
|
51
|
+
const market = await ctx.client.request('GET', `/cards/${card_uuid}/market`);
|
|
52
|
+
const lines = ['Fair market value by price key (trailing-90-day trimmed median appraisal):'];
|
|
53
|
+
const prices = (market.prices ?? []).filter((p) => !input.grade_key || p.grade_key === input.grade_key);
|
|
54
|
+
if (!prices.length) {
|
|
55
|
+
lines.push(' (no priced sales matched — this card has no comps yet, or none for that grade key)');
|
|
56
|
+
}
|
|
57
|
+
for (const price of prices) {
|
|
58
|
+
lines.push(' ' +
|
|
59
|
+
join(' | ', join(' ', price.finish ?? 'base', price.grade_key), money(price.fair_market_value), price.sample_size != null ? `n=${price.sample_size}` : undefined, price.price_change_30d != null ? `appraisal drift 30d ${(price.price_change_30d * 100).toFixed(1)}%` : undefined, price.last_sold_date ? `last sale ${price.last_sold_date}` : undefined));
|
|
60
|
+
}
|
|
61
|
+
if (includeComps) {
|
|
62
|
+
const comps = await ctx.client.request('GET', `/cards/${card_uuid}/comps`, {
|
|
63
|
+
query: { limit: compsLimit, grade_key: input.grade_key },
|
|
64
|
+
});
|
|
65
|
+
const rows = comps.comps ?? [];
|
|
66
|
+
lines.push('', `Recent sales (${rows.length}) — these are the actual transactions; count these for "what happened in a window":`);
|
|
67
|
+
for (const comp of rows) {
|
|
68
|
+
lines.push(' ' + join(' | ', comp.sold_date, money(comp.price), comp.grade_key ?? 'RAW', comp.title));
|
|
69
|
+
}
|
|
70
|
+
if (!rows.length)
|
|
71
|
+
lines.push(' (none)');
|
|
72
|
+
}
|
|
73
|
+
if (input.include_history) {
|
|
74
|
+
const history = await ctx.client.request('GET', `/cards/${card_uuid}/price-history`, {
|
|
75
|
+
query: {
|
|
76
|
+
grade_key: input.grade_key ?? 'RAW',
|
|
77
|
+
start: input.history_start,
|
|
78
|
+
end: input.history_end,
|
|
79
|
+
interval: 'daily',
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
const points = history.points ?? [];
|
|
83
|
+
lines.push('', `Daily appraisal series (${points.length} points, grade key ${input.grade_key ?? 'RAW'}):`);
|
|
84
|
+
lines.push(...points.map((p) => ` ${p.date} ${money(p.value)}${p.sample_size != null ? ` n=${p.sample_size}` : ''}`));
|
|
85
|
+
}
|
|
86
|
+
return text(...lines);
|
|
87
|
+
},
|
|
88
|
+
});
|
|
89
|
+
export const pricingTools = [getCardPricing];
|
|
90
|
+
//# sourceMappingURL=pricing.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pricing.js","sourceRoot":"","sources":["../../src/tools/pricing.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AA2BnD,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;IACvC,IAAI,EAAE,kBAAkB;IACxB,KAAK,EAAE,sBAAsB;IAC7B,WAAW,EACT,8FAA8F;QAC9F,mBAAmB;QACnB,iGAAiG;QACjG,+FAA+F;QAC/F,yBAAyB;QACzB,iGAAiG;QACjG,+FAA+F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AAC,KAAK,CAAC,GAAG,CAAC,CAAC,WAAW,IAAI,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;QAC3H,CAAC;QAED,OAAO,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;IACxB,CAAC;CACF,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,cAAc,CAAC,CAAC"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tool contract — the seam this whole server is built around.
|
|
3
|
+
*
|
|
4
|
+
* Adding a tool is: write a `defineTool({...})` in a module under `tools/`,
|
|
5
|
+
* and add it to the array in `tools/index.ts`. Nothing else changes. No
|
|
6
|
+
* registration code, no switch statement, no edit to `index.ts`.
|
|
7
|
+
*
|
|
8
|
+
* Two fields are required that most MCP examples leave optional, because
|
|
9
|
+
* making them optional is how a write tool ships looking like a read tool:
|
|
10
|
+
*
|
|
11
|
+
* - `mutates` — the ONLY thing that decides whether a tool is registered
|
|
12
|
+
* when SLAB_MCP_WRITE is off. Not a naming convention, not a
|
|
13
|
+
* hand-maintained list.
|
|
14
|
+
* - `annotations` — the hints an MCP host uses to decide whether to prompt
|
|
15
|
+
* the user before running a tool. A host cannot ask about a
|
|
16
|
+
* hint that was never declared.
|
|
17
|
+
*
|
|
18
|
+
* `tests/registry.test.ts` enforces that these two agree with each other, so
|
|
19
|
+
* a mislabelled tool fails the suite rather than silently shipping.
|
|
20
|
+
*/
|
|
21
|
+
import type { z } from 'zod';
|
|
22
|
+
import type { ToolContext } from '../context.js';
|
|
23
|
+
import type { ToolResult } from '../format.js';
|
|
24
|
+
/**
|
|
25
|
+
* MCP tool annotations. All are advisory hints for the host UI — none of them
|
|
26
|
+
* are enforced by the protocol, so they describe intent, never permission.
|
|
27
|
+
*/
|
|
28
|
+
export interface ToolAnnotations {
|
|
29
|
+
/** The tool does not modify anything. */
|
|
30
|
+
readOnlyHint: boolean;
|
|
31
|
+
/** The tool may perform irreversible updates or deletions. */
|
|
32
|
+
destructiveHint?: boolean;
|
|
33
|
+
/** Calling it twice with the same arguments has the same effect as calling it once. */
|
|
34
|
+
idempotentHint?: boolean;
|
|
35
|
+
/** The tool touches data outside the closed world of this server. */
|
|
36
|
+
openWorldHint?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface ToolModule<S extends z.ZodType = z.ZodType> {
|
|
39
|
+
/** Wire name. snake_case, verb-first, unique across the registry. */
|
|
40
|
+
name: string;
|
|
41
|
+
/** Short human label for host UIs. */
|
|
42
|
+
title: string;
|
|
43
|
+
/**
|
|
44
|
+
* The tool's public reference text — this is what the calling model reads to
|
|
45
|
+
* decide whether to call it. Write *when would I reach for this* and *what
|
|
46
|
+
* do the numbers mean*, not a restatement of the parameter list. Name the
|
|
47
|
+
* tool that produces any UUID this one consumes; a model that cannot see
|
|
48
|
+
* where an argument comes from will invent one.
|
|
49
|
+
*/
|
|
50
|
+
description: string;
|
|
51
|
+
inputSchema: S;
|
|
52
|
+
annotations: ToolAnnotations;
|
|
53
|
+
/** True if the tool writes. Gates registration behind SLAB_MCP_WRITE. */
|
|
54
|
+
mutates: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Declared as a method, not a property, so a concrete tool is assignable to
|
|
57
|
+
* `ToolModule` in the registry array (TS treats method parameters
|
|
58
|
+
* bivariantly). The registry validates arguments against `inputSchema`
|
|
59
|
+
* before this runs.
|
|
60
|
+
*/
|
|
61
|
+
handler(input: z.infer<S>, ctx: ToolContext): Promise<ToolResult>;
|
|
62
|
+
}
|
|
63
|
+
/** Identity helper that preserves the inferred input type for the handler. */
|
|
64
|
+
export declare function defineTool<S extends z.ZodType>(module: ToolModule<S>): ToolModule<S>;
|
|
65
|
+
/** Annotation presets, so the common cases are one word and hard to get wrong. */
|
|
66
|
+
export declare const READ_ONLY: ToolAnnotations;
|
|
67
|
+
export declare const CREATES: ToolAnnotations;
|
|
68
|
+
export declare const UPDATES: ToolAnnotations;
|
|
69
|
+
export declare const DELETES: ToolAnnotations;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The tool contract — the seam this whole server is built around.
|
|
3
|
+
*
|
|
4
|
+
* Adding a tool is: write a `defineTool({...})` in a module under `tools/`,
|
|
5
|
+
* and add it to the array in `tools/index.ts`. Nothing else changes. No
|
|
6
|
+
* registration code, no switch statement, no edit to `index.ts`.
|
|
7
|
+
*
|
|
8
|
+
* Two fields are required that most MCP examples leave optional, because
|
|
9
|
+
* making them optional is how a write tool ships looking like a read tool:
|
|
10
|
+
*
|
|
11
|
+
* - `mutates` — the ONLY thing that decides whether a tool is registered
|
|
12
|
+
* when SLAB_MCP_WRITE is off. Not a naming convention, not a
|
|
13
|
+
* hand-maintained list.
|
|
14
|
+
* - `annotations` — the hints an MCP host uses to decide whether to prompt
|
|
15
|
+
* the user before running a tool. A host cannot ask about a
|
|
16
|
+
* hint that was never declared.
|
|
17
|
+
*
|
|
18
|
+
* `tests/registry.test.ts` enforces that these two agree with each other, so
|
|
19
|
+
* a mislabelled tool fails the suite rather than silently shipping.
|
|
20
|
+
*/
|
|
21
|
+
/** Identity helper that preserves the inferred input type for the handler. */
|
|
22
|
+
export function defineTool(module) {
|
|
23
|
+
return module;
|
|
24
|
+
}
|
|
25
|
+
/** Annotation presets, so the common cases are one word and hard to get wrong. */
|
|
26
|
+
export const READ_ONLY = {
|
|
27
|
+
readOnlyHint: true,
|
|
28
|
+
destructiveHint: false,
|
|
29
|
+
idempotentHint: true,
|
|
30
|
+
openWorldHint: true,
|
|
31
|
+
};
|
|
32
|
+
export const CREATES = {
|
|
33
|
+
readOnlyHint: false,
|
|
34
|
+
destructiveHint: false,
|
|
35
|
+
idempotentHint: false,
|
|
36
|
+
openWorldHint: true,
|
|
37
|
+
};
|
|
38
|
+
export const UPDATES = {
|
|
39
|
+
readOnlyHint: false,
|
|
40
|
+
destructiveHint: false,
|
|
41
|
+
idempotentHint: true,
|
|
42
|
+
openWorldHint: true,
|
|
43
|
+
};
|
|
44
|
+
export const DELETES = {
|
|
45
|
+
readOnlyHint: false,
|
|
46
|
+
destructiveHint: true,
|
|
47
|
+
idempotentHint: true,
|
|
48
|
+
openWorldHint: true,
|
|
49
|
+
};
|
|
50
|
+
//# sourceMappingURL=types.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/tools/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AA+CH,8EAA8E;AAC9E,MAAM,UAAU,UAAU,CAAsB,MAAqB;IACnE,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,kFAAkF;AAClF,MAAM,CAAC,MAAM,SAAS,GAAoB;IACxC,YAAY,EAAE,IAAI;IAClB,eAAe,EAAE,KAAK;IACtB,cAAc,EAAE,IAAI;IACpB,aAAa,EAAE,IAAI;CACpB,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAoB;IACtC,YAAY,EAAE,KAAK;IACnB,eAAe,EAAE,KAAK;IACtB,cAAc,EAAE,KAAK;IACrB,aAAa,EAAE,IAAI;CACpB,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAoB;IACtC,YAAY,EAAE,KAAK;IACnB,eAAe,EAAE,KAAK;IACtB,cAAc,EAAE,IAAI;IACpB,aAAa,EAAE,IAAI;CACpB,CAAC;AAEF,MAAM,CAAC,MAAM,OAAO,GAAoB;IACtC,YAAY,EAAE,KAAK;IACnB,eAAe,EAAE,IAAI;IACrB,cAAc,EAAE,IAAI;IACpB,aAAa,EAAE,IAAI;CACpB,CAAC"}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Write tools — registered only when SLAB_MCP_WRITE=1.
|
|
3
|
+
*
|
|
4
|
+
* Everything in this file has `mutates: true`, which is what the registry
|
|
5
|
+
* checks; `tests/registry.test.ts` fails the build if a tool in here forgets
|
|
6
|
+
* it, or claims `readOnlyHint: true`.
|
|
7
|
+
*
|
|
8
|
+
* These write to a real person's records, so the descriptions say what a wrong
|
|
9
|
+
* call actually costs — a duplicated copy quietly doubles a reported
|
|
10
|
+
* collection value, and a break's total cost is divided across every card
|
|
11
|
+
* pulled from it, so the wrong figure re-prices dozens of cards at once.
|
|
12
|
+
*/
|
|
13
|
+
import { z } from 'zod';
|
|
14
|
+
export declare const addCopy: import("./types.js").ToolModule<z.ZodObject<{
|
|
15
|
+
collector_uuid: z.ZodOptional<z.ZodString>;
|
|
16
|
+
card_uuid: z.ZodString;
|
|
17
|
+
quantity: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
serial_number: z.ZodOptional<z.ZodNumber>;
|
|
19
|
+
grading_company: z.ZodOptional<z.ZodString>;
|
|
20
|
+
grade: z.ZodOptional<z.ZodString>;
|
|
21
|
+
cert_number: z.ZodOptional<z.ZodString>;
|
|
22
|
+
self_grade: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
acquisition_type: z.ZodOptional<z.ZodEnum<{
|
|
24
|
+
purchase: "purchase";
|
|
25
|
+
pack_pull: "pack_pull";
|
|
26
|
+
trade: "trade";
|
|
27
|
+
gift: "gift";
|
|
28
|
+
other: "other";
|
|
29
|
+
}>>;
|
|
30
|
+
acquisition_cost: z.ZodOptional<z.ZodNumber>;
|
|
31
|
+
acquired_date: z.ZodOptional<z.ZodString>;
|
|
32
|
+
acquired_source: z.ZodOptional<z.ZodString>;
|
|
33
|
+
break_uuid: z.ZodOptional<z.ZodString>;
|
|
34
|
+
lot_uuid: z.ZodOptional<z.ZodString>;
|
|
35
|
+
storage_location: z.ZodOptional<z.ZodString>;
|
|
36
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
37
|
+
}, z.core.$strip>>;
|
|
38
|
+
export declare const updateCopy: import("./types.js").ToolModule<z.ZodObject<{
|
|
39
|
+
collector_uuid: z.ZodOptional<z.ZodString>;
|
|
40
|
+
copy_uuid: z.ZodString;
|
|
41
|
+
quantity: z.ZodOptional<z.ZodNumber>;
|
|
42
|
+
serial_number: z.ZodOptional<z.ZodNumber>;
|
|
43
|
+
grading_company: z.ZodOptional<z.ZodString>;
|
|
44
|
+
grade: z.ZodOptional<z.ZodString>;
|
|
45
|
+
cert_number: z.ZodOptional<z.ZodString>;
|
|
46
|
+
self_grade: z.ZodOptional<z.ZodNumber>;
|
|
47
|
+
acquisition_type: z.ZodOptional<z.ZodEnum<{
|
|
48
|
+
purchase: "purchase";
|
|
49
|
+
pack_pull: "pack_pull";
|
|
50
|
+
trade: "trade";
|
|
51
|
+
gift: "gift";
|
|
52
|
+
other: "other";
|
|
53
|
+
}>>;
|
|
54
|
+
acquisition_cost: z.ZodOptional<z.ZodNumber>;
|
|
55
|
+
acquired_date: z.ZodOptional<z.ZodString>;
|
|
56
|
+
acquired_source: z.ZodOptional<z.ZodString>;
|
|
57
|
+
status: z.ZodOptional<z.ZodEnum<{
|
|
58
|
+
in_collection: "in_collection";
|
|
59
|
+
for_trade: "for_trade";
|
|
60
|
+
for_sale: "for_sale";
|
|
61
|
+
sold: "sold";
|
|
62
|
+
}>>;
|
|
63
|
+
sale_price: z.ZodOptional<z.ZodNumber>;
|
|
64
|
+
sold_date: z.ZodOptional<z.ZodString>;
|
|
65
|
+
storage_location: z.ZodOptional<z.ZodString>;
|
|
66
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
67
|
+
}, z.core.$strip>>;
|
|
68
|
+
export declare const removeCopy: import("./types.js").ToolModule<z.ZodObject<{
|
|
69
|
+
collector_uuid: z.ZodOptional<z.ZodString>;
|
|
70
|
+
copy_uuid: z.ZodString;
|
|
71
|
+
}, z.core.$strip>>;
|
|
72
|
+
export declare const logBreak: import("./types.js").ToolModule<z.ZodObject<{
|
|
73
|
+
collector_uuid: z.ZodOptional<z.ZodString>;
|
|
74
|
+
set_uuid: z.ZodString;
|
|
75
|
+
break_type: z.ZodString;
|
|
76
|
+
total_cost: z.ZodNumber;
|
|
77
|
+
break_date: z.ZodString;
|
|
78
|
+
source: z.ZodOptional<z.ZodString>;
|
|
79
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
80
|
+
}, z.core.$strip>>;
|
|
81
|
+
export declare const logLot: import("./types.js").ToolModule<z.ZodObject<{
|
|
82
|
+
collector_uuid: z.ZodOptional<z.ZodString>;
|
|
83
|
+
total_cost: z.ZodNumber;
|
|
84
|
+
lot_date: z.ZodString;
|
|
85
|
+
source: z.ZodOptional<z.ZodString>;
|
|
86
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
87
|
+
}, z.core.$strip>>;
|
|
88
|
+
export declare const writeTools: (import("./types.js").ToolModule<z.ZodObject<{
|
|
89
|
+
collector_uuid: z.ZodOptional<z.ZodString>;
|
|
90
|
+
card_uuid: z.ZodString;
|
|
91
|
+
quantity: z.ZodOptional<z.ZodNumber>;
|
|
92
|
+
serial_number: z.ZodOptional<z.ZodNumber>;
|
|
93
|
+
grading_company: z.ZodOptional<z.ZodString>;
|
|
94
|
+
grade: z.ZodOptional<z.ZodString>;
|
|
95
|
+
cert_number: z.ZodOptional<z.ZodString>;
|
|
96
|
+
self_grade: z.ZodOptional<z.ZodNumber>;
|
|
97
|
+
acquisition_type: z.ZodOptional<z.ZodEnum<{
|
|
98
|
+
purchase: "purchase";
|
|
99
|
+
pack_pull: "pack_pull";
|
|
100
|
+
trade: "trade";
|
|
101
|
+
gift: "gift";
|
|
102
|
+
other: "other";
|
|
103
|
+
}>>;
|
|
104
|
+
acquisition_cost: z.ZodOptional<z.ZodNumber>;
|
|
105
|
+
acquired_date: z.ZodOptional<z.ZodString>;
|
|
106
|
+
acquired_source: z.ZodOptional<z.ZodString>;
|
|
107
|
+
break_uuid: z.ZodOptional<z.ZodString>;
|
|
108
|
+
lot_uuid: z.ZodOptional<z.ZodString>;
|
|
109
|
+
storage_location: z.ZodOptional<z.ZodString>;
|
|
110
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
111
|
+
}, z.core.$strip>> | import("./types.js").ToolModule<z.ZodObject<{
|
|
112
|
+
collector_uuid: z.ZodOptional<z.ZodString>;
|
|
113
|
+
copy_uuid: z.ZodString;
|
|
114
|
+
}, z.core.$strip>> | import("./types.js").ToolModule<z.ZodObject<{
|
|
115
|
+
collector_uuid: z.ZodOptional<z.ZodString>;
|
|
116
|
+
set_uuid: z.ZodString;
|
|
117
|
+
break_type: z.ZodString;
|
|
118
|
+
total_cost: z.ZodNumber;
|
|
119
|
+
break_date: z.ZodString;
|
|
120
|
+
source: z.ZodOptional<z.ZodString>;
|
|
121
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
122
|
+
}, z.core.$strip>> | import("./types.js").ToolModule<z.ZodObject<{
|
|
123
|
+
collector_uuid: z.ZodOptional<z.ZodString>;
|
|
124
|
+
total_cost: z.ZodNumber;
|
|
125
|
+
lot_date: z.ZodString;
|
|
126
|
+
source: z.ZodOptional<z.ZodString>;
|
|
127
|
+
notes: z.ZodOptional<z.ZodString>;
|
|
128
|
+
}, z.core.$strip>>)[];
|