@htmlbricks/mcp 0.66.11 → 0.66.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@htmlbricks/mcp",
3
- "version": "0.66.11",
3
+ "version": "0.66.13",
4
4
  "private": false,
5
5
  "description": "MCP server with HTML Bricks (hb-*) web component catalog resources and tools for agentic IDEs.",
6
6
  "type": "module",
package/server.js CHANGED
@@ -18,7 +18,7 @@ let referenceCache = null;
18
18
 
19
19
  const DEVELOPMENT_GUIDE = `# HTML Bricks — agent development guide
20
20
 
21
- Use this together with the resource **${RESOURCE_REFERENCE_URI}** (full catalog) and **${RESOURCE_LIST_URI}** (manifest index).
21
+ Use this together with the resource **${RESOURCE_REFERENCE_URI}** (full catalog) and **${RESOURCE_LIST_URI}** (\`list.json\`: one manifest per component).
22
22
 
23
23
  ## Conventions
24
24
 
@@ -32,11 +32,32 @@ Use this together with the resource **${RESOURCE_REFERENCE_URI}** (full catalog)
32
32
  - **Per-component** scripts from jsDelivr: \`https://cdn.jsdelivr.net/npm/@htmlbricks/hb-<name>@<version>/main.iife.js\` (see each package for optional \`integrity\` from npm).
33
33
  - **Full catalog** IIFE: **@htmlbricks/hb-bundle** provides \`main.iife.js\`, \`list.json\`, \`bundle.json\`, and \`agents/docs/AGENT_WEBCOMPONENTS_REFERENCE.md\` (same content as the MCP resource above when versions match).
34
34
 
35
+ ## Custom events — read \`list.json\` (\`definitions.events\`)
36
+
37
+ 1. Parse **${RESOURCE_LIST_URI}** (or \`list.json\` from hb-bundle). Use \`packages[]\`.
38
+ 2. Find the object whose \`name\` matches the tag (e.g. \`"hb-footer"\`).
39
+ 3. Open **\`definitions.events\`**: a **JSON Schema** (draft-07) for the component’s **\`Events\`** TypeScript type.
40
+ 4. Navigate to **\`definitions.Events\`** inside that object (path is usually \`definitions.events.definitions.Events\`).
41
+ 5. Under **\`properties\`**, **each key is a \`CustomEvent\` type string** — the same name you pass to \`element.addEventListener("<key>", …)\` and that appears as \`event.type\`.
42
+ 6. The **schema value** for that key describes **\`event.detail\`**: typically \`type: "object"\` with \`properties\`, \`required\`, and \`$ref\` to nested definitions. Resolve \`$ref\` within the same \`definitions.events\` document.
43
+
44
+ Prose event lists in the merged Markdown reference are aligned with these schemas; use **list.json** when you need exact **detail** field types and nesting.
45
+
46
+ ## Component props — read \`list.json\` (\`definitions.component\`)
47
+
48
+ 1. Same \`packages[]\` entry as above.
49
+ 2. Open **\`definitions.component\`**: JSON Schema for the **\`Component\`** TypeScript interface.
50
+ 3. Open **\`definitions.Component\`** (usually \`definitions.component.definitions.Component\`).
51
+ 4. **\`properties\`** lists each prop **as in TypeScript** (often camelCase). Types use JSON Schema (\`type\`, \`enum\`, \`items\`, booleans, etc.). Shared shapes (\`ICompany\`, …) appear under the same document’s **\`definitions\`** map; follow **\`$ref\`**.
52
+
53
+ For **HTML**, attribute names and JSON-string props are documented per component in **${RESOURCE_REFERENCE_URI}** (snake_case on the host). Use **\`definitions.component\`** for the **logical type** of each prop and nested JSON; use the **README section** for the **exact attribute names** and examples.
54
+
35
55
  ## Workflow for agents
36
56
 
37
57
  1. Read **${RESOURCE_GUIDE_URI}** (this file) and **${RESOURCE_REFERENCE_URI}** before proposing markup or props.
38
- 2. Use the **search_catalog** tool for keyword lookup when the reference is too large to scan manually.
39
- 3. Prefer attributes and events documented in the reference; do not invent props.
58
+ 2. For **events** and **prop typings**, use **${RESOURCE_LIST_URI}** (\`definitions.events\` / \`definitions.component\`) or the **get_component_schemas** tool for one component.
59
+ 3. Use the **search_catalog** tool for keyword lookup when the Markdown reference is too large to scan manually.
60
+ 4. Do not invent props or events; stick to schemas + README.
40
61
 
41
62
  Version of this MCP package tracks the published **@htmlbricks/hb-bundle** release it was built with.
42
63
  `;
@@ -109,6 +130,26 @@ function searchInText(text, query, maxResults) {
109
130
  return matches;
110
131
  }
111
132
 
133
+ /**
134
+ * Match list.json package by `hb-*` name, folder slug, or loose id (e.g. footer, hb-footer).
135
+ */
136
+ function findPackageEntry(packages, componentId) {
137
+ const raw = componentId.trim();
138
+ if (!raw) return undefined;
139
+ const slug = raw.replace(/^hb-/i, "").replace(/_/g, "-");
140
+ return packages.find((p) => {
141
+ const n = p && typeof p.name === "string" ? p.name : "";
142
+ if (!n) return false;
143
+ const pSlug = n.replace(/^hb-/, "");
144
+ return (
145
+ n === raw ||
146
+ n === `hb-${slug}` ||
147
+ pSlug === slug ||
148
+ pSlug.replace(/-/g, "_") === raw.replace(/^hb-/i, "")
149
+ );
150
+ });
151
+ }
152
+
112
153
  export async function startMcp() {
113
154
  const version = await readPackageVersion();
114
155
  const server = new McpServer(
@@ -149,7 +190,7 @@ export async function startMcp() {
149
190
  {
150
191
  title: "HTML Bricks — package list",
151
192
  description:
152
- "list.json from hb-bundle: full component manifest fields per package (same as manifest.json), excluding iifeIntegrity.",
193
+ "list.json: { version, packages[] }. Each package includes definitions.events and definitions.component (JSON Schema). Event names = keys under definitions.events.definitions.Events.properties; each value schemas event.detail. Prop types = definitions.component.definitions.Component.properties (+ $ref). Excludes iifeIntegrity.",
153
194
  mimeType: "application/json",
154
195
  },
155
196
  async () => {
@@ -212,6 +253,54 @@ export async function startMcp() {
212
253
  }
213
254
  );
214
255
 
256
+ server.registerTool(
257
+ "get_component_schemas",
258
+ {
259
+ title: "JSON Schemas for one component (from list.json)",
260
+ description:
261
+ "Returns definitions.events and definitions.component for one package: JSON Schema for CustomEvent detail (event names = keys under definitions.Events.properties) and for Component props. Pass hb-* name or folder slug (e.g. hb-footer or footer).",
262
+ inputSchema: {
263
+ component_id: z
264
+ .string()
265
+ .min(1)
266
+ .describe("Component: hb-footer, footer, or hb_footer-style folder slug"),
267
+ },
268
+ },
269
+ async ({ component_id }) => {
270
+ const raw = await getPackageListJson();
271
+ const data = JSON.parse(raw);
272
+ const packages = Array.isArray(data.packages) ? data.packages : [];
273
+ const found = findPackageEntry(packages, component_id);
274
+ if (!found) {
275
+ return {
276
+ content: [
277
+ {
278
+ type: "text",
279
+ text: `No package matching ${JSON.stringify(component_id)} in list.json (try hb-<folder> or folder name).`,
280
+ },
281
+ ],
282
+ };
283
+ }
284
+ const defs = found.definitions && typeof found.definitions === "object" ? found.definitions : {};
285
+ const slice = {
286
+ name: found.name,
287
+ list_json_guide: {
288
+ events:
289
+ "Open definitions.events → definitions.Events.properties: each key is CustomEvent.type; value schemas event.detail.",
290
+ props:
291
+ "Open definitions.component → definitions.Component.properties; follow $ref in the same document for nested objects.",
292
+ },
293
+ definitions: {
294
+ events: defs.events ?? null,
295
+ component: defs.component ?? null,
296
+ },
297
+ };
298
+ return {
299
+ content: [{ type: "text", text: JSON.stringify(slice, null, 2) }],
300
+ };
301
+ }
302
+ );
303
+
215
304
  server.registerTool(
216
305
  "get_bundle_cdn_urls",
217
306
  {
@@ -258,7 +347,7 @@ First, read MCP resources:
258
347
  - ${RESOURCE_GUIDE_URI}
259
348
  - ${RESOURCE_REFERENCE_URI}
260
349
 
261
- Rules: use **snake_case** attributes with **string** values; follow Bootstrap 5 and Bootstrap Icons; align with the reference for props and events.
350
+ Rules: use **snake_case** attributes with **string** values; follow Bootstrap 5 and Bootstrap Icons. For **event names** and **event.detail** shapes, use **list.json** \`packages[].definitions.events\`; for **prop JSON types**, use \`packages[].definitions.component\`. Cross-check **${RESOURCE_REFERENCE_URI}** for attribute names and examples.
262
351
 
263
352
  Goal: ${goal}
264
353