tabbied-mcp 0.2.2 → 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/LICENSE +21 -21
- package/README.md +147 -83
- package/dist/index.js.map +1 -1
- package/dist/info.d.ts +1 -1
- package/dist/info.js +10 -9
- package/dist/info.js.map +1 -1
- package/dist/node/index.d.ts +2 -0
- package/dist/node/index.js +7 -0
- package/dist/node/index.js.map +1 -0
- package/dist/node/render.js +197 -99
- package/dist/node/render.js.map +1 -1
- package/dist/node/resources.js +37 -23
- package/dist/node/resources.js.map +1 -1
- package/dist/server.js +9 -1
- package/dist/server.js.map +1 -1
- package/dist/stdio.js +2 -0
- package/dist/stdio.js.map +1 -1
- package/dist/templates.js +143 -27
- package/dist/templates.js.map +1 -1
- package/dist/tools.js +53 -5
- package/dist/tools.js.map +1 -1
- package/dist/types.d.ts +11 -1
- package/dist/types.js.map +1 -1
- package/package.json +61 -55
package/dist/tools.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,oEAAoE;AACpE,oBAAoB;AACpB,EAAE;AACF,yEAAyE;AACzE,6EAA6E;AAC7E,EAAE;AACF,2EAA2E;AAC3E,yEAAyE;AACzE,6EAA6E;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAW/C,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAE5B,6EAA6E;AAC7E,6EAA6E;AAC7E,qCAAqC;AACrC,MAAM,mBAAmB,GAAG,SAAS,CAAC;AAEtC,+EAA+E;AAE/E,MAAM,IAAI,GAAG,CAAC,KAAa,EAAe,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,E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abbied toolset: four thin wrappers over catalog.json, the template tools\r\n// (templates.ts), and whatever the host adds (the stdio server adds\r\n// `render_design`).\r\n//\r\n// Nothing here touches node or the Worker runtime; the host injects what\r\n// differs via ToolContext, so both transports describe a design identically.\r\n//\r\n// The point is design *selection*. Slugs are opaque (\"cleat\", \"karst\") and\r\n// these are pictures, so search narrows on closed-vocabulary enums, then\r\n// preview_design puts the shortlist in front of the model before it commits.\r\nimport { templateTools } from './templates.js';\r\nimport type {\r\n Catalog,\r\n CatalogDesign,\r\n Tool,\r\n ToolContent,\r\n ToolContext,\r\n ToolDefinition,\r\n ToolResult,\r\n} from './types.js';\r\n\r\nconst SEARCH_LIMIT_DEFAULT = 20;\r\nconst SEARCH_LIMIT_MAX = 50;\r\nconst PREVIEW_MAX_SLUGS = 6;\r\n\r\n// Previews reach a few hundred KB and base64 adds a third, so six large ones\r\n// would spend megabytes of context. The batch stops early and says so rather\r\n// than silently truncating the list.\r\nconst PREVIEW_BYTE_BUDGET = 1_500_000;\r\n\r\n// ---- helpers ---------------------------------------------------------------\r\n\r\nconst text = (value: string): ToolContent => ({ type: 'text', text: value });\r\n\r\nconst json = (value: unknown): ToolContent =>\r\n text(JSON.stringify(value, null, 2));\r\n\r\nconst toolError = (message: string): ToolResult => ({\r\n content: [text(message)],\r\n isError: true,\r\n});\r\n\r\n/** Distinct values of a repeated field, sorted - the vocabulary actually in use. */\r\nfunction vocabulary(\r\n designs: CatalogDesign[],\r\n field: 'tags' | 'mood' | 'goodFor'\r\n): string[] {\r\n return [...new Set(designs.flatMap((design) => design[field]))].sort();\r\n}\r\n\r\nfunction densities(designs: CatalogDesign[]): string[] {\r\n return [...new Set(designs.map((design) => design.density))].sort();\r\n}\r\n\r\nfunction asStringArray(value: unknown): string[] | null {\r\n if (value == null) return null;\r\n const list = Array.isArray(value) ? value : [value];\r\n const strings = list.filter((entry): entry is string => typeof entry === 'string');\r\n return strings.length ? strings : null;\r\n}\r\n\r\n/** The compact form used in search hits - enough to shortlist, not the full record. */\r\nfunction summarize(design: CatalogDesign) {\r\n return {\r\n slug: design.slug,\r\n name: design.name,\r\n ...(design.description ? { description: design.description } : {}),\r\n tags: design.tags,\r\n mood: design.mood,\r\n density: design.density,\r\n goodFor: design.goodFor,\r\n svgExport: design.svgExport.supported,\r\n preview: design.preview,\r\n };\r\n}\r\n\r\nfunction findDesign(catalog: Catalog, slug: unknown): CatalogDesign | null {\r\n if (typeof slug !== 'string') return null;\r\n return catalog.designs.find((design) => design.slug === slug) ?? null;\r\n}\r\n\r\n/** Near misses for an unknown slug: a shared three-letter prefix, or a name match. */\r\nfunction suggestSlugs(catalog: Catalog, slug: string): string[] {\r\n const needle = slug.toLowerCase();\r\n return catalog.designs\r\n .filter(\r\n (design) =>\r\n design.slug.startsWith(needle.slice(0, 3)) ||\r\n design.name.toLowerCase().includes(needle)\r\n )\r\n .slice(0, 8)\r\n .map((design) => design.slug);\r\n}\r\n\r\n// ---- search_designs --------------------------------------------------------\r\n\r\nfunction searchTool(catalog: Catalog): Tool {\r\n const tags = vocabulary(catalog.designs, 'tags');\r\n const moods = vocabulary(catalog.designs, 'mood');\r\n const goodFor = vocabulary(catalog.designs, 'goodFor');\r\n const densityValues = densities(catalog.designs);\r\n\r\n const definition: ToolDefinition = {\r\n name: 'search_designs',\r\n title: 'Search designs',\r\n description:\r\n `Find Tabbied designs by visible motif, feel, busyness, or intended use. ` +\r\n `Filters combine with AND - listing two tags returns only designs carrying ` +\r\n `both - so start broad and narrow. Returns compact entries including a ` +\r\n `preview image URL; follow up with preview_design to actually look at the ` +\r\n `shortlist before choosing, because these are pictures and the metadata ` +\r\n `only narrows the field. ${catalog.count} designs in total.`,\r\n inputSchema: {\r\n type: 'object',\r\n properties: {\r\n query: {\r\n type: 'string',\r\n description:\r\n 'Free text matched against slug, name, and description. Every ' +\r\n 'whitespace-separated word must appear somewhere in the entry.',\r\n },\r\n tags: {\r\n type: 'array',\r\n items: { type: 'string', enum: tags },\r\n description: 'Visible motifs. A design must carry every tag listed.',\r\n },\r\n mood: {\r\n type: 'array',\r\n items: { type: 'string', enum: moods },\r\n description: 'The feel of the design at a glance.',\r\n },\r\n density: {\r\n type: 'string',\r\n enum: densityValues,\r\n description:\r\n 'How busy the surface is. sparse takes overlaid text well; dense is ' +\r\n 'ink-dominated.',\r\n },\r\n goodFor: {\r\n type: 'array',\r\n items: { type: 'string', enum: goodFor },\r\n description: 'Uses the design suits with no customization.',\r\n },\r\n svgExport: {\r\n type: 'boolean',\r\n description:\r\n 'Restrict to designs that can (true) or cannot (false) be exported ' +\r\n 'as true vector SVG. Some use CSS (smooth conic sweeps, double or ' +\r\n 'dashed borders, 3D transforms) that SVG cannot represent faithfully.',\r\n },\r\n limit: {\r\n type: 'integer',\r\n minimum: 1,\r\n maximum: SEARCH_LIMIT_MAX,\r\n description: `Maximum hits to return (default ${SEARCH_LIMIT_DEFAULT}).`,\r\n },\r\n },\r\n additionalProperties: false,\r\n },\r\n };\r\n\r\n return {\r\n definition,\r\n run(args) {\r\n const wantTags = asStringArray(args.tags);\r\n const wantMood = asStringArray(args.mood);\r\n const wantGoodFor = asStringArray(args.goodFor);\r\n const density = typeof args.density === 'string' ? args.density : null;\r\n const svgExport =\r\n typeof args.svgExport === 'boolean' ? args.svgExport : null;\r\n const terms =\r\n typeof args.query === 'string'\r\n ? args.query.toLowerCase().split(/\\s+/).filter(Boolean)\r\n : [];\r\n\r\n const limit = Math.min(\r\n Math.max(\r\n typeof args.limit === 'number' && Number.isFinite(args.limit)\r\n ? Math.trunc(args.limit)\r\n : SEARCH_LIMIT_DEFAULT,\r\n 1\r\n ),\r\n SEARCH_LIMIT_MAX\r\n );\r\n\r\n const matches = (design: CatalogDesign) => {\r\n const haystack =\r\n `${design.slug} ${design.name} ${design.description ?? ''}`.toLowerCase();\r\n return (\r\n terms.every((term) => haystack.includes(term)) &&\r\n (!wantTags || wantTags.every((tag) => design.tags.includes(tag))) &&\r\n (!wantMood || wantMood.every((mood) => design.mood.includes(mood))) &&\r\n (!wantGoodFor ||\r\n wantGoodFor.every((use) => design.goodFor.includes(use))) &&\r\n (!density || design.density === density) &&\r\n (svgExport === null || design.svgExport.supported === svgExport)\r\n );\r\n };\r\n\r\n const hits = catalog.designs.filter(matches);\r\n\r\n // From an empty result an agent can't tell an over-narrow AND from a\r\n // wrongly guessed vocabulary, so report how each filter does on its own.\r\n if (hits.length === 0) {\r\n const alone = (label: string, predicate: (d: CatalogDesign) => boolean) => ({\r\n filter: label,\r\n matches: catalog.designs.filter(predicate).length,\r\n });\r\n const breakdown = [\r\n ...(terms.length\r\n ? [\r\n alone(`query \"${args.query}\"`, (design) =>\r\n terms.every((term) =>\r\n `${design.slug} ${design.name} ${design.description ?? ''}`\r\n .toLowerCase()\r\n .includes(term)\r\n )\r\n ),\r\n ]\r\n : []),\r\n ...(wantTags ?? []).map((tag) =>\r\n alone(`tag \"${tag}\"`, (design) => design.tags.includes(tag))\r\n ),\r\n ...(wantMood ?? []).map((mood) =>\r\n alone(`mood \"${mood}\"`, (design) => design.mood.includes(mood))\r\n ),\r\n ...(wantGoodFor ?? []).map((use) =>\r\n alone(`goodFor \"${use}\"`, (design) => design.goodFor.includes(use))\r\n ),\r\n ...(density\r\n ? [alone(`density \"${density}\"`, (design) => design.density === density)]\r\n : []),\r\n ...(svgExport !== null\r\n ? [alone(`svgExport ${svgExport}`, (design) => design.svgExport.supported === svgExport)]\r\n : []),\r\n ];\r\n\r\n return {\r\n content: [\r\n json({\r\n matched: 0,\r\n total: catalog.count,\r\n note:\r\n 'No design satisfies every filter at once. Each filter on its ' +\r\n 'own matches the counts below - drop the ones scoring 0 (likely ' +\r\n 'out of vocabulary) and relax the rest.',\r\n filtersIndependently: breakdown,\r\n vocabulary: {\r\n tags,\r\n mood: moods,\r\n density: densityValues,\r\n goodFor,\r\n },\r\n }),\r\n ],\r\n };\r\n }\r\n\r\n return {\r\n content: [\r\n json({\r\n matched: hits.length,\r\n total: catalog.count,\r\n returned: Math.min(hits.length, limit),\r\n designs: hits.slice(0, limit).map(summarize),\r\n }),\r\n ],\r\n };\r\n },\r\n };\r\n}\r\n\r\n// ---- get_design ------------------------------------------------------------\r\n\r\nfunction getDesignTool(catalog: Catalog): Tool {\r\n const definition: ToolDefinition = {\r\n name: 'get_design',\r\n title: 'Get design details',\r\n description:\r\n 'The full catalog record for one design - palette, every option with its ' +\r\n 'range and default, SVG-export support, preview URL - plus ready-to-paste ' +\r\n 'React and vanilla snippets. Call this once a slug is chosen; ' +\r\n 'search_designs already returns enough to shortlist.',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {\r\n slug: {\r\n type: 'string',\r\n description: 'The design slug, e.g. \"radius\". Slugs are not guessable.',\r\n },\r\n },\r\n required: ['slug'],\r\n additionalProperties: false,\r\n },\r\n };\r\n\r\n return {\r\n definition,\r\n run(args) {\r\n const design = findDesign(catalog, args.slug);\r\n if (!design) {\r\n const near = suggestSlugs(catalog, String(args.slug ?? ''));\r\n return toolError(\r\n `No design with slug \"${args.slug}\". ` +\r\n (near.length\r\n ? `Closest slugs: ${near.join(', ')}. `\r\n : '') +\r\n 'Use search_designs to find one - slugs are opaque and cannot be guessed.'\r\n );\r\n }\r\n\r\n const snippet = (template: string) =>\r\n template.replaceAll('<slug>', design.slug);\r\n\r\n return {\r\n content: [\r\n json({\r\n ...design,\r\n usage: {\r\n install: catalog.usage.install,\r\n import: snippet(catalog.usage.import),\r\n react: snippet(catalog.usage.react),\r\n core: snippet(catalog.usage.core),\r\n fit: catalog.usage.fit,\r\n cli: `npx tabbied render ${design.slug} --out ${design.slug}.svg`,\r\n },\r\n // The number-one integration mistake, repeated here because an\r\n // agent that called get_design may never read llms-full.txt.\r\n sizing:\r\n 'A pattern has no intrinsic size - it fills its parent, and ' +\r\n 'collapses to nothing in a parent that sizes to content. Pass ' +\r\n 'height or aspectRatio when in doubt.',\r\n ...(design.svgExport.supported\r\n ? {}\r\n : {\r\n svgExportWarning:\r\n 'This design cannot be exported as vector SVG. Render it as PNG instead.',\r\n }),\r\n }),\r\n ],\r\n };\r\n },\r\n };\r\n}\r\n\r\n// ---- preview_design --------------------------------------------------------\r\n\r\nfunction previewTool(context: ToolContext): Tool | null {\r\n const { catalog, fetchPreview } = context;\r\n if (!fetchPreview) return null;\r\n\r\n const definition: ToolDefinition = {\r\n name: 'preview_design',\r\n title: 'Look at designs',\r\n description:\r\n `Return the rendered preview image for up to ${PREVIEW_MAX_SLUGS} designs, ` +\r\n 'so you can see them rather than infer them from tags. Previews use each ' +\r\n \"design's authored palette, default options, and a fixed seed. This is the \" +\r\n 'step that makes a choice reliable - do it before committing to a slug.',\r\n inputSchema: {\r\n type: 'object',\r\n properties: {\r\n slugs: {\r\n type: 'array',\r\n items: { type: 'string' },\r\n minItems: 1,\r\n maxItems: PREVIEW_MAX_SLUGS,\r\n description: 'Design slugs to look at, e.g. [\"radius\", \"cleat\"].',\r\n },\r\n },\r\n required: ['slugs'],\r\n additionalProperties: false,\r\n },\r\n };\r\n\r\n return {\r\n definition,\r\n async run(args) {\r\n const slugs = asStringArray(args.slugs);\r\n if (!slugs) {\r\n return toolError('Pass \"slugs\" as a non-empty array of design slugs.');\r\n }\r\n\r\n const requested = slugs.slice(0, PREVIEW_MAX_SLUGS);\r\n const content: ToolContent[] = [];\r\n let spent = 0;\r\n\r\n for (const [index, slug] of requested.entries()) {\r\n const design = findDesign(catalog, slug);\r\n if (!design) {\r\n content.push(\r\n text(`${slug}: no such design. Use search_designs to find valid slugs.`)\r\n );\r\n continue;\r\n }\r\n\r\n if (spent > PREVIEW_BYTE_BUDGET) {\r\n content.push(\r\n text(\r\n `Stopped after ${index} image(s) to stay within a sane response ` +\r\n `size. Ask again for the rest: ${requested.slice(index).join(', ')}.`\r\n )\r\n );\r\n break;\r\n }\r\n\r\n try {\r\n const { data, mimeType } = await fetchPreview(design);\r\n spent += data.length;\r\n content.push(\r\n text(\r\n `${design.slug} - ${design.name}` +\r\n (design.description ? `: ${design.description}` : '')\r\n ),\r\n { type: 'image', data, mimeType }\r\n );\r\n } catch (error) {\r\n content.push(\r\n text(\r\n `${design.slug}: preview unavailable (${\r\n error instanceof Error ? error.message : String(error)\r\n }). The image is also at ${design.preview}.`\r\n )\r\n );\r\n }\r\n }\r\n\r\n return { content };\r\n },\r\n };\r\n}\r\n\r\n// ---- get_docs --------------------------------------------------------------\r\n\r\nfunction docsTool(context: ToolContext): Tool | null {\r\n const { fetchDocs } = context;\r\n if (!fetchDocs) return null;\r\n\r\n return {\r\n definition: {\r\n name: 'get_docs',\r\n title: 'Get the Tabbied reference',\r\n description:\r\n 'The complete agent-facing reference (llms-full.txt): entry points, the ' +\r\n 'React and vanilla APIs, sizing rules that compile but render wrong, ' +\r\n 'integration recipes, and the share-link URL scheme. Fetch this once ' +\r\n 'before writing integration code; the per-design tools do not repeat it.',\r\n inputSchema: { type: 'object', additionalProperties: false },\r\n },\r\n async run() {\r\n try {\r\n return { content: [text(await fetchDocs())] };\r\n } catch (error) {\r\n return toolError(\r\n `Could not load the reference (${\r\n error instanceof Error ? error.message : String(error)\r\n }). It is also served at https://tabbied.com/llms-full.txt.`\r\n );\r\n }\r\n },\r\n };\r\n}\r\n\r\n// ---- assembly --------------------------------------------------------------\r\n\r\n/**\r\n * The catalog-backed tools available in every runtime, template tools\r\n * included. A host opts into a tool by supplying its fetcher in the one\r\n * context, so the tool list follows from what the host can resolve.\r\n */\r\nexport function catalogTools(context: ToolContext): Tool[] {\r\n return [\r\n searchTool(context.catalog),\r\n getDesignTool(context.catalog),\r\n previewTool(context),\r\n docsTool(context),\r\n ...templateTools(context),\r\n ].filter((tool): tool is Tool => tool !== null);\r\n}\r\n\r\nexport type Toolset = {\r\n list(): ToolDefinition[];\r\n call(name: string, args: Record<string, unknown>): Promise<ToolResult>;\r\n has(name: string): boolean;\r\n};\r\n\r\n/**\r\n * Bundle tools into a name lookup. Handler throws become `isError` results\r\n * rather than JSON-RPC errors: the spec reserves protocol errors for malformed\r\n * requests and sends execution failures back to the model to retry.\r\n */\r\nexport function createToolset(tools: Tool[]): Toolset {\r\n const byName = new Map(tools.map((tool) => [tool.definition.name, tool]));\r\n\r\n return {\r\n list: () => tools.map((tool) => tool.definition),\r\n has: (name) => byName.has(name),\r\n async call(name, args) {\r\n const tool = byName.get(name);\r\n if (!tool) {\r\n return toolError(\r\n `Unknown tool \"${name}\". Available: ${[...byName.keys()].join(', ')}.`\r\n );\r\n }\r\n try {\r\n return await tool.run(args ?? {});\r\n } catch (error) {\r\n return toolError(\r\n error instanceof Error ? error.message : String(error)\r\n );\r\n }\r\n },\r\n };\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"tools.js","sourceRoot":"","sources":["../src/tools.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,oEAAoE;AACpE,oBAAoB;AACpB,EAAE;AACF,yEAAyE;AACzE,6EAA6E;AAC7E,EAAE;AACF,2EAA2E;AAC3E,yEAAyE;AACzE,6EAA6E;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAW/C,MAAM,oBAAoB,GAAG,EAAE,CAAC;AAChC,MAAM,gBAAgB,GAAG,EAAE,CAAC;AAC5B,MAAM,iBAAiB,GAAG,CAAC,CAAC;AAE5B,6EAA6E;AAC7E,6EAA6E;AAC7E,qCAAqC;AACrC,MAAM,mBAAmB,GAAG,SAAS,CAAC;AAEtC,+EAA+E;AAE/E,MAAM,IAAI,GAAG,CAAC,KAAa,EAAe,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;AAE7E,MAAM,IAAI,GAAG,CAAC,KAAc,EAAe,EAAE,CAC3C,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;AAEvC,MAAM,SAAS,GAAG,CAAC,OAAe,EAAc,EAAE,CAAC,CAAC;IAClD,OAAO,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;IACxB,OAAO,EAAE,IAA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YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CACvD,CAAC;YACJ,CAAC;QACH,CAAC;KACF,CAAC;AACJ,CAAC","sourcesContent":["// The Tabbied toolset: four thin wrappers over catalog.json, the template tools\n// (templates.ts), and whatever the host adds (the stdio server adds\n// `render_design`).\n//\n// Nothing here touches node or the Worker runtime; the host injects what\n// differs via ToolContext, so both transports describe a design identically.\n//\n// The point is design *selection*. Slugs are opaque (\"cleat\", \"karst\") and\n// these are pictures, so search narrows on closed-vocabulary enums, then\n// preview_design puts the shortlist in front of the model before it commits.\nimport { templateTools } from './templates.js';\nimport type {\n Catalog,\n CatalogDesign,\n Tool,\n ToolContent,\n ToolContext,\n ToolDefinition,\n ToolResult,\n} from './types.js';\n\nconst SEARCH_LIMIT_DEFAULT = 20;\nconst SEARCH_LIMIT_MAX = 50;\nconst PREVIEW_MAX_SLUGS = 6;\n\n// Previews reach a few hundred KB and base64 adds a third, so six large ones\n// would spend megabytes of context. The batch stops early and says so rather\n// than silently truncating the list.\nconst PREVIEW_BYTE_BUDGET = 1_500_000;\n\n// ---- helpers ---------------------------------------------------------------\n\nconst text = (value: string): ToolContent => ({ type: 'text', text: value });\n\nconst json = (value: unknown): ToolContent =>\n text(JSON.stringify(value, null, 2));\n\nconst toolError = (message: string): ToolResult => ({\n content: [text(message)],\n isError: true,\n});\n\n/** Distinct values of a repeated field, sorted - the vocabulary actually in use. */\nfunction vocabulary(\n designs: CatalogDesign[],\n field: 'tags' | 'mood' | 'goodFor'\n): string[] {\n return [...new Set(designs.flatMap((design) => design[field]))].sort();\n}\n\nfunction densities(designs: CatalogDesign[]): string[] {\n return [...new Set(designs.map((design) => design.density))].sort();\n}\n\nfunction asStringArray(value: unknown): string[] | null {\n if (value == null) return null;\n const list = Array.isArray(value) ? value : [value];\n const strings = list.filter((entry): entry is string => typeof entry === 'string');\n return strings.length ? strings : null;\n}\n\n/** The compact form used in search hits - enough to shortlist, not the full record. */\nfunction summarize(design: CatalogDesign) {\n return {\n slug: design.slug,\n name: design.name,\n ...(design.description ? { description: design.description } : {}),\n tags: design.tags,\n mood: design.mood,\n density: design.density,\n goodFor: design.goodFor,\n svgExport: design.svgExport.supported,\n preview: design.preview,\n };\n}\n\nfunction findDesign(catalog: Catalog, slug: unknown): CatalogDesign | null {\n if (typeof slug !== 'string') return null;\n return catalog.designs.find((design) => design.slug === slug) ?? null;\n}\n\nconst ASPECT_RATIO_DEFAULT = '2:3';\n\n/**\n * The React snippet: a component at the design's own aspect ratio. The ratio\n * is the catalog's id (`2:3`) written as CSS's `2 / 3`, which is what the\n * prop takes - the id itself is not valid CSS and would size nothing. Same\n * shape as the editor's \"Copy React component\", so the two agree.\n */\nfunction reactSnippet(design: CatalogDesign): string {\n const ratio = design.defaultAspectRatio ?? ASPECT_RATIO_DEFAULT;\n const [width, height] = /^(\\d+):(\\d+)$/.exec(ratio)?.slice(1) ?? ['2', '3'];\n const component = `${design.slug.charAt(0).toUpperCase()}${design.slug.slice(1)}Pattern`;\n\n return [\n `import { TabbiedPattern } from 'tabbied/react';`,\n `import { ${design.slug} } from 'tabbied/patterns';`,\n ``,\n `// As wide as its parent, at the ${width}:${height} ratio it was designed at.`,\n `// Add maxWidth to bound it, or swap aspectRatio for a fixed height.`,\n `export function ${component}() {`,\n ` return (`,\n ` <TabbiedPattern`,\n ` pattern={${design.slug}}`,\n ` aspectRatio=\"${width} / ${height}\"`,\n ` />`,\n ` );`,\n `}`,\n ].join('\\n');\n}\n\n/** What the CLI command in `usage.cli` needs where it runs. */\nconst CLI_SETUP =\n 'Rendering needs Playwright, found from the current directory first: ' +\n '`npm i -D playwright && npx playwright install chromium`. With nothing ' +\n 'installed, run `npx -y -p tabbied -p playwright tabbied render ...` ' +\n 'instead (and `npx playwright install chromium` once).';\n\n/** Near misses for an unknown slug: a shared three-letter prefix, or a name match. */\nfunction suggestSlugs(catalog: Catalog, slug: string): string[] {\n const needle = slug.trim().toLowerCase();\n // An empty needle is a prefix of every slug, so it would \"suggest\" the first\n // eight in the catalog.\n if (!needle) return [];\n return catalog.designs\n .filter(\n (design) =>\n design.slug.startsWith(needle.slice(0, 3)) ||\n design.name.toLowerCase().includes(needle)\n )\n .slice(0, 8)\n .map((design) => design.slug);\n}\n\n// ---- search_designs --------------------------------------------------------\n\nfunction searchTool(catalog: Catalog): Tool {\n const tags = vocabulary(catalog.designs, 'tags');\n const moods = vocabulary(catalog.designs, 'mood');\n const goodFor = vocabulary(catalog.designs, 'goodFor');\n const densityValues = densities(catalog.designs);\n\n const definition: ToolDefinition = {\n name: 'search_designs',\n title: 'Search designs',\n description:\n `Find Tabbied designs by visible motif, feel, busyness, or intended use. ` +\n `Filters combine with AND - listing two tags returns only designs carrying ` +\n `both - so start broad and narrow. Returns compact entries including a ` +\n `preview image URL; follow up with preview_design to actually look at the ` +\n `shortlist before choosing, because these are pictures and the metadata ` +\n `only narrows the field. ${catalog.count} designs in total.`,\n inputSchema: {\n type: 'object',\n properties: {\n query: {\n type: 'string',\n description:\n 'Free text matched against slug, name, and description. Every ' +\n 'whitespace-separated word must appear somewhere in the entry.',\n },\n tags: {\n type: 'array',\n items: { type: 'string', enum: tags },\n description: 'Visible motifs. A design must carry every tag listed.',\n },\n mood: {\n type: 'array',\n items: { type: 'string', enum: moods },\n description: 'The feel of the design at a glance.',\n },\n density: {\n type: 'string',\n enum: densityValues,\n description:\n 'How busy the surface is. sparse takes overlaid text well; dense is ' +\n 'ink-dominated.',\n },\n goodFor: {\n type: 'array',\n items: { type: 'string', enum: goodFor },\n description: 'Uses the design suits with no customization.',\n },\n svgExport: {\n type: 'boolean',\n description:\n 'Restrict to designs that can (true) or cannot (false) be exported ' +\n 'as true vector SVG. Some use CSS (smooth conic sweeps, double or ' +\n 'dashed borders, 3D transforms) that SVG cannot represent faithfully.',\n },\n limit: {\n type: 'integer',\n minimum: 1,\n maximum: SEARCH_LIMIT_MAX,\n description: `Maximum hits to return (default ${SEARCH_LIMIT_DEFAULT}).`,\n },\n },\n additionalProperties: false,\n },\n annotations: { readOnlyHint: true, openWorldHint: false },\n };\n\n return {\n definition,\n run(args) {\n const wantTags = asStringArray(args.tags);\n const wantMood = asStringArray(args.mood);\n const wantGoodFor = asStringArray(args.goodFor);\n const density = typeof args.density === 'string' ? args.density : null;\n const svgExport =\n typeof args.svgExport === 'boolean' ? args.svgExport : null;\n const terms =\n typeof args.query === 'string'\n ? args.query.toLowerCase().split(/\\s+/).filter(Boolean)\n : [];\n\n const limit = Math.min(\n Math.max(\n typeof args.limit === 'number' && Number.isFinite(args.limit)\n ? Math.trunc(args.limit)\n : SEARCH_LIMIT_DEFAULT,\n 1\n ),\n SEARCH_LIMIT_MAX\n );\n\n const matches = (design: CatalogDesign) => {\n const haystack =\n `${design.slug} ${design.name} ${design.description ?? ''}`.toLowerCase();\n return (\n terms.every((term) => haystack.includes(term)) &&\n (!wantTags || wantTags.every((tag) => design.tags.includes(tag))) &&\n (!wantMood || wantMood.every((mood) => design.mood.includes(mood))) &&\n (!wantGoodFor ||\n wantGoodFor.every((use) => design.goodFor.includes(use))) &&\n (!density || design.density === density) &&\n (svgExport === null || design.svgExport.supported === svgExport)\n );\n };\n\n const hits = catalog.designs.filter(matches);\n\n // From an empty result an agent can't tell an over-narrow AND from a\n // wrongly guessed vocabulary, so report how each filter does on its own.\n if (hits.length === 0) {\n const alone = (label: string, predicate: (d: CatalogDesign) => boolean) => ({\n filter: label,\n matches: catalog.designs.filter(predicate).length,\n });\n const breakdown = [\n ...(terms.length\n ? [\n alone(`query \"${args.query}\"`, (design) =>\n terms.every((term) =>\n `${design.slug} ${design.name} ${design.description ?? ''}`\n .toLowerCase()\n .includes(term)\n )\n ),\n ]\n : []),\n ...(wantTags ?? []).map((tag) =>\n alone(`tag \"${tag}\"`, (design) => design.tags.includes(tag))\n ),\n ...(wantMood ?? []).map((mood) =>\n alone(`mood \"${mood}\"`, (design) => design.mood.includes(mood))\n ),\n ...(wantGoodFor ?? []).map((use) =>\n alone(`goodFor \"${use}\"`, (design) => design.goodFor.includes(use))\n ),\n ...(density\n ? [alone(`density \"${density}\"`, (design) => design.density === density)]\n : []),\n ...(svgExport !== null\n ? [alone(`svgExport ${svgExport}`, (design) => design.svgExport.supported === svgExport)]\n : []),\n ];\n\n return {\n content: [\n json({\n matched: 0,\n total: catalog.count,\n note:\n 'No design satisfies every filter at once. Each filter on its ' +\n 'own matches the counts below - drop the ones scoring 0 (likely ' +\n 'out of vocabulary) and relax the rest.',\n filtersIndependently: breakdown,\n vocabulary: {\n tags,\n mood: moods,\n density: densityValues,\n goodFor,\n },\n }),\n ],\n };\n }\n\n return {\n content: [\n json({\n matched: hits.length,\n total: catalog.count,\n returned: Math.min(hits.length, limit),\n designs: hits.slice(0, limit).map(summarize),\n }),\n ],\n };\n },\n };\n}\n\n// ---- get_design ------------------------------------------------------------\n\nfunction getDesignTool(catalog: Catalog): Tool {\n const definition: ToolDefinition = {\n name: 'get_design',\n title: 'Get design details',\n description:\n 'The full catalog record for one design - palette, every option with its ' +\n 'range and default, SVG-export support, preview URL - plus ready-to-paste ' +\n 'React and vanilla snippets. Call this once a slug is chosen; ' +\n 'search_designs already returns enough to shortlist.',\n inputSchema: {\n type: 'object',\n properties: {\n slug: {\n type: 'string',\n minLength: 1,\n description: 'The design slug, e.g. \"radius\". Slugs are not guessable.',\n },\n },\n required: ['slug'],\n additionalProperties: false,\n },\n annotations: { readOnlyHint: true, openWorldHint: false },\n };\n\n return {\n definition,\n run(args) {\n const design = findDesign(catalog, args.slug);\n if (!design) {\n const near = suggestSlugs(catalog, String(args.slug ?? ''));\n return toolError(\n `No design with slug \"${args.slug}\". ` +\n (near.length\n ? `Closest slugs: ${near.join(', ')}. `\n : '') +\n 'Use search_designs to find one - slugs are opaque and cannot be guessed.'\n );\n }\n\n const snippet = (template: string) =>\n template.replaceAll('<slug>', design.slug);\n\n // A design that cannot be vectorized gets a command that works.\n const extension = design.svgExport.supported ? 'svg' : 'png';\n\n return {\n content: [\n json({\n ...design,\n usage: {\n install: catalog.usage.install,\n import: snippet(catalog.usage.import),\n react: reactSnippet(design),\n core: snippet(catalog.usage.core),\n fit: catalog.usage.fit,\n cli: `npx tabbied render ${design.slug} --out ${design.slug}.${extension}`,\n cliSetup: CLI_SETUP,\n },\n // The number-one integration mistake, repeated here because an\n // agent that called get_design may never read llms-full.txt.\n sizing:\n 'A pattern has no intrinsic size - it fills its parent, and ' +\n 'collapses to nothing in a parent that sizes to content. Pass ' +\n 'height or aspectRatio when in doubt.',\n ...(design.svgExport.supported\n ? {}\n : {\n svgExportWarning:\n 'This design cannot be exported as vector SVG. Render it as PNG instead.',\n }),\n }),\n ],\n };\n },\n };\n}\n\n// ---- preview_design --------------------------------------------------------\n\nfunction previewTool(context: ToolContext): Tool | null {\n const { catalog, fetchPreview } = context;\n if (!fetchPreview) return null;\n\n const definition: ToolDefinition = {\n name: 'preview_design',\n title: 'Look at designs',\n description:\n `Return the rendered preview image for up to ${PREVIEW_MAX_SLUGS} designs, ` +\n 'so you can see them rather than infer them from tags. Previews use each ' +\n \"design's authored palette, default options, and a fixed seed. This is the \" +\n 'step that makes a choice reliable - do it before committing to a slug.',\n inputSchema: {\n type: 'object',\n properties: {\n slugs: {\n type: 'array',\n items: { type: 'string', minLength: 1 },\n minItems: 1,\n maxItems: PREVIEW_MAX_SLUGS,\n description: 'Design slugs to look at, e.g. [\"radius\", \"cleat\"].',\n },\n },\n required: ['slugs'],\n additionalProperties: false,\n },\n annotations: { readOnlyHint: true, openWorldHint: true },\n };\n\n return {\n definition,\n async run(args) {\n const slugs = asStringArray(args.slugs);\n if (!slugs) {\n return toolError('Pass \"slugs\" as a non-empty array of design slugs.');\n }\n\n const requested = slugs.slice(0, PREVIEW_MAX_SLUGS);\n const content: ToolContent[] = [];\n let spent = 0;\n let found = 0;\n\n for (const [index, slug] of requested.entries()) {\n const design = findDesign(catalog, slug);\n if (!design) {\n content.push(\n text(`${slug}: no such design. Use search_designs to find valid slugs.`)\n );\n continue;\n }\n found += 1;\n\n if (spent > PREVIEW_BYTE_BUDGET) {\n content.push(\n text(\n `Stopped after ${index} image(s) to stay within a sane response ` +\n `size. Ask again for the rest: ${requested.slice(index).join(', ')}.`\n )\n );\n break;\n }\n\n try {\n const { data, mimeType } = await fetchPreview(design);\n spent += data.length;\n content.push(\n text(\n `${design.slug} - ${design.name}` +\n (design.description ? `: ${design.description}` : '')\n ),\n { type: 'image', data, mimeType }\n );\n } catch (error) {\n content.push(\n text(\n `${design.slug}: preview unavailable (${\n error instanceof Error ? error.message : String(error)\n }). The image is also at ${design.preview}.`\n )\n );\n }\n }\n\n // One bad slug among good ones is a note beside the images; a call in\n // which nothing resolved has failed, and says so.\n return found > 0 ? { content } : { content, isError: true };\n },\n };\n}\n\n// ---- get_docs --------------------------------------------------------------\n\nfunction docsTool(context: ToolContext): Tool | null {\n const { fetchDocs } = context;\n if (!fetchDocs) return null;\n\n return {\n definition: {\n name: 'get_docs',\n title: 'Get the Tabbied reference',\n description:\n 'The complete agent-facing reference (llms-full.txt): entry points, the ' +\n 'React and vanilla APIs, sizing rules that compile but render wrong, ' +\n 'integration recipes, and the share-link URL scheme. Fetch this once ' +\n 'before writing integration code; the per-design tools do not repeat it.',\n inputSchema: { type: 'object', additionalProperties: false },\n annotations: { readOnlyHint: true, openWorldHint: true },\n },\n async run() {\n try {\n return { content: [text(await fetchDocs())] };\n } catch (error) {\n return toolError(\n `Could not load the reference (${\n error instanceof Error ? error.message : String(error)\n }). It is also served at https://tabbied.com/llms-full.txt.`\n );\n }\n },\n };\n}\n\n// ---- assembly --------------------------------------------------------------\n\n/**\n * The catalog-backed tools available in every runtime, template tools\n * included. A host opts into a tool by supplying its fetcher in the one\n * context, so the tool list follows from what the host can resolve.\n */\nexport function catalogTools(context: ToolContext): Tool[] {\n return [\n searchTool(context.catalog),\n getDesignTool(context.catalog),\n previewTool(context),\n docsTool(context),\n ...templateTools(context),\n ].filter((tool): tool is Tool => tool !== null);\n}\n\nexport type Toolset = {\n list(): ToolDefinition[];\n call(name: string, args: Record<string, unknown>): Promise<ToolResult>;\n has(name: string): boolean;\n};\n\n/**\n * Bundle tools into a name lookup. Handler throws become `isError` results\n * rather than JSON-RPC errors: the spec reserves protocol errors for malformed\n * requests and sends execution failures back to the model to retry.\n */\nexport function createToolset(tools: Tool[]): Toolset {\n const byName = new Map(tools.map((tool) => [tool.definition.name, tool]));\n\n return {\n list: () => tools.map((tool) => tool.definition),\n has: (name) => byName.has(name),\n async call(name, args) {\n const tool = byName.get(name);\n if (!tool) {\n return toolError(\n `Unknown tool \"${name}\". Available: ${[...byName.keys()].join(', ')}.`\n );\n }\n try {\n return await tool.run(args ?? {});\n } catch (error) {\n return toolError(\n error instanceof Error ? error.message : String(error)\n );\n }\n },\n };\n}\n"]}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { JsonSchemaType } from '@modelcontextprotocol/server';
|
|
1
|
+
import type { JsonSchemaType, ToolAnnotations } from '@modelcontextprotocol/server';
|
|
2
2
|
/** One design, as it appears in catalog.json. */
|
|
3
3
|
export type CatalogDesign = {
|
|
4
4
|
slug: string;
|
|
@@ -41,6 +41,10 @@ export type Catalog = {
|
|
|
41
41
|
export type TemplateCatalogEntry = {
|
|
42
42
|
slug: string;
|
|
43
43
|
name: string;
|
|
44
|
+
/** The gallery's category, e.g. "Food & drink". Absent from older indexes. */
|
|
45
|
+
category?: string;
|
|
46
|
+
/** One line on what the business is, e.g. "Wood-fire restaurant". */
|
|
47
|
+
topic?: string;
|
|
44
48
|
href: string;
|
|
45
49
|
spec: string;
|
|
46
50
|
palette: string[];
|
|
@@ -109,6 +113,12 @@ export type ToolDefinition = {
|
|
|
109
113
|
* rather than at the first `tools/list`.
|
|
110
114
|
*/
|
|
111
115
|
inputSchema: JsonSchemaType;
|
|
116
|
+
/**
|
|
117
|
+
* Hints a client may show or act on (read-only, reaches the network, writes
|
|
118
|
+
* files). Hints, not guarantees: the spec tells clients not to trust them
|
|
119
|
+
* from an untrusted server, so nothing here relies on them being read.
|
|
120
|
+
*/
|
|
121
|
+
annotations?: ToolAnnotations;
|
|
112
122
|
};
|
|
113
123
|
export type Tool = {
|
|
114
124
|
definition: ToolDefinition;
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["// The shapes this server reads and writes.\
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["// The shapes this server reads and writes.\nimport type { JsonSchemaType, ToolAnnotations } from '@modelcontextprotocol/server';\n\n// The catalog types mirror what packages/tabbied/scripts/codegen.mjs emits into\n// catalog.json. They are structural rather than imported so the server can\n// read a catalog fetched from an older or newer version of the site.\n\n/** One design, as it appears in catalog.json. */\nexport type CatalogDesign = {\n slug: string;\n name: string;\n description?: string;\n tags: string[];\n mood: string[];\n density: string;\n goodFor: string[];\n preview: string;\n palette: string[];\n colors?: unknown;\n options: CatalogOption[];\n /** An aspect-ratio id such as `2:3`, as codegen emits it. */\n defaultAspectRatio?: string;\n svgExport: { supported: boolean; note?: string };\n};\n\nexport type CatalogOption = {\n id: string;\n label: string;\n type: string;\n default: unknown;\n values?: string[];\n min?: number;\n max?: number;\n step?: number;\n svgExportNote?: string;\n};\n\nexport type Catalog = {\n package: string;\n version: string;\n count: number;\n docs: string;\n usage: Record<string, string>;\n designs: CatalogDesign[];\n};\n\n// ---- template sites --------------------------------------------------------\n//\n// Mirrors what scripts/generate-editable.mjs emits into\n// public/editable-catalog.json and public/editable/<slug>.json. Structural\n// rather than imported from `tabbied-templates`, for the same reason as the\n// design catalog.\n\nexport type TemplateCatalogEntry = {\n slug: string;\n name: string;\n /** The gallery's category, e.g. \"Food & drink\". Absent from older indexes. */\n category?: string;\n /** One line on what the business is, e.g. \"Wood-fire restaurant\". */\n topic?: string;\n href: string;\n spec: string;\n palette: string[];\n patterns: string[];\n slots: { text: number; image: number; pattern: number };\n downloads: { html: string; react: string };\n};\n\nexport type TemplateCatalog = {\n specVersion: number;\n generated: number;\n templates: TemplateCatalogEntry[];\n};\n\n/** One site's editable-section spec. Slots stay opaque here - the tool passes\n * them through, and their shape is owned by `tabbied-templates`. */\nexport type TemplateSpec = {\n specVersion: number;\n site: { slug: string; name: string; topic?: string };\n palette: { colors: string[]; derivation: string; flatSections?: boolean };\n fonts?: Record<string, string>;\n slots: unknown[];\n};\n\n// ---- tools -----------------------------------------------------------------\n\n/**\n * A content block in a tool result. This is the subset of MCP's content types\n * the Tabbied tools actually produce; the shape is identical in both protocol\n * eras (see docs/mcp-server.md).\n */\nexport type ToolContent =\n | { type: 'text'; text: string }\n | { type: 'image'; data: string; mimeType: string };\n\nexport type ToolResult = {\n content: ToolContent[];\n /**\n * A *tool execution* error (bad slug, unrenderable design), not a JSON-RPC\n * protocol error: the spec asks clients to feed these back to the model so\n * it can self-correct.\n */\n isError?: boolean;\n};\n\nexport type ToolDefinition = {\n name: string;\n title: string;\n description: string;\n /**\n * Plain JSON Schema, not Zod (see server.ts). Typed as the SDK's own type\n * (a type-only import) so a schema the SDK cannot register fails at `tsc`\n * rather than at the first `tools/list`.\n */\n inputSchema: JsonSchemaType;\n /**\n * Hints a client may show or act on (read-only, reaches the network, writes\n * files). Hints, not guarantees: the spec tells clients not to trust them\n * from an untrusted server, so nothing here relies on them being read.\n */\n annotations?: ToolAnnotations;\n};\n\nexport type Tool = {\n definition: ToolDefinition;\n run(args: Record<string, unknown>): ToolResult | Promise<ToolResult>;\n};\n\n/**\n * Everything the catalog tools need from their host. The fetchers are injected\n * rather than imported because they differ per runtime: the Worker reads its\n * own static assets, the stdio server the local package and the network.\n */\nexport type ToolContext = {\n catalog: Catalog;\n /** Resolves a design's preview image to base64. Omit to drop `preview_design`. */\n fetchPreview?: (\n design: CatalogDesign\n ) => Promise<{ data: string; mimeType: string }>;\n /** Resolves the llms-full.txt reference. Omit to drop `get_docs`. */\n fetchDocs?: () => Promise<string>;\n /** Resolves the editable-template index. Omit to drop both template tools. */\n fetchTemplateCatalog?: () => Promise<TemplateCatalog>;\n /** Resolves one template's spec. Omit (with the above) to drop `get_template`. */\n fetchTemplate?: (slug: string) => Promise<TemplateSpec>;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,55 +1,61 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "tabbied-mcp",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "MCP server for Tabbied: search, look at, and render its generative pattern designs from any MCP client.",
|
|
5
|
-
"type": "module",
|
|
6
|
-
"sideEffects": false,
|
|
7
|
-
"license": "MIT",
|
|
8
|
-
"author": "Sy Hong and Ye Joo Park",
|
|
9
|
-
"homepage": "https://tabbied.com",
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "git+https://github.com/tabbied-design/tabbied.git",
|
|
13
|
-
"directory": "packages/tabbied-mcp"
|
|
14
|
-
},
|
|
15
|
-
"keywords": [
|
|
16
|
-
"mcp",
|
|
17
|
-
"model-context-protocol",
|
|
18
|
-
"tabbied",
|
|
19
|
-
"generative-art",
|
|
20
|
-
"pattern",
|
|
21
|
-
"css-doodle"
|
|
22
|
-
],
|
|
23
|
-
"exports": {
|
|
24
|
-
".": {
|
|
25
|
-
"types": "./dist/index.d.ts",
|
|
26
|
-
"import": "./dist/index.js",
|
|
27
|
-
"default": "./dist/index.js"
|
|
28
|
-
},
|
|
29
|
-
"./
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
},
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
"
|
|
43
|
-
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
1
|
+
{
|
|
2
|
+
"name": "tabbied-mcp",
|
|
3
|
+
"version": "0.2.4",
|
|
4
|
+
"description": "MCP server for Tabbied: search, look at, and render its generative pattern designs from any MCP client.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"author": "Sy Hong and Ye Joo Park",
|
|
9
|
+
"homepage": "https://tabbied.com/docs/mcp/",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "git+https://github.com/tabbied-design/tabbied.git",
|
|
13
|
+
"directory": "packages/tabbied-mcp"
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"mcp",
|
|
17
|
+
"model-context-protocol",
|
|
18
|
+
"tabbied",
|
|
19
|
+
"generative-art",
|
|
20
|
+
"pattern",
|
|
21
|
+
"css-doodle"
|
|
22
|
+
],
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"import": "./dist/index.js",
|
|
27
|
+
"default": "./dist/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./node": {
|
|
30
|
+
"types": "./dist/node/index.d.ts",
|
|
31
|
+
"import": "./dist/node/index.js",
|
|
32
|
+
"default": "./dist/node/index.js"
|
|
33
|
+
},
|
|
34
|
+
"./package.json": "./package.json"
|
|
35
|
+
},
|
|
36
|
+
"main": "./dist/index.js",
|
|
37
|
+
"types": "./dist/index.d.ts",
|
|
38
|
+
"bin": {
|
|
39
|
+
"tabbied-mcp": "dist/stdio.js"
|
|
40
|
+
},
|
|
41
|
+
"files": [
|
|
42
|
+
"dist"
|
|
43
|
+
],
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "node -e \"fs.rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.json",
|
|
46
|
+
"test": "node --test",
|
|
47
|
+
"sync-version": "node scripts/sync-version.mjs",
|
|
48
|
+
"typecheck": "tsc -p tsconfig.json --noEmit"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@modelcontextprotocol/server": "^2.2.0",
|
|
52
|
+
"tabbied": "^0.8.0"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@types/node": "^26.6.3",
|
|
56
|
+
"typescript": "^7.0.2"
|
|
57
|
+
},
|
|
58
|
+
"engines": {
|
|
59
|
+
"node": ">=20"
|
|
60
|
+
}
|
|
61
|
+
}
|