@m3e/mcp 2.13.0 → 2.13.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js CHANGED
@@ -56,7 +56,7 @@ function reactUsage(c) {
56
56
  ].join("\n");
57
57
  }
58
58
  export function createServer(catalog) {
59
- const server = new McpServer({ name: "m3e", version: "2.13.0" });
59
+ const server = new McpServer({ name: "m3e", version: "2.13.2" });
60
60
  const readOnly = { readOnlyHint: true, openWorldHint: false };
61
61
  server.registerTool("list_components", {
62
62
  title: "List M3E components",
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAsB,cAAc,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE9E,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,OAAO,GAAG,KAAK,EAAE,EAAE,CAAC,CAAC;IAChD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,CAAC;IAC1C,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;CAChC,CAAC,CAAC;AAEH,MAAM,OAAO,GAAG,CAAC,CAAU,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAEtE,SAAS,QAAQ,CAAC,OAAgB,EAAE,IAAY;IAC9C,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IAC5D,OAAO,KAAK,CACV,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;QACD,WAAW,EAAE,QAAQ;KACtB,EACD,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,EAAE,EAAE;QAC9B,MAAM,GAAG,GAAG,SAAS,CAAC,CAAC,CAAC,OAAO,CAAC,GAAG,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;QACpE,IAAI,SAAS,IAAI,CAAC,GAAG;YAAE,OAAO,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAC3D,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,CAAC,MAAM;YAAE,OAAO,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACrE,MAAM,GAAG,GAAG,GAAG,CAAC;QAChB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,CAAC,IAAI,OAAO,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QACxG,IAAI,IAAI,CAAC,MAAM,GAAG,GAAG;YAAE,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,GAAG,GAAG,yCAAyC,CAAC,CAAC;QAClG,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAChC,CAAC,CACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\r\nimport { z } from \"zod\";\r\nimport { Catalog, Component, reactEventProp, reactName } from \"./manifest.js\";\r\n\r\nconst reply = (text: string, isError = false) => ({\r\n content: [{ type: \"text\" as const, text }],\r\n ...(isError ? { isError } : {}),\r\n});\r\n\r\nconst oneLine = (s?: string) => (s ?? \"\").replace(/\\s+/g, \" \").trim();\r\n\r\nfunction notFound(catalog: Catalog, name: string) {\r\n const hints = catalog.search(name, 5).map((c) => c.tagName);\r\n return reply(\r\n `Unknown component \"${name}\".${hints.length ? ` Did you mean: ${hints.join(\", \")}?` : \"\"} Use list_components to see all.`,\r\n true,\r\n );\r\n}\r\n\r\nfunction section(title: string, rows: string[]) {\r\n return rows.length ? `\\n## ${title}\\n${rows.join(\"\\n\")}\\n` : \"\";\r\n}\r\n\r\nexport function describe(c: Component): string {\r\n const attrs = c.attributes.map(\r\n (a) =>\r\n `- \\`${a.name}\\` (${a.type?.text ?? \"unknown\"}${a.default !== undefined ? `, default ${a.default}` : \"\"}): ${oneLine(a.description)}`,\r\n );\r\n const attrNames = new Set(c.attributes.map((a) => a.name));\r\n const props = c.properties\r\n .filter((p) => !attrNames.has(p.attribute ?? p.name))\r\n .map(\r\n (p) =>\r\n `- \\`${p.name}\\` (${p.type?.text ?? \"unknown\"}${p.readonly ? \", readonly\" : \"\"}): ${oneLine(p.description)}`,\r\n );\r\n const methods = c.methods.map(\r\n (m) =>\r\n `- \\`${m.name}(${(m.parameters ?? []).map((p) => `${p.name}: ${p.type?.text ?? \"any\"}`).join(\", \")})\\`: ${oneLine(m.description)}`,\r\n );\r\n const slots = c.slots.map((s) => `- \\`${s.name || \"(default)\"}\\`: ${oneLine(s.description)}`);\r\n const events = c.events.map((e) => `- \\`${e.name}\\` (${e.type?.text ?? \"Event\"}): ${oneLine(e.description)}`);\r\n const parts = c.cssParts.map((p) => `- \\`${p.name}\\`: ${oneLine(p.description)}`);\r\n const states = c.cssStates.map((p) => `- \\`${p.name}\\`: ${oneLine(p.description)}`);\r\n const vars = c.cssProperties.map((p) => `- \\`${p.name}\\`: ${oneLine(p.description)}`);\r\n\r\n return (\r\n `# <${c.tagName}> (${c.className})\\n${c.description}\\n` +\r\n (c.remarks ? `\\n${c.remarks}\\n` : \"\") +\r\n `\\nImport: \\`import \"@m3e/web/${c.entryPoint}\";\\`\\n` +\r\n section(\"Attributes\", attrs) +\r\n section(\"Other properties\", props) +\r\n section(\"Methods\", methods) +\r\n section(\"Slots\", slots) +\r\n section(\"Events\", events) +\r\n section(\"CSS parts\", parts) +\r\n section(\"CSS states\", states) +\r\n section(\"CSS custom properties\", vars)\r\n );\r\n}\r\n\r\nfunction usage(c: Component): string {\r\n return c.examples.length\r\n ? c.examples.map((example, i) => `## Example ${i + 1}\\n\\n${example}`).join(\"\\n\\n\")\r\n : `No usage examples are documented for <${c.tagName}>. See get_component for its API.`;\r\n}\r\n\r\nfunction reactUsage(c: Component): string {\r\n const name = reactName(c.tagName);\r\n const handlers = c.events.map((e) => `${reactEventProp(e.name)}`);\r\n return [\r\n \"```tsx\",\r\n `import { ${name} } from \"@m3e/react/${c.entryPoint}\";`,\r\n \"\",\r\n `<${name}>Content</${name}>`,\r\n \"```\",\r\n `Event props (derived from the element's events): ${handlers.length ? handlers.map((h) => `\\`${h}\\``).join(\", \") : \"none\"}.`,\r\n \"Properties map to React props by camelCase property name; the ref is forwarded to the element.\",\r\n ].join(\"\\n\");\r\n}\r\n\r\nexport function createServer(catalog: Catalog): McpServer {\r\n const server = new McpServer({ name: \"m3e\", version: \"2.13.0\" });\r\n const readOnly = { readOnlyHint: true, openWorldHint: false };\r\n\r\n server.registerTool(\r\n \"list_components\",\r\n {\r\n title: \"List M3E components\",\r\n description: \"Lists every M3E custom element with a one-line description.\",\r\n annotations: readOnly,\r\n },\r\n async () => reply(catalog.components.map((c) => `- ${c.tagName}: ${oneLine(c.description)}`).join(\"\\n\")),\r\n );\r\n\r\n server.registerTool(\r\n \"get_component\",\r\n {\r\n title: \"Get component API\",\r\n description:\r\n \"Returns the API of an M3E component: attributes, properties, methods, slots, events, CSS parts, states and custom properties.\",\r\n inputSchema: { name: z.string().describe('Tag name, e.g. \"m3e-button\" (the \"m3e-\" prefix is optional)') },\r\n annotations: readOnly,\r\n },\r\n async ({ name }) => {\r\n const c = catalog.get(name);\r\n return c ? reply(describe(c)) : notFound(catalog, name);\r\n },\r\n );\r\n\r\n server.registerTool(\r\n \"search_components\",\r\n {\r\n title: \"Search components\",\r\n description: \"Searches component names, descriptions, attributes, slots and events for the given keywords.\",\r\n inputSchema: {\r\n query: z.string().min(1),\r\n limit: z.number().int().min(1).max(50).optional().describe(\"Maximum results (default 10)\"),\r\n },\r\n annotations: readOnly,\r\n },\r\n async ({ query, limit }) => {\r\n const found = catalog.search(query, limit ?? 10);\r\n return reply(\r\n found.length ? found.map((c) => `- ${c.tagName}: ${oneLine(c.description)}`).join(\"\\n\") : \"No matches.\",\r\n );\r\n },\r\n );\r\n\r\n server.registerTool(\r\n \"get_usage_example\",\r\n {\r\n title: \"Get usage example\",\r\n description: \"Returns the component's documented examples from the Custom Elements Manifest.\",\r\n inputSchema: { name: z.string() },\r\n annotations: readOnly,\r\n },\r\n async ({ name }) => {\r\n const c = catalog.get(name);\r\n return c ? reply(usage(c)) : notFound(catalog, name);\r\n },\r\n );\r\n\r\n server.registerTool(\r\n \"get_react_wrapper\",\r\n {\r\n title: \"Get React wrapper info\",\r\n description: \"Returns the @m3e/react import, component name and event props for a component.\",\r\n inputSchema: { name: z.string() },\r\n annotations: readOnly,\r\n },\r\n async ({ name }) => {\r\n const c = catalog.get(name);\r\n return c ? reply(reactUsage(c)) : notFound(catalog, name);\r\n },\r\n );\r\n\r\n server.registerTool(\r\n \"list_css_properties\",\r\n {\r\n title: \"List design tokens / CSS custom properties\",\r\n description:\r\n \"Lists CSS custom properties used to theme components, optionally filtered by component and/or keyword.\",\r\n inputSchema: {\r\n component: z.string().optional().describe(\"Restrict to one component, e.g. m3e-button\"),\r\n filter: z.string().optional().describe(\"Case-insensitive substring matched against name and description\"),\r\n },\r\n annotations: readOnly,\r\n },\r\n async ({ component, filter }) => {\r\n const tag = component ? catalog.get(component)?.tagName : undefined;\r\n if (component && !tag) return notFound(catalog, component);\r\n const rows = catalog.cssProperties(filter, tag);\r\n if (!rows.length) return reply(\"No matching CSS custom properties.\");\r\n const cap = 200;\r\n const text = rows.slice(0, cap).map((r) => `- ${r.component} \\`${r.name}\\`: ${oneLine(r.description)}`);\r\n if (rows.length > cap) text.push(`… ${rows.length - cap} more; narrow with component or filter.`);\r\n return reply(text.join(\"\\n\"));\r\n },\r\n );\r\n\r\n return server;\r\n}\r\n"]}
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,yCAAyC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAsB,cAAc,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE9E,MAAM,KAAK,GAAG,CAAC,IAAY,EAAE,OAAO,GAAG,KAAK,EAAE,EAAE,CAAC,CAAC;IAChD,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAe,EAAE,IAAI,EAAE,CAAC;IAC1C,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;CAChC,CAAC,CAAC;AAEH,MAAM,OAAO,GAAG,CAAC,CAAU,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAEtE,SAAS,QAAQ,CAAC,OAAgB,EAAE,IAAY;IAC9C,MAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;IAC5D,OAAO,KAAK,CACV,sBAAsB,IAAI,KAAK,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,kBAAkB,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,kCAAkC,EAC1H,IAAI,CACL,CAAC;AACJ,CAAC;AAED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E,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC;QACpE,IAAI,SAAS,IAAI,CAAC,GAAG;YAAE,OAAO,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAC3D,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;QAChD,IAAI,CAAC,IAAI,CAAC,MAAM;YAAE,OAAO,KAAK,CAAC,oCAAoC,CAAC,CAAC;QACrE,MAAM,GAAG,GAAG,GAAG,CAAC;QAChB,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,CAAC,SAAS,MAAM,CAAC,CAAC,IAAI,OAAO,OAAO,CAAC,CAAC,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;QACxG,IAAI,IAAI,CAAC,MAAM,GAAG,GAAG;YAAE,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,GAAG,GAAG,yCAAyC,CAAC,CAAC;QAClG,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IAChC,CAAC,CACF,CAAC;IAEF,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { McpServer } from \"@modelcontextprotocol/sdk/server/mcp.js\";\r\nimport { z } from \"zod\";\r\nimport { Catalog, Component, reactEventProp, reactName } from \"./manifest.js\";\r\n\r\nconst reply = (text: string, isError = false) => ({\r\n content: [{ type: \"text\" as const, text }],\r\n ...(isError ? { isError } : {}),\r\n});\r\n\r\nconst oneLine = (s?: string) => (s ?? \"\").replace(/\\s+/g, \" \").trim();\r\n\r\nfunction notFound(catalog: Catalog, name: string) {\r\n const hints = catalog.search(name, 5).map((c) => c.tagName);\r\n return reply(\r\n `Unknown component \"${name}\".${hints.length ? ` Did you mean: ${hints.join(\", \")}?` : \"\"} Use list_components to see all.`,\r\n true,\r\n );\r\n}\r\n\r\nfunction section(title: string, rows: string[]) {\r\n return rows.length ? `\\n## ${title}\\n${rows.join(\"\\n\")}\\n` : \"\";\r\n}\r\n\r\nexport function describe(c: Component): string {\r\n const attrs = c.attributes.map(\r\n (a) =>\r\n `- \\`${a.name}\\` (${a.type?.text ?? \"unknown\"}${a.default !== undefined ? `, default ${a.default}` : \"\"}): ${oneLine(a.description)}`,\r\n );\r\n const attrNames = new Set(c.attributes.map((a) => a.name));\r\n const props = c.properties\r\n .filter((p) => !attrNames.has(p.attribute ?? p.name))\r\n .map(\r\n (p) =>\r\n `- \\`${p.name}\\` (${p.type?.text ?? \"unknown\"}${p.readonly ? \", readonly\" : \"\"}): ${oneLine(p.description)}`,\r\n );\r\n const methods = c.methods.map(\r\n (m) =>\r\n `- \\`${m.name}(${(m.parameters ?? []).map((p) => `${p.name}: ${p.type?.text ?? \"any\"}`).join(\", \")})\\`: ${oneLine(m.description)}`,\r\n );\r\n const slots = c.slots.map((s) => `- \\`${s.name || \"(default)\"}\\`: ${oneLine(s.description)}`);\r\n const events = c.events.map((e) => `- \\`${e.name}\\` (${e.type?.text ?? \"Event\"}): ${oneLine(e.description)}`);\r\n const parts = c.cssParts.map((p) => `- \\`${p.name}\\`: ${oneLine(p.description)}`);\r\n const states = c.cssStates.map((p) => `- \\`${p.name}\\`: ${oneLine(p.description)}`);\r\n const vars = c.cssProperties.map((p) => `- \\`${p.name}\\`: ${oneLine(p.description)}`);\r\n\r\n return (\r\n `# <${c.tagName}> (${c.className})\\n${c.description}\\n` +\r\n (c.remarks ? `\\n${c.remarks}\\n` : \"\") +\r\n `\\nImport: \\`import \"@m3e/web/${c.entryPoint}\";\\`\\n` +\r\n section(\"Attributes\", attrs) +\r\n section(\"Other properties\", props) +\r\n section(\"Methods\", methods) +\r\n section(\"Slots\", slots) +\r\n section(\"Events\", events) +\r\n section(\"CSS parts\", parts) +\r\n section(\"CSS states\", states) +\r\n section(\"CSS custom properties\", vars)\r\n );\r\n}\r\n\r\nfunction usage(c: Component): string {\r\n return c.examples.length\r\n ? c.examples.map((example, i) => `## Example ${i + 1}\\n\\n${example}`).join(\"\\n\\n\")\r\n : `No usage examples are documented for <${c.tagName}>. See get_component for its API.`;\r\n}\r\n\r\nfunction reactUsage(c: Component): string {\r\n const name = reactName(c.tagName);\r\n const handlers = c.events.map((e) => `${reactEventProp(e.name)}`);\r\n return [\r\n \"```tsx\",\r\n `import { ${name} } from \"@m3e/react/${c.entryPoint}\";`,\r\n \"\",\r\n `<${name}>Content</${name}>`,\r\n \"```\",\r\n `Event props (derived from the element's events): ${handlers.length ? handlers.map((h) => `\\`${h}\\``).join(\", \") : \"none\"}.`,\r\n \"Properties map to React props by camelCase property name; the ref is forwarded to the element.\",\r\n ].join(\"\\n\");\r\n}\r\n\r\nexport function createServer(catalog: Catalog): McpServer {\r\n const server = new McpServer({ name: \"m3e\", version: \"2.13.2\" });\r\n const readOnly = { readOnlyHint: true, openWorldHint: false };\r\n\r\n server.registerTool(\r\n \"list_components\",\r\n {\r\n title: \"List M3E components\",\r\n description: \"Lists every M3E custom element with a one-line description.\",\r\n annotations: readOnly,\r\n },\r\n async () => reply(catalog.components.map((c) => `- ${c.tagName}: ${oneLine(c.description)}`).join(\"\\n\")),\r\n );\r\n\r\n server.registerTool(\r\n \"get_component\",\r\n {\r\n title: \"Get component API\",\r\n description:\r\n \"Returns the API of an M3E component: attributes, properties, methods, slots, events, CSS parts, states and custom properties.\",\r\n inputSchema: { name: z.string().describe('Tag name, e.g. \"m3e-button\" (the \"m3e-\" prefix is optional)') },\r\n annotations: readOnly,\r\n },\r\n async ({ name }) => {\r\n const c = catalog.get(name);\r\n return c ? reply(describe(c)) : notFound(catalog, name);\r\n },\r\n );\r\n\r\n server.registerTool(\r\n \"search_components\",\r\n {\r\n title: \"Search components\",\r\n description: \"Searches component names, descriptions, attributes, slots and events for the given keywords.\",\r\n inputSchema: {\r\n query: z.string().min(1),\r\n limit: z.number().int().min(1).max(50).optional().describe(\"Maximum results (default 10)\"),\r\n },\r\n annotations: readOnly,\r\n },\r\n async ({ query, limit }) => {\r\n const found = catalog.search(query, limit ?? 10);\r\n return reply(\r\n found.length ? found.map((c) => `- ${c.tagName}: ${oneLine(c.description)}`).join(\"\\n\") : \"No matches.\",\r\n );\r\n },\r\n );\r\n\r\n server.registerTool(\r\n \"get_usage_example\",\r\n {\r\n title: \"Get usage example\",\r\n description: \"Returns the component's documented examples from the Custom Elements Manifest.\",\r\n inputSchema: { name: z.string() },\r\n annotations: readOnly,\r\n },\r\n async ({ name }) => {\r\n const c = catalog.get(name);\r\n return c ? reply(usage(c)) : notFound(catalog, name);\r\n },\r\n );\r\n\r\n server.registerTool(\r\n \"get_react_wrapper\",\r\n {\r\n title: \"Get React wrapper info\",\r\n description: \"Returns the @m3e/react import, component name and event props for a component.\",\r\n inputSchema: { name: z.string() },\r\n annotations: readOnly,\r\n },\r\n async ({ name }) => {\r\n const c = catalog.get(name);\r\n return c ? reply(reactUsage(c)) : notFound(catalog, name);\r\n },\r\n );\r\n\r\n server.registerTool(\r\n \"list_css_properties\",\r\n {\r\n title: \"List design tokens / CSS custom properties\",\r\n description:\r\n \"Lists CSS custom properties used to theme components, optionally filtered by component and/or keyword.\",\r\n inputSchema: {\r\n component: z.string().optional().describe(\"Restrict to one component, e.g. m3e-button\"),\r\n filter: z.string().optional().describe(\"Case-insensitive substring matched against name and description\"),\r\n },\r\n annotations: readOnly,\r\n },\r\n async ({ component, filter }) => {\r\n const tag = component ? catalog.get(component)?.tagName : undefined;\r\n if (component && !tag) return notFound(catalog, component);\r\n const rows = catalog.cssProperties(filter, tag);\r\n if (!rows.length) return reply(\"No matching CSS custom properties.\");\r\n const cap = 200;\r\n const text = rows.slice(0, cap).map((r) => `- ${r.component} \\`${r.name}\\`: ${oneLine(r.description)}`);\r\n if (rows.length > cap) text.push(`… ${rows.length - cap} more; narrow with component or filter.`);\r\n return reply(text.join(\"\\n\"));\r\n },\r\n );\r\n\r\n return server;\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@m3e/mcp",
3
- "version": "2.13.0",
3
+ "version": "2.13.2",
4
4
  "description": "Model Context Protocol server exposing the M3E component library to AI assistants",
5
5
  "author": "matraic <matraic@yahoo.com>",
6
6
  "license": "MIT",
@@ -35,7 +35,7 @@
35
35
  "clean": "rimraf dist test-results"
36
36
  },
37
37
  "dependencies": {
38
- "@m3e/web": "^2.13.0",
38
+ "@m3e/web": "^2.13.2",
39
39
  "@modelcontextprotocol/sdk": "^1.32.2",
40
40
  "zod": "^4.6.7"
41
41
  },