@wordpress/design-system-mcp 0.1.2-next.v.202604201441.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.
Files changed (46) hide show
  1. package/LICENSE.md +788 -0
  2. package/README.md +47 -0
  3. package/bin/design-system-mcp.mjs +9 -0
  4. package/build-module/data.mjs +61 -0
  5. package/build-module/data.mjs.map +7 -0
  6. package/build-module/format.mjs +60 -0
  7. package/build-module/format.mjs.map +7 -0
  8. package/build-module/index.mjs +15 -0
  9. package/build-module/index.mjs.map +7 -0
  10. package/build-module/parse-components.mjs +96 -0
  11. package/build-module/parse-components.mjs.map +7 -0
  12. package/build-module/tools/get-component-details.mjs +45 -0
  13. package/build-module/tools/get-component-details.mjs.map +7 -0
  14. package/build-module/tools/get-components.mjs +30 -0
  15. package/build-module/tools/get-components.mjs.map +7 -0
  16. package/build-module/tools/get-design-tokens.mjs +29 -0
  17. package/build-module/tools/get-design-tokens.mjs.map +7 -0
  18. package/build-module/tools/index.mjs +13 -0
  19. package/build-module/tools/index.mjs.map +7 -0
  20. package/build-module/types.mjs +1 -0
  21. package/build-module/types.mjs.map +7 -0
  22. package/build-types/data.d.ts +27 -0
  23. package/build-types/data.d.ts.map +1 -0
  24. package/build-types/format.d.ts +16 -0
  25. package/build-types/format.d.ts.map +1 -0
  26. package/build-types/index.d.ts +3 -0
  27. package/build-types/index.d.ts.map +1 -0
  28. package/build-types/parse-components.d.ts +55 -0
  29. package/build-types/parse-components.d.ts.map +1 -0
  30. package/build-types/test/data.d.ts +2 -0
  31. package/build-types/test/data.d.ts.map +1 -0
  32. package/build-types/test/format.d.ts +2 -0
  33. package/build-types/test/format.d.ts.map +1 -0
  34. package/build-types/test/parse-components.d.ts +2 -0
  35. package/build-types/test/parse-components.d.ts.map +1 -0
  36. package/build-types/tools/get-component-details.d.ts +8 -0
  37. package/build-types/tools/get-component-details.d.ts.map +1 -0
  38. package/build-types/tools/get-components.d.ts +8 -0
  39. package/build-types/tools/get-components.d.ts.map +1 -0
  40. package/build-types/tools/get-design-tokens.d.ts +8 -0
  41. package/build-types/tools/get-design-tokens.d.ts.map +1 -0
  42. package/build-types/tools/index.d.ts +8 -0
  43. package/build-types/tools/index.d.ts.map +1 -0
  44. package/build-types/types.d.ts +51 -0
  45. package/build-types/types.d.ts.map +1 -0
  46. package/package.json +55 -0
package/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # WordPress Design System MCP
2
+
3
+ <div class="callout callout-alert">
4
+ This package is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
5
+ </div>
6
+
7
+ An [MCP (Model Context Protocol)](https://modelcontextprotocol.io/) server for the WordPress Design System. Provides AI coding agents with component documentation, prop definitions, usage examples, and design tokens.
8
+
9
+ ## Setup
10
+
11
+ ### Claude Code
12
+
13
+ ```bash
14
+ claude mcp add wordpress-design-system -- npx -y --ignore-scripts --min-release-age=2 @wordpress/design-system-mcp@latest
15
+ ```
16
+
17
+ ### Cursor
18
+
19
+ [![Install MCP Server](https://cursor.com/deeplink/mcp-install-dark.svg)](https://cursor.com/en-US/install-mcp?name=wordpress-design-system&config=eyJjb21tYW5kIjoibnB4IC15IC0taWdub3JlLXNjcmlwdHMgLS1taW4tcmVsZWFzZS1hZ2U9MiBAd29yZHByZXNzL2Rlc2lnbi1zeXN0ZW0tbWNwQGxhdGVzdCJ9)
20
+
21
+ Install link: [cursor://anysphere.cursor-deeplink/mcp/install?name=wordpress-design-system&config=eyJjb21tYW5kIjoibnB4IC15IC0taWdub3JlLXNjcmlwdHMgLS1taW4tcmVsZWFzZS1hZ2U9MiBAd29yZHByZXNzL2Rlc2lnbi1zeXN0ZW0tbWNwQGxhdGVzdCJ9](cursor://anysphere.cursor-deeplink/mcp/install?name=wordpress-design-system&config=eyJjb21tYW5kIjoibnB4IC15IC0taWdub3JlLXNjcmlwdHMgLS1taW4tcmVsZWFzZS1hZ2U9MiBAd29yZHByZXNzL2Rlc2lnbi1zeXN0ZW0tbWNwQGxhdGVzdCJ9)
22
+
23
+ ### Other (Claude Desktop, VS Code)
24
+
25
+ Add to your MCP client configuration (`mcp.json` or equivalent):
26
+
27
+ ```json
28
+ {
29
+ "mcpServers": {
30
+ "wordpress-design-system": {
31
+ "command": "npx",
32
+ "args": [
33
+ "-y",
34
+ "--ignore-scripts",
35
+ "--min-release-age=2",
36
+ "@wordpress/design-system-mcp@latest"
37
+ ]
38
+ }
39
+ }
40
+ }
41
+ ```
42
+
43
+ ## Contributing to this package
44
+
45
+ This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to [npm](https://www.npmjs.com/org/wordpress) and used by [WordPress](https://make.wordpress.org/core/) as well as by the broader JavaScript ecosystem.
46
+
47
+ To find out more about contributing to this package or Gutenberg as a whole, please read the project's main [contributor guide](https://github.com/WordPress/gutenberg/tree/HEAD/CONTRIBUTING.md).
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env node
2
+
3
+ import { StdioServerTransport } from '@modelcontextprotocol/server';
4
+ import { createServer } from '@wordpress/design-system-mcp';
5
+
6
+ const transport = new StdioServerTransport();
7
+ const server = createServer();
8
+
9
+ await server.connect( transport );
@@ -0,0 +1,61 @@
1
+ // packages/design-system-mcp/src/data.ts
2
+ import {
3
+ packageNameFromPath,
4
+ parseComponents,
5
+ parseComponentDetail
6
+ } from "./parse-components.mjs";
7
+ var COMPONENTS_MANIFEST_URL = process.env.COMPONENTS_MANIFEST_URL || "https://wordpress.github.io/gutenberg/manifests/components.json";
8
+ var DESIGN_TOKENS_URL = process.env.DESIGN_TOKENS_URL || "https://raw.githubusercontent.com/WordPress/gutenberg/refs/heads/trunk/packages/theme/docs/tokens.md";
9
+ var cachedComponents = null;
10
+ var cachedTokens = null;
11
+ function resetCache() {
12
+ cachedComponents = null;
13
+ cachedTokens = null;
14
+ }
15
+ async function fetchComponents() {
16
+ if (cachedComponents) {
17
+ return cachedComponents;
18
+ }
19
+ const response = await fetch(COMPONENTS_MANIFEST_URL);
20
+ if (!response.ok) {
21
+ throw new Error(
22
+ `Failed to fetch components manifest: ${response.status} ${response.statusText}`
23
+ );
24
+ }
25
+ const manifest = await response.json();
26
+ const filtered = {};
27
+ for (const [key, component] of Object.entries(manifest.components)) {
28
+ if (packageNameFromPath(component.path)) {
29
+ filtered[key] = component;
30
+ }
31
+ }
32
+ cachedComponents = filtered;
33
+ return cachedComponents;
34
+ }
35
+ async function getComponents() {
36
+ const components = await fetchComponents();
37
+ return parseComponents(components);
38
+ }
39
+ async function getComponentDetail(name) {
40
+ const components = await fetchComponents();
41
+ return parseComponentDetail(components, name);
42
+ }
43
+ async function getDesignTokens() {
44
+ if (!cachedTokens) {
45
+ const response = await fetch(DESIGN_TOKENS_URL);
46
+ if (!response.ok) {
47
+ throw new Error(
48
+ `Failed to fetch design tokens: ${response.status} ${response.statusText}`
49
+ );
50
+ }
51
+ cachedTokens = await response.text();
52
+ }
53
+ return { content: cachedTokens };
54
+ }
55
+ export {
56
+ getComponentDetail,
57
+ getComponents,
58
+ getDesignTokens,
59
+ resetCache
60
+ };
61
+ //# sourceMappingURL=data.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/data.ts"],
4
+ "sourcesContent": ["import {\n\tpackageNameFromPath,\n\tparseComponents,\n\tparseComponentDetail,\n} from './parse-components';\nimport type { Component, ComponentDetail, ManifestComponent } from './types';\n\nconst COMPONENTS_MANIFEST_URL =\n\tprocess.env.COMPONENTS_MANIFEST_URL ||\n\t'https://wordpress.github.io/gutenberg/manifests/components.json';\n\nconst DESIGN_TOKENS_URL =\n\tprocess.env.DESIGN_TOKENS_URL ||\n\t'https://raw.githubusercontent.com/WordPress/gutenberg/refs/heads/trunk/packages/theme/docs/tokens.md';\n\nlet cachedComponents: Record< string, ManifestComponent > | null = null;\nlet cachedTokens: string | null = null;\n\n/**\n * Clear cached data. Intended for testing.\n */\nexport function resetCache(): void {\n\tcachedComponents = null;\n\tcachedTokens = null;\n}\n\n/**\n * Fetch and cache the components from the Storybook manifest, filtered to only\n * components from allowed packages.\n *\n * @return The filtered components record.\n */\nasync function fetchComponents(): Promise<\n\tRecord< string, ManifestComponent >\n> {\n\tif ( cachedComponents ) {\n\t\treturn cachedComponents;\n\t}\n\n\tconst response = await fetch( COMPONENTS_MANIFEST_URL );\n\tif ( ! response.ok ) {\n\t\tthrow new Error(\n\t\t\t`Failed to fetch components manifest: ${ response.status } ${ response.statusText }`\n\t\t);\n\t}\n\n\tconst manifest: {\n\t\tv: number;\n\t\tcomponents: Record< string, ManifestComponent >;\n\t} = await response.json();\n\n\tconst filtered: Record< string, ManifestComponent > = {};\n\tfor ( const [ key, component ] of Object.entries( manifest.components ) ) {\n\t\tif ( packageNameFromPath( component.path ) ) {\n\t\t\tfiltered[ key ] = component;\n\t\t}\n\t}\n\n\tcachedComponents = filtered;\n\treturn cachedComponents;\n}\n\n/**\n * Get all components from allowed packages.\n *\n * @return Parsed component list.\n */\nexport async function getComponents(): Promise< Component[] > {\n\tconst components = await fetchComponents();\n\treturn parseComponents( components );\n}\n\n/**\n * Get detailed documentation for a single component by name.\n *\n * @param name - The component name (case-insensitive).\n * @return The component detail, or null if not found.\n */\nexport async function getComponentDetail(\n\tname: string\n): Promise< ComponentDetail | null > {\n\tconst components = await fetchComponents();\n\treturn parseComponentDetail( components, name );\n}\n\n/**\n * Get the design tokens reference document as markdown.\n *\n * @return The tokens markdown content.\n */\nexport async function getDesignTokens(): Promise< { content: string } > {\n\tif ( ! cachedTokens ) {\n\t\tconst response = await fetch( DESIGN_TOKENS_URL );\n\t\tif ( ! response.ok ) {\n\t\t\tthrow new Error(\n\t\t\t\t`Failed to fetch design tokens: ${ response.status } ${ response.statusText }`\n\t\t\t);\n\t\t}\n\n\t\tcachedTokens = await response.text();\n\t}\n\n\treturn { content: cachedTokens };\n}\n"],
5
+ "mappings": ";AAAA;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAGP,IAAM,0BACL,QAAQ,IAAI,2BACZ;AAED,IAAM,oBACL,QAAQ,IAAI,qBACZ;AAED,IAAI,mBAA+D;AACnE,IAAI,eAA8B;AAK3B,SAAS,aAAmB;AAClC,qBAAmB;AACnB,iBAAe;AAChB;AAQA,eAAe,kBAEb;AACD,MAAK,kBAAmB;AACvB,WAAO;AAAA,EACR;AAEA,QAAM,WAAW,MAAM,MAAO,uBAAwB;AACtD,MAAK,CAAE,SAAS,IAAK;AACpB,UAAM,IAAI;AAAA,MACT,wCAAyC,SAAS,MAAO,IAAK,SAAS,UAAW;AAAA,IACnF;AAAA,EACD;AAEA,QAAM,WAGF,MAAM,SAAS,KAAK;AAExB,QAAM,WAAgD,CAAC;AACvD,aAAY,CAAE,KAAK,SAAU,KAAK,OAAO,QAAS,SAAS,UAAW,GAAI;AACzE,QAAK,oBAAqB,UAAU,IAAK,GAAI;AAC5C,eAAU,GAAI,IAAI;AAAA,IACnB;AAAA,EACD;AAEA,qBAAmB;AACnB,SAAO;AACR;AAOA,eAAsB,gBAAwC;AAC7D,QAAM,aAAa,MAAM,gBAAgB;AACzC,SAAO,gBAAiB,UAAW;AACpC;AAQA,eAAsB,mBACrB,MACoC;AACpC,QAAM,aAAa,MAAM,gBAAgB;AACzC,SAAO,qBAAsB,YAAY,IAAK;AAC/C;AAOA,eAAsB,kBAAkD;AACvE,MAAK,CAAE,cAAe;AACrB,UAAM,WAAW,MAAM,MAAO,iBAAkB;AAChD,QAAK,CAAE,SAAS,IAAK;AACpB,YAAM,IAAI;AAAA,QACT,kCAAmC,SAAS,MAAO,IAAK,SAAS,UAAW;AAAA,MAC7E;AAAA,IACD;AAEA,mBAAe,MAAM,SAAS,KAAK;AAAA,EACpC;AAEA,SAAO,EAAE,SAAS,aAAa;AAChC;",
6
+ "names": []
7
+ }
@@ -0,0 +1,60 @@
1
+ // packages/design-system-mcp/src/format.ts
2
+ function formatComponentSummary(component, headingLevel) {
3
+ const heading = "#".repeat(headingLevel);
4
+ const lines = [`${heading} ${component.name}`];
5
+ if (component.description) {
6
+ lines.push("", component.description);
7
+ }
8
+ return lines;
9
+ }
10
+ function formatComponents(components) {
11
+ const lines = ["# WordPress Design System Components"];
12
+ for (const component of components) {
13
+ lines.push("", ...formatComponentSummary(component, 2));
14
+ }
15
+ return lines.join("\n");
16
+ }
17
+ function formatComponentDetail(detail) {
18
+ const lines = formatComponentSummary(detail, 1);
19
+ lines.push("", `**Package:** \`${detail.packageName}\``);
20
+ if (detail.importStatement) {
21
+ lines.push(
22
+ "",
23
+ "## Import",
24
+ "",
25
+ "```ts",
26
+ detail.importStatement,
27
+ "```"
28
+ );
29
+ }
30
+ if (detail.props.length > 0) {
31
+ lines.push("", "## Props", "");
32
+ for (const prop of detail.props) {
33
+ const required = prop.required ? " **(required)**" : "";
34
+ const defaultNote = prop.defaultValue ? ` (default: \`${prop.defaultValue}\`)` : "";
35
+ lines.push(
36
+ `### \`${prop.name}\`: \`${prop.type}\`${required}${defaultNote}`,
37
+ ""
38
+ );
39
+ if (prop.description) {
40
+ lines.push(prop.description, "");
41
+ }
42
+ }
43
+ }
44
+ if (detail.stories.length > 0) {
45
+ lines.push("", "## Examples", "");
46
+ for (const story of detail.stories) {
47
+ lines.push(`### ${story.name}`);
48
+ if (story.snippet) {
49
+ lines.push("", "```tsx", story.snippet, "```");
50
+ }
51
+ lines.push("");
52
+ }
53
+ }
54
+ return lines.join("\n");
55
+ }
56
+ export {
57
+ formatComponentDetail,
58
+ formatComponents
59
+ };
60
+ //# sourceMappingURL=format.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/format.ts"],
4
+ "sourcesContent": ["import type { Component, ComponentDetail } from './types';\n\n/**\n * Format a component's name, package, and description as markdown.\n *\n * @param component - The component to format.\n * @param headingLevel - The heading level for the component name.\n * @return Markdown lines.\n */\nfunction formatComponentSummary(\n\tcomponent: Component,\n\theadingLevel: number\n): string[] {\n\tconst heading = '#'.repeat( headingLevel );\n\tconst lines = [ `${ heading } ${ component.name }` ];\n\n\tif ( component.description ) {\n\t\tlines.push( '', component.description );\n\t}\n\n\treturn lines;\n}\n\n/**\n * Format the component list as markdown.\n *\n * @param components - The components to format.\n * @return Formatted markdown.\n */\nexport function formatComponents( components: Component[] ): string {\n\tconst lines = [ '# WordPress Design System Components' ];\n\n\tfor ( const component of components ) {\n\t\tlines.push( '', ...formatComponentSummary( component, 2 ) );\n\t}\n\n\treturn lines.join( '\\n' );\n}\n\n/**\n * Format a single component's detail as markdown documentation.\n *\n * @param detail - The component detail to format.\n * @return Formatted markdown.\n */\nexport function formatComponentDetail( detail: ComponentDetail ): string {\n\tconst lines = formatComponentSummary( detail, 1 );\n\n\tlines.push( '', `**Package:** \\`${ detail.packageName }\\`` );\n\n\tif ( detail.importStatement ) {\n\t\tlines.push(\n\t\t\t'',\n\t\t\t'## Import',\n\t\t\t'',\n\t\t\t'```ts',\n\t\t\tdetail.importStatement,\n\t\t\t'```'\n\t\t);\n\t}\n\n\tif ( detail.props.length > 0 ) {\n\t\tlines.push( '', '## Props', '' );\n\t\tfor ( const prop of detail.props ) {\n\t\t\tconst required = prop.required ? ' **(required)**' : '';\n\t\t\tconst defaultNote = prop.defaultValue\n\t\t\t\t? ` (default: \\`${ prop.defaultValue }\\`)`\n\t\t\t\t: '';\n\t\t\tlines.push(\n\t\t\t\t`### \\`${ prop.name }\\`: \\`${ prop.type }\\`${ required }${ defaultNote }`,\n\t\t\t\t''\n\t\t\t);\n\t\t\tif ( prop.description ) {\n\t\t\t\tlines.push( prop.description, '' );\n\t\t\t}\n\t\t}\n\t}\n\n\tif ( detail.stories.length > 0 ) {\n\t\tlines.push( '', '## Examples', '' );\n\t\tfor ( const story of detail.stories ) {\n\t\t\tlines.push( `### ${ story.name }` );\n\t\t\tif ( story.snippet ) {\n\t\t\t\tlines.push( '', '```tsx', story.snippet, '```' );\n\t\t\t}\n\t\t\tlines.push( '' );\n\t\t}\n\t}\n\n\treturn lines.join( '\\n' );\n}\n"],
5
+ "mappings": ";AASA,SAAS,uBACR,WACA,cACW;AACX,QAAM,UAAU,IAAI,OAAQ,YAAa;AACzC,QAAM,QAAQ,CAAE,GAAI,OAAQ,IAAK,UAAU,IAAK,EAAG;AAEnD,MAAK,UAAU,aAAc;AAC5B,UAAM,KAAM,IAAI,UAAU,WAAY;AAAA,EACvC;AAEA,SAAO;AACR;AAQO,SAAS,iBAAkB,YAAkC;AACnE,QAAM,QAAQ,CAAE,sCAAuC;AAEvD,aAAY,aAAa,YAAa;AACrC,UAAM,KAAM,IAAI,GAAG,uBAAwB,WAAW,CAAE,CAAE;AAAA,EAC3D;AAEA,SAAO,MAAM,KAAM,IAAK;AACzB;AAQO,SAAS,sBAAuB,QAAkC;AACxE,QAAM,QAAQ,uBAAwB,QAAQ,CAAE;AAEhD,QAAM,KAAM,IAAI,kBAAmB,OAAO,WAAY,IAAK;AAE3D,MAAK,OAAO,iBAAkB;AAC7B,UAAM;AAAA,MACL;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA,MACA,OAAO;AAAA,MACP;AAAA,IACD;AAAA,EACD;AAEA,MAAK,OAAO,MAAM,SAAS,GAAI;AAC9B,UAAM,KAAM,IAAI,YAAY,EAAG;AAC/B,eAAY,QAAQ,OAAO,OAAQ;AAClC,YAAM,WAAW,KAAK,WAAW,oBAAoB;AACrD,YAAM,cAAc,KAAK,eACtB,gBAAiB,KAAK,YAAa,QACnC;AACH,YAAM;AAAA,QACL,SAAU,KAAK,IAAK,SAAU,KAAK,IAAK,KAAM,QAAS,GAAI,WAAY;AAAA,QACvE;AAAA,MACD;AACA,UAAK,KAAK,aAAc;AACvB,cAAM,KAAM,KAAK,aAAa,EAAG;AAAA,MAClC;AAAA,IACD;AAAA,EACD;AAEA,MAAK,OAAO,QAAQ,SAAS,GAAI;AAChC,UAAM,KAAM,IAAI,eAAe,EAAG;AAClC,eAAY,SAAS,OAAO,SAAU;AACrC,YAAM,KAAM,OAAQ,MAAM,IAAK,EAAG;AAClC,UAAK,MAAM,SAAU;AACpB,cAAM,KAAM,IAAI,UAAU,MAAM,SAAS,KAAM;AAAA,MAChD;AACA,YAAM,KAAM,EAAG;AAAA,IAChB;AAAA,EACD;AAEA,SAAO,MAAM,KAAM,IAAK;AACzB;",
6
+ "names": []
7
+ }
@@ -0,0 +1,15 @@
1
+ // packages/design-system-mcp/src/index.ts
2
+ import { McpServer } from "@modelcontextprotocol/server";
3
+ import { registerTools } from "./tools/index.mjs";
4
+ function createServer() {
5
+ const server = new McpServer({
6
+ name: "WordPress Design System",
7
+ version: "0.1.0"
8
+ });
9
+ registerTools(server);
10
+ return server;
11
+ }
12
+ export {
13
+ createServer
14
+ };
15
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/index.ts"],
4
+ "sourcesContent": ["import { McpServer } from '@modelcontextprotocol/server';\nimport { registerTools } from './tools/index';\n\nexport function createServer() {\n\tconst server = new McpServer( {\n\t\tname: 'WordPress Design System',\n\t\tversion: '0.1.0',\n\t} );\n\n\tregisterTools( server );\n\n\treturn server;\n}\n"],
5
+ "mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAEvB,SAAS,eAAe;AAC9B,QAAM,SAAS,IAAI,UAAW;AAAA,IAC7B,MAAM;AAAA,IACN,SAAS;AAAA,EACV,CAAE;AAEF,gBAAe,MAAO;AAEtB,SAAO;AACR;",
6
+ "names": []
7
+ }
@@ -0,0 +1,96 @@
1
+ // packages/design-system-mcp/src/parse-components.ts
2
+ var EXPORT_ALIASES = {
3
+ "@wordpress/components:ConfirmDialog": "__experimentalConfirmDialog",
4
+ "@wordpress/components:InputControl": "__experimentalInputControl",
5
+ "@wordpress/components:ItemGroup": "__experimentalItemGroup",
6
+ "@wordpress/components:ToggleGroupControl": "__experimentalToggleGroupControl",
7
+ "@wordpress/components:TreeGrid": "__experimentalTreeGrid",
8
+ "@wordpress/components:Truncate": "__experimentalTruncate"
9
+ };
10
+ function buildImportStatement(name, packageName) {
11
+ const exported = EXPORT_ALIASES[`${packageName}:${name}`];
12
+ return exported ? `import { ${exported} as ${name} } from '${packageName}';` : `import { ${name} } from '${packageName}';`;
13
+ }
14
+ function packageNameFromPath(storyPath) {
15
+ const match = storyPath.match(/\.\.\/packages\/([^/]+)\//);
16
+ return match ? `@wordpress/${match[1]}` : null;
17
+ }
18
+ function canonicalComponentName(name) {
19
+ return name.split(".", 1)[0];
20
+ }
21
+ function parseProps(rawProps) {
22
+ return Object.entries(rawProps).filter(([, propInfo]) => {
23
+ const description = (propInfo.description || "").toLowerCase();
24
+ return !description.includes("@deprecated") && !description.includes("@ignore");
25
+ }).map(([propName, propInfo]) => ({
26
+ name: propName,
27
+ // Prefer `raw` when present, as it carries the source-authored type
28
+ // expression a consumer could use directly. Primitives emit only
29
+ // `name`, so fall back if `raw` is not present.
30
+ type: propInfo.tsType?.raw || propInfo.tsType?.name || "unknown",
31
+ required: propInfo.required || false,
32
+ description: propInfo.description || "",
33
+ defaultValue: propInfo.defaultValue?.value ?? null
34
+ }));
35
+ }
36
+ function parseComponents(components) {
37
+ const byKey = /* @__PURE__ */ new Map();
38
+ for (const component of Object.values(components)) {
39
+ const packageName = packageNameFromPath(component.path);
40
+ if (!packageName) {
41
+ continue;
42
+ }
43
+ const name = canonicalComponentName(component.name);
44
+ const key = `${packageName}:${name}`;
45
+ const existing = byKey.get(key);
46
+ const description = component.description || "";
47
+ if (!existing) {
48
+ byKey.set(key, { name, description, packageName });
49
+ } else {
50
+ existing.description ||= description;
51
+ }
52
+ }
53
+ return Array.from(byKey.values()).sort(
54
+ (a, b) => a.name.localeCompare(b.name)
55
+ );
56
+ }
57
+ function parseComponentDetail(components, name) {
58
+ let detail = null;
59
+ for (const component of Object.values(components)) {
60
+ const canonicalName = canonicalComponentName(component.name);
61
+ if (canonicalName.toLowerCase() !== name.toLowerCase()) {
62
+ continue;
63
+ }
64
+ const pkg = packageNameFromPath(component.path);
65
+ if (!pkg) {
66
+ continue;
67
+ }
68
+ const description = component.description || "";
69
+ const props = parseProps(component.reactDocgen?.props || {});
70
+ const stories = component.stories || [];
71
+ if (!detail) {
72
+ detail = {
73
+ name: canonicalName,
74
+ description,
75
+ packageName: pkg,
76
+ importStatement: buildImportStatement(canonicalName, pkg),
77
+ props,
78
+ stories: [...stories]
79
+ };
80
+ } else if (detail.packageName === pkg) {
81
+ detail.description ||= description;
82
+ if (detail.props.length === 0) {
83
+ detail.props = props;
84
+ }
85
+ detail.stories.push(...stories);
86
+ }
87
+ }
88
+ return detail;
89
+ }
90
+ export {
91
+ packageNameFromPath,
92
+ parseComponentDetail,
93
+ parseComponents,
94
+ parseProps
95
+ };
96
+ //# sourceMappingURL=parse-components.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/parse-components.ts"],
4
+ "sourcesContent": ["import type {\n\tComponent,\n\tComponentDetail,\n\tComponentProp,\n\tManifestComponent,\n} from './types';\n\n/**\n * Mapping of canonical name to actual exported identifier, keyed by\n * `package:name`. A package's actual exported identifier may be different from\n * the canonical name in the internal implementation that's known to Storybook.\n *\n * Ideally we could derive this from the package's source code, but MCP\n * consumers aren't guaranteed to have these packages installed. Since this\n * is a legacy convention, we expect this list will only ever shrink over time\n * and can eventually be removed.\n */\nconst EXPORT_ALIASES: Record< string, string > = {\n\t'@wordpress/components:ConfirmDialog': '__experimentalConfirmDialog',\n\t'@wordpress/components:InputControl': '__experimentalInputControl',\n\t'@wordpress/components:ItemGroup': '__experimentalItemGroup',\n\t'@wordpress/components:ToggleGroupControl':\n\t\t'__experimentalToggleGroupControl',\n\t'@wordpress/components:TreeGrid': '__experimentalTreeGrid',\n\t'@wordpress/components:Truncate': '__experimentalTruncate',\n};\n\n/**\n * Build the import statement a consumer should use to bring a component into\n * scope under its canonical name. For aliased components, emit an `as` rename\n * so that subsequent code samples (which reference the canonical name) resolve\n * against the actual export.\n *\n * @param name - The canonical component name.\n * @param packageName - The npm package name.\n * @return The import statement as a single-line string.\n */\nfunction buildImportStatement( name: string, packageName: string ): string {\n\tconst exported = EXPORT_ALIASES[ `${ packageName }:${ name }` ];\n\treturn exported\n\t\t? `import { ${ exported } as ${ name } } from '${ packageName }';`\n\t\t: `import { ${ name } } from '${ packageName }';`;\n}\n\n/**\n * Derive the npm package name from the story file path.\n *\n * Manifest paths look like `../packages/<dir>/src/.../index.story.tsx`. We\n * extract `<dir>` and prepend the `@wordpress/` npm namespace. Curation of\n * which components appear in the manifest is handled upstream via Storybook\n * tags, so this only needs to recognize package-shaped paths.\n *\n * @param storyPath - The story file path from the manifest.\n * @return The npm package name, or null for paths outside `packages/*`.\n */\nexport function packageNameFromPath( storyPath: string ): string | null {\n\tconst match = storyPath.match( /\\.\\.\\/packages\\/([^/]+)\\// );\n\treturn match ? `@wordpress/${ match[ 1 ] }` : null;\n}\n\n/**\n * For components exported as a namespace (e.g. `AlertDialog`, with members\n * `AlertDialog.Root`, `AlertDialog.Trigger`, etc.), the manifest lists the\n * primary entry under a dotted name like `AlertDialog.Root`. The canonical\n * name we expose is the top-level identifier a consumer actually imports,\n * which is the portion before the first dot. For simple components (e.g.\n * `Button`), this is a no-op.\n *\n * @param name - The component name from the manifest.\n * @return The top-level importable identifier.\n */\nfunction canonicalComponentName( name: string ): string {\n\treturn name.split( '.', 1 )[ 0 ];\n}\n\n/**\n * Parse props from a component's reactDocgen data, filtering out\n * deprecated and ignored props.\n *\n * @param rawProps - The reactDocgen props record.\n * @return Parsed props with deprecated entries removed.\n */\nexport function parseProps(\n\trawProps: Record<\n\t\tstring,\n\t\t{\n\t\t\trequired?: boolean;\n\t\t\ttsType?: { name: string; raw?: string };\n\t\t\tdescription?: string;\n\t\t\tdefaultValue?: { value: string };\n\t\t}\n\t>\n): ComponentProp[] {\n\treturn Object.entries( rawProps )\n\t\t.filter( ( [ , propInfo ] ) => {\n\t\t\tconst description = ( propInfo.description || '' ).toLowerCase();\n\t\t\treturn (\n\t\t\t\t! description.includes( '@deprecated' ) &&\n\t\t\t\t! description.includes( '@ignore' )\n\t\t\t);\n\t\t} )\n\t\t.map( ( [ propName, propInfo ] ) => ( {\n\t\t\tname: propName,\n\t\t\t// Prefer `raw` when present, as it carries the source-authored type\n\t\t\t// expression a consumer could use directly. Primitives emit only\n\t\t\t// `name`, so fall back if `raw` is not present.\n\t\t\ttype: propInfo.tsType?.raw || propInfo.tsType?.name || 'unknown',\n\t\t\trequired: propInfo.required || false,\n\t\t\tdescription: propInfo.description || '',\n\t\t\tdefaultValue: propInfo.defaultValue?.value ?? null,\n\t\t} ) );\n}\n\n/**\n * Parse manifest components into a flat list sorted alphabetically by name.\n * When a component is defined across multiple story files (e.g. a companion\n * file documenting a specific aspect), it is collapsed to a single entry keyed\n * by its canonical name and package.\n *\n * @param components - The manifest components record.\n * @return Flat list of components derived from the manifest.\n */\nexport function parseComponents(\n\tcomponents: Record< string, ManifestComponent >\n): Component[] {\n\tconst byKey = new Map< string, Component >();\n\n\tfor ( const component of Object.values( components ) ) {\n\t\tconst packageName = packageNameFromPath( component.path );\n\t\tif ( ! packageName ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst name = canonicalComponentName( component.name );\n\t\tconst key = `${ packageName }:${ name }`;\n\t\tconst existing = byKey.get( key );\n\t\tconst description = component.description || '';\n\n\t\tif ( ! existing ) {\n\t\t\tbyKey.set( key, { name, description, packageName } );\n\t\t} else {\n\t\t\t// Prefer a non-empty description from a later entry over an\n\t\t\t// empty one from the first.\n\t\t\texisting.description ||= description;\n\t\t}\n\t}\n\n\treturn Array.from( byKey.values() ).sort( ( a, b ) =>\n\t\ta.name.localeCompare( b.name )\n\t);\n}\n\n/**\n * Find a single component by name (case-insensitive) and return its full\n * detail including props and stories. When a component is spread across\n * multiple story files, stories from every contributing file are collected\n * in manifest order. Descriptions and props are also authored on the component\n * itself, so in principle they should be identical across story files; in\n * practice one file may omit them, so we prefer any non-empty value found.\n *\n * @param components - The manifest components record.\n * @param name - The component name to look up.\n * @return The component detail, or null if not found.\n */\nexport function parseComponentDetail(\n\tcomponents: Record< string, ManifestComponent >,\n\tname: string\n): ComponentDetail | null {\n\tlet detail: ComponentDetail | null = null;\n\n\tfor ( const component of Object.values( components ) ) {\n\t\tconst canonicalName = canonicalComponentName( component.name );\n\t\tif ( canonicalName.toLowerCase() !== name.toLowerCase() ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst pkg = packageNameFromPath( component.path );\n\t\tif ( ! pkg ) {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst description = component.description || '';\n\t\tconst props = parseProps( component.reactDocgen?.props || {} );\n\t\tconst stories = component.stories || [];\n\n\t\tif ( ! detail ) {\n\t\t\tdetail = {\n\t\t\t\tname: canonicalName,\n\t\t\t\tdescription,\n\t\t\t\tpackageName: pkg,\n\t\t\t\timportStatement: buildImportStatement( canonicalName, pkg ),\n\t\t\t\tprops,\n\t\t\t\tstories: [ ...stories ],\n\t\t\t};\n\t\t} else if ( detail.packageName === pkg ) {\n\t\t\tdetail.description ||= description;\n\t\t\tif ( detail.props.length === 0 ) {\n\t\t\t\tdetail.props = props;\n\t\t\t}\n\t\t\tdetail.stories.push( ...stories );\n\t\t}\n\t}\n\n\treturn detail;\n}\n"],
5
+ "mappings": ";AAiBA,IAAM,iBAA2C;AAAA,EAChD,uCAAuC;AAAA,EACvC,sCAAsC;AAAA,EACtC,mCAAmC;AAAA,EACnC,4CACC;AAAA,EACD,kCAAkC;AAAA,EAClC,kCAAkC;AACnC;AAYA,SAAS,qBAAsB,MAAc,aAA8B;AAC1E,QAAM,WAAW,eAAgB,GAAI,WAAY,IAAK,IAAK,EAAG;AAC9D,SAAO,WACJ,YAAa,QAAS,OAAQ,IAAK,YAAa,WAAY,OAC5D,YAAa,IAAK,YAAa,WAAY;AAC/C;AAaO,SAAS,oBAAqB,WAAmC;AACvE,QAAM,QAAQ,UAAU,MAAO,2BAA4B;AAC3D,SAAO,QAAQ,cAAe,MAAO,CAAE,CAAE,KAAK;AAC/C;AAaA,SAAS,uBAAwB,MAAuB;AACvD,SAAO,KAAK,MAAO,KAAK,CAAE,EAAG,CAAE;AAChC;AASO,SAAS,WACf,UASkB;AAClB,SAAO,OAAO,QAAS,QAAS,EAC9B,OAAQ,CAAE,CAAE,EAAE,QAAS,MAAO;AAC9B,UAAM,eAAgB,SAAS,eAAe,IAAK,YAAY;AAC/D,WACC,CAAE,YAAY,SAAU,aAAc,KACtC,CAAE,YAAY,SAAU,SAAU;AAAA,EAEpC,CAAE,EACD,IAAK,CAAE,CAAE,UAAU,QAAS,OAAS;AAAA,IACrC,MAAM;AAAA;AAAA;AAAA;AAAA,IAIN,MAAM,SAAS,QAAQ,OAAO,SAAS,QAAQ,QAAQ;AAAA,IACvD,UAAU,SAAS,YAAY;AAAA,IAC/B,aAAa,SAAS,eAAe;AAAA,IACrC,cAAc,SAAS,cAAc,SAAS;AAAA,EAC/C,EAAI;AACN;AAWO,SAAS,gBACf,YACc;AACd,QAAM,QAAQ,oBAAI,IAAyB;AAE3C,aAAY,aAAa,OAAO,OAAQ,UAAW,GAAI;AACtD,UAAM,cAAc,oBAAqB,UAAU,IAAK;AACxD,QAAK,CAAE,aAAc;AACpB;AAAA,IACD;AAEA,UAAM,OAAO,uBAAwB,UAAU,IAAK;AACpD,UAAM,MAAM,GAAI,WAAY,IAAK,IAAK;AACtC,UAAM,WAAW,MAAM,IAAK,GAAI;AAChC,UAAM,cAAc,UAAU,eAAe;AAE7C,QAAK,CAAE,UAAW;AACjB,YAAM,IAAK,KAAK,EAAE,MAAM,aAAa,YAAY,CAAE;AAAA,IACpD,OAAO;AAGN,eAAS,gBAAgB;AAAA,IAC1B;AAAA,EACD;AAEA,SAAO,MAAM,KAAM,MAAM,OAAO,CAAE,EAAE;AAAA,IAAM,CAAE,GAAG,MAC9C,EAAE,KAAK,cAAe,EAAE,IAAK;AAAA,EAC9B;AACD;AAcO,SAAS,qBACf,YACA,MACyB;AACzB,MAAI,SAAiC;AAErC,aAAY,aAAa,OAAO,OAAQ,UAAW,GAAI;AACtD,UAAM,gBAAgB,uBAAwB,UAAU,IAAK;AAC7D,QAAK,cAAc,YAAY,MAAM,KAAK,YAAY,GAAI;AACzD;AAAA,IACD;AAEA,UAAM,MAAM,oBAAqB,UAAU,IAAK;AAChD,QAAK,CAAE,KAAM;AACZ;AAAA,IACD;AAEA,UAAM,cAAc,UAAU,eAAe;AAC7C,UAAM,QAAQ,WAAY,UAAU,aAAa,SAAS,CAAC,CAAE;AAC7D,UAAM,UAAU,UAAU,WAAW,CAAC;AAEtC,QAAK,CAAE,QAAS;AACf,eAAS;AAAA,QACR,MAAM;AAAA,QACN;AAAA,QACA,aAAa;AAAA,QACb,iBAAiB,qBAAsB,eAAe,GAAI;AAAA,QAC1D;AAAA,QACA,SAAS,CAAE,GAAG,OAAQ;AAAA,MACvB;AAAA,IACD,WAAY,OAAO,gBAAgB,KAAM;AACxC,aAAO,gBAAgB;AACvB,UAAK,OAAO,MAAM,WAAW,GAAI;AAChC,eAAO,QAAQ;AAAA,MAChB;AACA,aAAO,QAAQ,KAAM,GAAG,OAAQ;AAAA,IACjC;AAAA,EACD;AAEA,SAAO;AACR;",
6
+ "names": []
7
+ }
@@ -0,0 +1,45 @@
1
+ // packages/design-system-mcp/src/tools/get-component-details.ts
2
+ import { z } from "zod";
3
+ import { getComponentDetail } from "../data.mjs";
4
+ import { formatComponentDetail } from "../format.mjs";
5
+ function register(server) {
6
+ server.registerTool(
7
+ "get_component_details",
8
+ {
9
+ title: "Get Component Details",
10
+ description: "Get detailed documentation for a WordPress Design System component including props, usage examples, and import statements.",
11
+ inputSchema: z.object({
12
+ name: z.string().min(1).describe('The component name (e.g. "Button", "Tabs")')
13
+ }),
14
+ annotations: {
15
+ readOnlyHint: true
16
+ }
17
+ },
18
+ async ({ name }) => {
19
+ const detail = await getComponentDetail(name);
20
+ if (!detail) {
21
+ return {
22
+ content: [
23
+ {
24
+ type: "text",
25
+ text: `No component named "${name}" was found.`
26
+ }
27
+ ],
28
+ isError: true
29
+ };
30
+ }
31
+ return {
32
+ content: [
33
+ {
34
+ type: "text",
35
+ text: formatComponentDetail(detail)
36
+ }
37
+ ]
38
+ };
39
+ }
40
+ );
41
+ }
42
+ export {
43
+ register
44
+ };
45
+ //# sourceMappingURL=get-component-details.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/tools/get-component-details.ts"],
4
+ "sourcesContent": ["import type { McpServer } from '@modelcontextprotocol/server';\nimport { z } from 'zod';\nimport { getComponentDetail } from '../data';\nimport { formatComponentDetail } from '../format';\n\n/**\n * Register the get_component_details tool.\n *\n * @param server - The MCP server instance.\n */\nexport function register( server: McpServer ): void {\n\tserver.registerTool(\n\t\t'get_component_details',\n\t\t{\n\t\t\ttitle: 'Get Component Details',\n\t\t\tdescription:\n\t\t\t\t'Get detailed documentation for a WordPress Design System component including props, usage examples, and import statements.',\n\t\t\tinputSchema: z.object( {\n\t\t\t\tname: z\n\t\t\t\t\t.string()\n\t\t\t\t\t.min( 1 )\n\t\t\t\t\t.describe( 'The component name (e.g. \"Button\", \"Tabs\")' ),\n\t\t\t} ),\n\t\t\tannotations: {\n\t\t\t\treadOnlyHint: true,\n\t\t\t},\n\t\t},\n\t\tasync ( { name } ) => {\n\t\t\tconst detail = await getComponentDetail( name );\n\t\t\tif ( ! detail ) {\n\t\t\t\treturn {\n\t\t\t\t\tcontent: [\n\t\t\t\t\t\t{\n\t\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\t\ttext: `No component named \"${ name }\" was found.`,\n\t\t\t\t\t\t},\n\t\t\t\t\t],\n\t\t\t\t\tisError: true,\n\t\t\t\t};\n\t\t\t}\n\t\t\treturn {\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\ttext: formatComponentDetail( detail ),\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t}\n\t);\n}\n"],
5
+ "mappings": ";AACA,SAAS,SAAS;AAClB,SAAS,0BAA0B;AACnC,SAAS,6BAA6B;AAO/B,SAAS,SAAU,QAA0B;AACnD,SAAO;AAAA,IACN;AAAA,IACA;AAAA,MACC,OAAO;AAAA,MACP,aACC;AAAA,MACD,aAAa,EAAE,OAAQ;AAAA,QACtB,MAAM,EACJ,OAAO,EACP,IAAK,CAAE,EACP,SAAU,4CAA6C;AAAA,MAC1D,CAAE;AAAA,MACF,aAAa;AAAA,QACZ,cAAc;AAAA,MACf;AAAA,IACD;AAAA,IACA,OAAQ,EAAE,KAAK,MAAO;AACrB,YAAM,SAAS,MAAM,mBAAoB,IAAK;AAC9C,UAAK,CAAE,QAAS;AACf,eAAO;AAAA,UACN,SAAS;AAAA,YACR;AAAA,cACC,MAAM;AAAA,cACN,MAAM,uBAAwB,IAAK;AAAA,YACpC;AAAA,UACD;AAAA,UACA,SAAS;AAAA,QACV;AAAA,MACD;AACA,aAAO;AAAA,QACN,SAAS;AAAA,UACR;AAAA,YACC,MAAM;AAAA,YACN,MAAM,sBAAuB,MAAO;AAAA,UACrC;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,30 @@
1
+ // packages/design-system-mcp/src/tools/get-components.ts
2
+ import { getComponents } from "../data.mjs";
3
+ import { formatComponents } from "../format.mjs";
4
+ function register(server) {
5
+ server.registerTool(
6
+ "get_components",
7
+ {
8
+ title: "Get Components",
9
+ description: "Get a list of all available WordPress Design System components with their package names and descriptions.",
10
+ annotations: {
11
+ readOnlyHint: true
12
+ }
13
+ },
14
+ async () => {
15
+ const components = await getComponents();
16
+ return {
17
+ content: [
18
+ {
19
+ type: "text",
20
+ text: formatComponents(components)
21
+ }
22
+ ]
23
+ };
24
+ }
25
+ );
26
+ }
27
+ export {
28
+ register
29
+ };
30
+ //# sourceMappingURL=get-components.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/tools/get-components.ts"],
4
+ "sourcesContent": ["import type { McpServer } from '@modelcontextprotocol/server';\nimport { getComponents } from '../data';\nimport { formatComponents } from '../format';\n\n/**\n * Register the get_components tool.\n *\n * @param server - The MCP server instance.\n */\nexport function register( server: McpServer ): void {\n\tserver.registerTool(\n\t\t'get_components',\n\t\t{\n\t\t\ttitle: 'Get Components',\n\t\t\tdescription:\n\t\t\t\t'Get a list of all available WordPress Design System components with their package names and descriptions.',\n\t\t\tannotations: {\n\t\t\t\treadOnlyHint: true,\n\t\t\t},\n\t\t},\n\t\tasync () => {\n\t\t\tconst components = await getComponents();\n\t\t\treturn {\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\ttext: formatComponents( components ),\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t}\n\t);\n}\n"],
5
+ "mappings": ";AACA,SAAS,qBAAqB;AAC9B,SAAS,wBAAwB;AAO1B,SAAS,SAAU,QAA0B;AACnD,SAAO;AAAA,IACN;AAAA,IACA;AAAA,MACC,OAAO;AAAA,MACP,aACC;AAAA,MACD,aAAa;AAAA,QACZ,cAAc;AAAA,MACf;AAAA,IACD;AAAA,IACA,YAAY;AACX,YAAM,aAAa,MAAM,cAAc;AACvC,aAAO;AAAA,QACN,SAAS;AAAA,UACR;AAAA,YACC,MAAM;AAAA,YACN,MAAM,iBAAkB,UAAW;AAAA,UACpC;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,29 @@
1
+ // packages/design-system-mcp/src/tools/get-design-tokens.ts
2
+ import { getDesignTokens } from "../data.mjs";
3
+ function register(server) {
4
+ server.registerTool(
5
+ "get_design_tokens",
6
+ {
7
+ title: "Get Design Tokens",
8
+ description: "Get the WordPress Design System design tokens reference (colors, spacing, typography, elevation, etc.).",
9
+ annotations: {
10
+ readOnlyHint: true
11
+ }
12
+ },
13
+ async () => {
14
+ const tokens = await getDesignTokens();
15
+ return {
16
+ content: [
17
+ {
18
+ type: "text",
19
+ text: tokens.content
20
+ }
21
+ ]
22
+ };
23
+ }
24
+ );
25
+ }
26
+ export {
27
+ register
28
+ };
29
+ //# sourceMappingURL=get-design-tokens.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/tools/get-design-tokens.ts"],
4
+ "sourcesContent": ["import type { McpServer } from '@modelcontextprotocol/server';\nimport { getDesignTokens } from '../data';\n\n/**\n * Register the get_design_tokens tool.\n *\n * @param server - The MCP server instance.\n */\nexport function register( server: McpServer ): void {\n\tserver.registerTool(\n\t\t'get_design_tokens',\n\t\t{\n\t\t\ttitle: 'Get Design Tokens',\n\t\t\tdescription:\n\t\t\t\t'Get the WordPress Design System design tokens reference (colors, spacing, typography, elevation, etc.).',\n\t\t\tannotations: {\n\t\t\t\treadOnlyHint: true,\n\t\t\t},\n\t\t},\n\t\tasync () => {\n\t\t\tconst tokens = await getDesignTokens();\n\t\t\treturn {\n\t\t\t\tcontent: [\n\t\t\t\t\t{\n\t\t\t\t\t\ttype: 'text',\n\t\t\t\t\t\ttext: tokens.content,\n\t\t\t\t\t},\n\t\t\t\t],\n\t\t\t};\n\t\t}\n\t);\n}\n"],
5
+ "mappings": ";AACA,SAAS,uBAAuB;AAOzB,SAAS,SAAU,QAA0B;AACnD,SAAO;AAAA,IACN;AAAA,IACA;AAAA,MACC,OAAO;AAAA,MACP,aACC;AAAA,MACD,aAAa;AAAA,QACZ,cAAc;AAAA,MACf;AAAA,IACD;AAAA,IACA,YAAY;AACX,YAAM,SAAS,MAAM,gBAAgB;AACrC,aAAO;AAAA,QACN,SAAS;AAAA,UACR;AAAA,YACC,MAAM;AAAA,YACN,MAAM,OAAO;AAAA,UACd;AAAA,QACD;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;",
6
+ "names": []
7
+ }
@@ -0,0 +1,13 @@
1
+ // packages/design-system-mcp/src/tools/index.ts
2
+ import { register as getComponents } from "./get-components.mjs";
3
+ import { register as getComponentDetails } from "./get-component-details.mjs";
4
+ import { register as getDesignTokens } from "./get-design-tokens.mjs";
5
+ function registerTools(server) {
6
+ getComponents(server);
7
+ getComponentDetails(server);
8
+ getDesignTokens(server);
9
+ }
10
+ export {
11
+ registerTools
12
+ };
13
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/tools/index.ts"],
4
+ "sourcesContent": ["import type { McpServer } from '@modelcontextprotocol/server';\nimport { register as getComponents } from './get-components';\nimport { register as getComponentDetails } from './get-component-details';\nimport { register as getDesignTokens } from './get-design-tokens';\n\n/**\n * Register all MCP tools on the server.\n *\n * @param server - The MCP server instance.\n */\nexport function registerTools( server: McpServer ): void {\n\tgetComponents( server );\n\tgetComponentDetails( server );\n\tgetDesignTokens( server );\n}\n"],
5
+ "mappings": ";AACA,SAAS,YAAY,qBAAqB;AAC1C,SAAS,YAAY,2BAA2B;AAChD,SAAS,YAAY,uBAAuB;AAOrC,SAAS,cAAe,QAA0B;AACxD,gBAAe,MAAO;AACtB,sBAAqB,MAAO;AAC5B,kBAAiB,MAAO;AACzB;",
6
+ "names": []
7
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -0,0 +1,27 @@
1
+ import type { Component, ComponentDetail } from './types';
2
+ /**
3
+ * Clear cached data. Intended for testing.
4
+ */
5
+ export declare function resetCache(): void;
6
+ /**
7
+ * Get all components from allowed packages.
8
+ *
9
+ * @return Parsed component list.
10
+ */
11
+ export declare function getComponents(): Promise<Component[]>;
12
+ /**
13
+ * Get detailed documentation for a single component by name.
14
+ *
15
+ * @param name - The component name (case-insensitive).
16
+ * @return The component detail, or null if not found.
17
+ */
18
+ export declare function getComponentDetail(name: string): Promise<ComponentDetail | null>;
19
+ /**
20
+ * Get the design tokens reference document as markdown.
21
+ *
22
+ * @return The tokens markdown content.
23
+ */
24
+ export declare function getDesignTokens(): Promise<{
25
+ content: string;
26
+ }>;
27
+ //# sourceMappingURL=data.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data.d.ts","sourceRoot":"","sources":["../src/data.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAqB,MAAM,SAAS,CAAC;AAa7E;;GAEG;AACH,wBAAgB,UAAU,IAAI,IAAI,CAGjC;AAsCD;;;;GAIG;AACH,wBAAsB,aAAa,IAAI,OAAO,CAAE,SAAS,EAAE,CAAE,CAG5D;AAED;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACvC,IAAI,EAAE,MAAM,GACV,OAAO,CAAE,eAAe,GAAG,IAAI,CAAE,CAGnC;AAED;;;;GAIG;AACH,wBAAsB,eAAe,IAAI,OAAO,CAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,CAAE,CAatE"}
@@ -0,0 +1,16 @@
1
+ import type { Component, ComponentDetail } from './types';
2
+ /**
3
+ * Format the component list as markdown.
4
+ *
5
+ * @param components - The components to format.
6
+ * @return Formatted markdown.
7
+ */
8
+ export declare function formatComponents(components: Component[]): string;
9
+ /**
10
+ * Format a single component's detail as markdown documentation.
11
+ *
12
+ * @param detail - The component detail to format.
13
+ * @return Formatted markdown.
14
+ */
15
+ export declare function formatComponentDetail(detail: ComponentDetail): string;
16
+ //# sourceMappingURL=format.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAuB1D;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAE,UAAU,EAAE,SAAS,EAAE,GAAI,MAAM,CAQlE;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAE,MAAM,EAAE,eAAe,GAAI,MAAM,CA6CvE"}
@@ -0,0 +1,3 @@
1
+ import { McpServer } from '@modelcontextprotocol/server';
2
+ export declare function createServer(): McpServer;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAGzD,wBAAgB,YAAY,cAS3B"}