@ingenx-io/valets-schema-mcp-server 0.2.3 → 0.2.4
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 +26 -0
- package/data/static/cookbook.json +150 -0
- package/index.js +32 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -45,6 +45,32 @@ claude mcp add valets-schema -- npx -y @ingenx-io/valets-schema-mcp-server
|
|
|
45
45
|
| `list_decisions` | All data model decisions (D00–D37+) with status and summary |
|
|
46
46
|
| `get_decision` | Full details for a specific decision by ID (e.g. `D12`) |
|
|
47
47
|
| `get_openapi` | OpenAPI 3.1 spec — full or filtered to a single component (e.g. `Order`, `OrderCreate`) |
|
|
48
|
+
| `get_guidance` | Use-case recipes: tool call sequences, field constraint cheatsheets, and workaround notes. Call with no args for the index, or pass a `slug` for the full recipe. |
|
|
49
|
+
|
|
50
|
+
## Cookbook
|
|
51
|
+
|
|
52
|
+
`get_guidance` exposes a set of use-case recipes — each one describes the right sequence of MCP tool calls for a specific task.
|
|
53
|
+
|
|
54
|
+
### Available recipes
|
|
55
|
+
|
|
56
|
+
| Slug | When to use |
|
|
57
|
+
|------|-------------|
|
|
58
|
+
| `write-model-code` | You need to read or write a Firestore document and want to know which fields are server-set, immutable, or deprecated. |
|
|
59
|
+
| `field-history` | You found a field and want to understand why it exists, what decision drove it, and whether it's been migrated. |
|
|
60
|
+
| `whatsapp-conversation-display` | You need to render a per-order WhatsApp message thread. Uses `NotificationRecord` as a workaround (outbound only). |
|
|
61
|
+
|
|
62
|
+
### Example usage
|
|
63
|
+
|
|
64
|
+
```
|
|
65
|
+
# Get the index
|
|
66
|
+
get_guidance()
|
|
67
|
+
|
|
68
|
+
# Get a specific recipe
|
|
69
|
+
get_guidance(slug="write-model-code")
|
|
70
|
+
get_guidance(slug="whatsapp-conversation-display")
|
|
71
|
+
```
|
|
72
|
+
|
|
73
|
+
Each recipe returns JSON with ordered `steps` (tool + args + note), tips, and any relevant caveats or cheatsheets.
|
|
48
74
|
|
|
49
75
|
## Resources
|
|
50
76
|
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": "1",
|
|
3
|
+
"recipes": [
|
|
4
|
+
{
|
|
5
|
+
"slug": "write-model-code",
|
|
6
|
+
"title": "Writing code that touches a model",
|
|
7
|
+
"summary": "How to look up a model's schema, identify field constraints, and avoid writing to server-set or immutable fields.",
|
|
8
|
+
"steps": [
|
|
9
|
+
{
|
|
10
|
+
"step": 1,
|
|
11
|
+
"tool": "schema_overview",
|
|
12
|
+
"args": {},
|
|
13
|
+
"note": "Start here to see all available models and enums. Identify the model(s) your code will read or write."
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"step": 2,
|
|
17
|
+
"tool": "get_schema",
|
|
18
|
+
"args": { "name": "<model-name>" },
|
|
19
|
+
"note": "Fetch the full JSON Schema for the model. Inspect each field for constraint extensions: readOnly, x-immutable, deprecated, x-note, x-when."
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"step": 3,
|
|
23
|
+
"tool": "get_openapi",
|
|
24
|
+
"args": { "component": "<ModelCreate>" },
|
|
25
|
+
"note": "Use the Create variant (PascalCase + 'Create', e.g. 'OrderCreate') to determine the correct write shape. readOnly and deprecated fields are excluded from required[] here."
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"step": 4,
|
|
29
|
+
"tool": "get_openapi",
|
|
30
|
+
"args": { "component": "<ModelUpdate>" },
|
|
31
|
+
"note": "For PATCH operations use the Update variant. All fields become optional and readOnly / x-immutable fields are excluded entirely."
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
"step": 5,
|
|
35
|
+
"tool": "get_doc",
|
|
36
|
+
"args": { "slug": "models/<model-name>" },
|
|
37
|
+
"note": "Read the human-readable doc page for callout blocks: server-set warnings, immutable notices, deprecation alerts, and implementation tips."
|
|
38
|
+
}
|
|
39
|
+
],
|
|
40
|
+
"field_constraint_cheatsheet": {
|
|
41
|
+
"readOnly: true": "Set by Firestore trigger or Admin SDK only — never write from client or backend application code.",
|
|
42
|
+
"x-immutable: true": "Set exactly once at document creation. Any subsequent write to this field is a bug.",
|
|
43
|
+
"deprecated: true": "Do not write in new code. Check x-replaced-by for the replacement field.",
|
|
44
|
+
"x-internal: true": "Backend-only collection — consumers must not depend on this model's shape."
|
|
45
|
+
},
|
|
46
|
+
"tips": [
|
|
47
|
+
"Field descriptions often contain '(GH#N)' or '(D-id)' references — use get_decision to trace rationale.",
|
|
48
|
+
"If a field is absent from ModelCreate, it is either readOnly (server-sets it) or deprecated.",
|
|
49
|
+
"Run get_schema on related enums (e.g. 'payment-status') to understand the allowed values for enum fields."
|
|
50
|
+
]
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"slug": "field-history",
|
|
54
|
+
"title": "Understanding a field's history or rationale",
|
|
55
|
+
"summary": "How to trace why a field exists, what decision or issue drove it, and whether it has been migrated or superseded.",
|
|
56
|
+
"steps": [
|
|
57
|
+
{
|
|
58
|
+
"step": 1,
|
|
59
|
+
"tool": "search_docs",
|
|
60
|
+
"args": { "query": "<fieldName>" },
|
|
61
|
+
"note": "Find every doc page that mentions the field. This surfaces the model page, any decision pages, and migration docs."
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
"step": 2,
|
|
65
|
+
"tool": "get_schema",
|
|
66
|
+
"args": { "name": "<model-name>" },
|
|
67
|
+
"note": "Read the field's 'description' value directly. It typically includes a GH# issue reference or a D-id decision reference."
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"step": 3,
|
|
71
|
+
"tool": "list_decisions",
|
|
72
|
+
"args": {},
|
|
73
|
+
"note": "Scan all decisions for ones related to the model or field. Look at 'status': accepted decisions are live; superseded ones have been replaced."
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
"step": 4,
|
|
77
|
+
"tool": "get_decision",
|
|
78
|
+
"args": { "id": "<D-id>" },
|
|
79
|
+
"note": "Get full context: rationale, migration path, affected models, and implementation status."
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"step": 5,
|
|
83
|
+
"tool": "get_doc",
|
|
84
|
+
"args": { "slug": "decisions/migrations" },
|
|
85
|
+
"note": "Check the migrations page for a changelog of field-level changes and the order in which they must be applied."
|
|
86
|
+
}
|
|
87
|
+
],
|
|
88
|
+
"tips": [
|
|
89
|
+
"If a field has 'x-replaced-by', check that replacement field's schema and the decision that drove the change.",
|
|
90
|
+
"A decision with status 'pending' means the change is not yet live — do not depend on the new shape yet.",
|
|
91
|
+
"search_docs with the GH# (e.g. 'GH#48') will surface all docs that reference that issue."
|
|
92
|
+
]
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"slug": "whatsapp-conversation-display",
|
|
96
|
+
"title": "Displaying WhatsApp conversation history for an order",
|
|
97
|
+
"summary": "Current workaround for rendering a per-order WhatsApp thread using NotificationRecord documents. There is no dedicated WhatsApp conversation model yet; outbound messages are reconstructed from the notification audit log.",
|
|
98
|
+
"workaround_notice": "This is a temporary workaround (GH#48). NotificationRecord captures outbound messages only. Inbound customer replies are not stored in Firestore. A proper WhatsApp conversation model is a future concern.",
|
|
99
|
+
"steps": [
|
|
100
|
+
{
|
|
101
|
+
"step": 1,
|
|
102
|
+
"tool": "get_schema",
|
|
103
|
+
"args": { "name": "notification-record" },
|
|
104
|
+
"note": "Understand the full NotificationRecord shape. Note: every field is readOnly — this is a backend-written audit log, consumers read only."
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"step": 2,
|
|
108
|
+
"tool": "get_doc",
|
|
109
|
+
"args": { "slug": "collections/firestore-paths" },
|
|
110
|
+
"note": "Review the two notification collection paths: company-wide (always written) and order-scoped (dual-write when relatedEntity.type === 'order')."
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"step": 3,
|
|
114
|
+
"action": "query",
|
|
115
|
+
"collection": "companies/{companyId}/orders/{orderId}/notifications",
|
|
116
|
+
"filter": "type == 'whatsapp'",
|
|
117
|
+
"sort": "sentAt ASC",
|
|
118
|
+
"note": "Use the order-scoped subcollection for O(1) per-order lookup. Filter to type='whatsapp' to exclude email/sms/push records."
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
"step": 4,
|
|
122
|
+
"action": "render",
|
|
123
|
+
"fields": {
|
|
124
|
+
"message_content": "templateParams — filled-in template variable values at send time; reconstruct the message text without calling the Meta API.",
|
|
125
|
+
"delivery_status": "status — 'sent' | 'failed' | 'pending'",
|
|
126
|
+
"failure_reason": "error — present only when status === 'failed'",
|
|
127
|
+
"timestamp": "sentAt — Firestore Timestamp; convert to local time for display",
|
|
128
|
+
"meta_message_id": "wamid — WhatsApp message ID from Meta; use for deduplication if querying both collection paths"
|
|
129
|
+
},
|
|
130
|
+
"note": "All display fields are reconstructable from the NotificationRecord alone — no Meta API call needed."
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"step": 5,
|
|
134
|
+
"action": "deduplicate",
|
|
135
|
+
"note": "If you query both companies/{cid}/notifications (filtered by relatedEntity.id === orderId) AND the order-scoped subcollection, deduplicate by 'id' — both paths write the same document ID."
|
|
136
|
+
}
|
|
137
|
+
],
|
|
138
|
+
"related_models": {
|
|
139
|
+
"notification-record": "GH#48 — the model used in this workaround",
|
|
140
|
+
"whatsapp-outbound-message": "GH#43 — dashboard-initiated WhatsApp sends. Separate from backend-automated NotificationRecords but both appear in the conversation thread. Query this collection too for a complete view."
|
|
141
|
+
},
|
|
142
|
+
"tips": [
|
|
143
|
+
"notification-record covers ALL channels (email, whatsapp, sms, push). Always filter by type='whatsapp'.",
|
|
144
|
+
"metadata field may contain 'templateName', 'senderPhoneId', 'orderNumber' — useful for display headers.",
|
|
145
|
+
"The order-scoped subcollection only exists if at least one notification with relatedEntity.type='order' was sent. Check for its absence gracefully.",
|
|
146
|
+
"For a company-wide WhatsApp audit (not order-scoped), query companies/{cid}/notifications filtered by type='whatsapp'."
|
|
147
|
+
]
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
}
|
package/index.js
CHANGED
|
@@ -19,6 +19,7 @@
|
|
|
19
19
|
* - list_decisions → all data model decisions with status
|
|
20
20
|
* - get_decision → single decision detail
|
|
21
21
|
* - get_openapi → OpenAPI 3.1 spec (full or single component)
|
|
22
|
+
* - get_guidance → use-case recipes (call sequences, field cheatsheets, workaround notes)
|
|
22
23
|
*
|
|
23
24
|
* Resources:
|
|
24
25
|
* - valets://schemas.json → full schema bundle
|
|
@@ -103,6 +104,11 @@ async function loadOpenapi() {
|
|
|
103
104
|
return fetchOrRead("/openapi.yaml", join(BUNDLED_STATIC, "openapi.yaml"));
|
|
104
105
|
}
|
|
105
106
|
|
|
107
|
+
async function loadCookbook() {
|
|
108
|
+
const raw = await fetchOrRead("/cookbook.json", join(BUNDLED_STATIC, "cookbook.json"));
|
|
109
|
+
return JSON.parse(raw);
|
|
110
|
+
}
|
|
111
|
+
|
|
106
112
|
// ---------------------------------------------------------------------------
|
|
107
113
|
// Doc page loading (Markdown)
|
|
108
114
|
// ---------------------------------------------------------------------------
|
|
@@ -319,6 +325,32 @@ server.tool(
|
|
|
319
325
|
}
|
|
320
326
|
);
|
|
321
327
|
|
|
328
|
+
server.tool(
|
|
329
|
+
"get_guidance",
|
|
330
|
+
"Get use-case recipes showing which MCP tools to call and in what order. Call with no arguments for an index of all recipes, or pass a slug to get the full recipe detail.",
|
|
331
|
+
{ slug: z.string().optional().describe("Recipe slug (e.g. 'write-model-code', 'field-history', 'whatsapp-conversation-display'). Omit to list all recipes.") },
|
|
332
|
+
async ({ slug } = {}) => {
|
|
333
|
+
const cookbook = await loadCookbook();
|
|
334
|
+
if (!slug) {
|
|
335
|
+
const index = cookbook.recipes.map((r) => `- **${r.slug}**: ${r.summary}`).join("\n");
|
|
336
|
+
return {
|
|
337
|
+
content: [{ type: "text", text: `Available recipes (${cookbook.recipes.length}):\n\n${index}\n\nCall get_guidance with a slug to get the full recipe.` }],
|
|
338
|
+
};
|
|
339
|
+
}
|
|
340
|
+
const recipe = cookbook.recipes.find((r) => r.slug === slug);
|
|
341
|
+
if (!recipe) {
|
|
342
|
+
const available = cookbook.recipes.map((r) => r.slug);
|
|
343
|
+
return {
|
|
344
|
+
content: [{ type: "text", text: `Recipe "${slug}" not found.\n\nAvailable slugs:\n${available.map((s) => ` - ${s}`).join("\n")}` }],
|
|
345
|
+
isError: true,
|
|
346
|
+
};
|
|
347
|
+
}
|
|
348
|
+
return {
|
|
349
|
+
content: [{ type: "text", text: JSON.stringify(recipe, null, 2) }],
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
);
|
|
353
|
+
|
|
322
354
|
// ---------------------------------------------------------------------------
|
|
323
355
|
// Resources
|
|
324
356
|
// ---------------------------------------------------------------------------
|