@wordpress/design-system-mcp 0.15.0 → 0.16.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.
- package/README.md +15 -6
- package/build-module/data.mjs +81 -50
- package/build-module/data.mjs.map +1 -7
- package/build-module/find-each.mjs +25 -0
- package/build-module/find-each.mjs.map +1 -0
- package/build-module/format.mjs +64 -53
- package/build-module/format.mjs.map +1 -7
- package/build-module/index.mjs +25 -23
- package/build-module/index.mjs.map +1 -7
- package/build-module/parse-components.mjs +135 -82
- package/build-module/parse-components.mjs.map +1 -7
- package/build-module/parse-patterns.mjs +44 -0
- package/build-module/parse-patterns.mjs.map +1 -0
- package/build-module/tools/get-component-details.mjs +32 -66
- package/build-module/tools/get-component-details.mjs.map +1 -7
- package/build-module/tools/get-components.mjs +20 -26
- package/build-module/tools/get-components.mjs.map +1 -7
- package/build-module/tools/get-design-tokens.mjs +19 -26
- package/build-module/tools/get-design-tokens.mjs.map +1 -7
- package/build-module/tools/get-pattern-details.mjs +38 -0
- package/build-module/tools/get-pattern-details.mjs.map +1 -0
- package/build-module/tools/get-patterns.mjs +23 -0
- package/build-module/tools/get-patterns.mjs.map +1 -0
- package/build-module/tools/index.mjs +18 -10
- package/build-module/tools/index.mjs.map +1 -7
- package/build-module/types.mjs +0 -1
- package/build-types/data.d.ts +14 -1
- package/build-types/data.d.ts.map +1 -1
- package/build-types/find-each.d.ts +13 -0
- package/build-types/find-each.d.ts.map +1 -0
- package/build-types/format.d.ts +8 -1
- package/build-types/format.d.ts.map +1 -1
- package/build-types/index.d.ts +1 -0
- package/build-types/index.d.ts.map +1 -1
- package/build-types/parse-patterns.d.ts +10 -0
- package/build-types/parse-patterns.d.ts.map +1 -0
- package/build-types/tools/get-component-details.d.ts.map +1 -1
- package/build-types/tools/get-pattern-details.d.ts +26 -0
- package/build-types/tools/get-pattern-details.d.ts.map +1 -0
- package/build-types/tools/get-patterns.d.ts +8 -0
- package/build-types/tools/get-patterns.d.ts.map +1 -0
- package/build-types/tools/index.d.ts.map +1 -1
- package/build-types/types.d.ts +11 -0
- package/build-types/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/build-module/types.mjs.map +0 -7
package/README.md
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
# WordPress Design System MCP Server
|
|
2
2
|
|
|
3
3
|
<p class="callout callout-alert">
|
|
4
|
-
|
|
4
|
+
The Design System MCP server is still experimental. “Experimental” means this is an early implementation subject to drastic and breaking changes.
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
7
|
An [MCP (Model Context Protocol)](https://modelcontextprotocol.io/) server for the WordPress Design System. Provides AI agents with component documentation, usage examples, and design tokens.
|
|
8
8
|
|
|
9
|
-
TypeScript consumers that import this package require TypeScript 5 or newer.
|
|
10
|
-
|
|
11
9
|
By using the MCP server, you can be confident that your AI agents are correctly following the latest design system guidance when asking questions like:
|
|
12
10
|
|
|
13
11
|
- Which components should be used for a given interaction or user interface, like a button or a dropdown
|
|
14
12
|
- How to implement those components in code, following sample code from the design system documentation
|
|
15
13
|
- How to implement new components following the design system styling standards with design tokens
|
|
14
|
+
- How to compose those components into an interaction, following the design system patterns, like confirming a destructive action or wording an error message
|
|
16
15
|
|
|
17
16
|
Without the MCP server, an AI agent may produce a functional and convincing result, but there's a higher risk that its resources are out-of-date or inaccurate, and it may try to use components which are no longer recommended for use. Since AI agents are unable to read [the WordPress Gutenberg Storybook documentation](https://wordpress.github.io/gutenberg/), the MCP server provides an alternative, machine-readable interface to that same information.
|
|
18
17
|
|
|
@@ -62,8 +61,18 @@ Configuration instructions for common clients:
|
|
|
62
61
|
- [Claude Desktop](https://modelcontextprotocol.io/docs/develop/connect-local-servers#installing-the-filesystem-server)
|
|
63
62
|
- This guide is for the "filesystem" server, but you can substitute the `mcpServers` entry from the snippet above and the rest of the instructions still apply.
|
|
64
63
|
|
|
65
|
-
##
|
|
64
|
+
## Importing the package
|
|
65
|
+
|
|
66
|
+
Most people only need the setup instructions above. To embed the server in your own tooling, install the `@wordpress/design-system-mcp` package from npm:
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npm install @wordpress/design-system-mcp
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
The package is ESM-only and requires Node.js 22.13.0 or newer. It exports `createServer`, which returns a ready-to-connect MCP server, and the `parseComponents` and `parseComponentDetail` helpers. TypeScript consumers that import the package require TypeScript 5 or newer.
|
|
73
|
+
|
|
74
|
+
## Contributing
|
|
66
75
|
|
|
67
|
-
|
|
76
|
+
The Design System MCP server is published as the `@wordpress/design-system-mcp` package, an individual package that's part of the [Gutenberg project](https://github.com/WordPress/gutenberg). 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.
|
|
68
77
|
|
|
69
|
-
To find out more about contributing to
|
|
78
|
+
To find out more about contributing to the Design System MCP server or Gutenberg as a whole, please read the project's main [contributor guide](https://github.com/WordPress/gutenberg/tree/HEAD/CONTRIBUTING.md).
|
package/build-module/data.mjs
CHANGED
|
@@ -1,61 +1,92 @@
|
|
|
1
|
+
import { packageNameFromPath, parseComponentDetail, parseComponents } from "./parse-components.mjs";
|
|
2
|
+
import { parsePatterns } from "./parse-patterns.mjs";
|
|
1
3
|
// packages/design-system-mcp/src/data.ts
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
const COMPONENTS_MANIFEST_URL = process.env.COMPONENTS_MANIFEST_URL || "https://wordpress.github.io/gutenberg/manifests/components.json";
|
|
5
|
+
const DESIGN_TOKENS_URL = process.env.DESIGN_TOKENS_URL || "https://raw.githubusercontent.com/WordPress/gutenberg/refs/heads/trunk/packages/theme/docs/tokens.md";
|
|
6
|
+
const DOCS_MANIFEST_URL = process.env.DOCS_MANIFEST_URL || "https://wordpress.github.io/gutenberg/manifests/docs.json";
|
|
7
|
+
let cachedComponents = null;
|
|
8
|
+
let cachedTokens = null;
|
|
9
|
+
let cachedPatterns = null;
|
|
10
|
+
/**
|
|
11
|
+
* Clear cached data. Intended for testing.
|
|
12
|
+
*/
|
|
11
13
|
function resetCache() {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
cachedComponents = null;
|
|
15
|
+
cachedTokens = null;
|
|
16
|
+
cachedPatterns = null;
|
|
14
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* Fetch and cache the components from the Storybook manifest, filtered to only
|
|
20
|
+
* components from allowed packages.
|
|
21
|
+
*
|
|
22
|
+
* @return The filtered components record.
|
|
23
|
+
*/
|
|
15
24
|
async function fetchComponents() {
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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;
|
|
25
|
+
if (cachedComponents) return cachedComponents;
|
|
26
|
+
const response = await fetch(COMPONENTS_MANIFEST_URL);
|
|
27
|
+
if (!response.ok) throw new Error(`Failed to fetch components manifest: ${response.status} ${response.statusText}`);
|
|
28
|
+
const manifest = await response.json();
|
|
29
|
+
const filtered = {};
|
|
30
|
+
for (const [key, component] of Object.entries(manifest.components)) if (packageNameFromPath(component.path)) filtered[key] = component;
|
|
31
|
+
cachedComponents = filtered;
|
|
32
|
+
return cachedComponents;
|
|
34
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Get all components from allowed packages.
|
|
36
|
+
*
|
|
37
|
+
* @return Parsed component list.
|
|
38
|
+
*/
|
|
35
39
|
async function getComponents() {
|
|
36
|
-
|
|
37
|
-
|
|
40
|
+
const components = await fetchComponents();
|
|
41
|
+
return parseComponents(components);
|
|
38
42
|
}
|
|
43
|
+
/**
|
|
44
|
+
* Get detailed documentation for a single component by name.
|
|
45
|
+
*
|
|
46
|
+
* @param name - The component name (case-insensitive).
|
|
47
|
+
* @return The component detail, or null if not found.
|
|
48
|
+
*/
|
|
39
49
|
async function getComponentDetail(name) {
|
|
40
|
-
|
|
41
|
-
|
|
50
|
+
const components = await fetchComponents();
|
|
51
|
+
return parseComponentDetail(components, name);
|
|
42
52
|
}
|
|
53
|
+
/**
|
|
54
|
+
* Get the design tokens reference document as markdown.
|
|
55
|
+
*
|
|
56
|
+
* @return The tokens markdown content.
|
|
57
|
+
*/
|
|
43
58
|
async function getDesignTokens() {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
cachedTokens = await response.text();
|
|
52
|
-
}
|
|
53
|
-
return { content: cachedTokens };
|
|
59
|
+
if (!cachedTokens) {
|
|
60
|
+
const response = await fetch(DESIGN_TOKENS_URL);
|
|
61
|
+
if (!response.ok) throw new Error(`Failed to fetch design tokens: ${response.status} ${response.statusText}`);
|
|
62
|
+
cachedTokens = await response.text();
|
|
63
|
+
}
|
|
64
|
+
return { content: cachedTokens };
|
|
54
65
|
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
66
|
+
/**
|
|
67
|
+
* Get the design system patterns from the Storybook docs manifest.
|
|
68
|
+
*
|
|
69
|
+
* @return The patterns.
|
|
70
|
+
*/
|
|
71
|
+
async function getPatterns() {
|
|
72
|
+
if (cachedPatterns) return cachedPatterns;
|
|
73
|
+
const response = await fetch(DOCS_MANIFEST_URL);
|
|
74
|
+
if (!response.ok) throw new Error(`Failed to fetch docs manifest: ${response.status} ${response.statusText}`);
|
|
75
|
+
const manifest = await response.json();
|
|
76
|
+
cachedPatterns = parsePatterns(manifest.docs);
|
|
77
|
+
return cachedPatterns;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Get a single pattern document by slug, including its markdown content.
|
|
81
|
+
*
|
|
82
|
+
* @param slug - The pattern slug (case-insensitive).
|
|
83
|
+
* @return The pattern detail, or null if there is no such pattern.
|
|
84
|
+
*/
|
|
85
|
+
async function getPatternDetail(slug) {
|
|
86
|
+
const patterns = await getPatterns();
|
|
87
|
+
const normalizedSlug = slug.trim().toLowerCase();
|
|
88
|
+
return patterns.find((pattern) => pattern.slug === normalizedSlug) ?? null;
|
|
89
|
+
}
|
|
90
|
+
export { getComponentDetail, getComponents, getDesignTokens, getPatternDetail, getPatterns, resetCache };
|
|
91
|
+
|
|
92
|
+
//# sourceMappingURL=data.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/data.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n\tpackageNameFromPath,\n\tparseComponents,\n\tparseComponentDetail,\n} from './parse-components.ts';\nimport type { Component, ComponentDetail, ManifestComponent } from './types.ts';\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
|
-
}
|
|
1
|
+
{"version":3,"file":"data.mjs","names":[],"sources":["../src/data.ts"],"sourcesContent":["import {\n\tpackageNameFromPath,\n\tparseComponents,\n\tparseComponentDetail,\n} from './parse-components.ts';\nimport { parsePatterns } from './parse-patterns.ts';\nimport type {\n\tComponent,\n\tComponentDetail,\n\tManifestComponent,\n\tManifestDoc,\n\tPattern,\n} from './types.ts';\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\nconst DOCS_MANIFEST_URL =\n\tprocess.env.DOCS_MANIFEST_URL ||\n\t'https://wordpress.github.io/gutenberg/manifests/docs.json';\n\nlet cachedComponents: Record< string, ManifestComponent > | null = null;\nlet cachedTokens: string | null = null;\nlet cachedPatterns: Pattern[] | null = null;\n\n/**\n * Clear cached data. Intended for testing.\n */\nexport function resetCache(): void {\n\tcachedComponents = null;\n\tcachedTokens = null;\n\tcachedPatterns = 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\n/**\n * Get the design system patterns from the Storybook docs manifest.\n *\n * @return The patterns.\n */\nexport async function getPatterns(): Promise< Pattern[] > {\n\tif ( cachedPatterns ) {\n\t\treturn cachedPatterns;\n\t}\n\n\tconst response = await fetch( DOCS_MANIFEST_URL );\n\tif ( ! response.ok ) {\n\t\tthrow new Error(\n\t\t\t`Failed to fetch docs manifest: ${ response.status } ${ response.statusText }`\n\t\t);\n\t}\n\n\tconst manifest: {\n\t\tv: number;\n\t\tdocs: Record< string, ManifestDoc >;\n\t} = await response.json();\n\n\tcachedPatterns = parsePatterns( manifest.docs );\n\treturn cachedPatterns;\n}\n\n/**\n * Get a single pattern document by slug, including its markdown content.\n *\n * @param slug - The pattern slug (case-insensitive).\n * @return The pattern detail, or null if there is no such pattern.\n */\nexport async function getPatternDetail(\n\tslug: string\n): Promise< Pattern | null > {\n\tconst patterns = await getPatterns();\n\tconst normalizedSlug = slug.trim().toLowerCase();\n\treturn (\n\t\tpatterns.find( ( pattern ) => pattern.slug === normalizedSlug ) ?? null\n\t);\n}\n"],"mappings":";;;AAcA,MAAM,0BACL,QAAQ,IAAI,2BACZ;AAED,MAAM,oBACL,QAAQ,IAAI,qBACZ;AAED,MAAM,oBACL,QAAQ,IAAI,qBACZ;AAED,IAAI,mBAA+D;AACnE,IAAI,eAA8B;AAClC,IAAI,iBAAmC;;;;AAKvC,SAAgB,aAAmB;CAClC,mBAAmB;CACnB,eAAe;CACf,iBAAiB;AAClB;;;;;;;AAQA,eAAe,kBAEb;CACD,IAAK,kBACJ,OAAO;CAGR,MAAM,WAAW,MAAM,MAAO,uBAAwB;CACtD,IAAK,CAAE,SAAS,IACf,MAAM,IAAI,MACT,wCAAyC,SAAS,OAAQ,GAAI,SAAS,YACxE;CAGD,MAAM,WAGF,MAAM,SAAS,KAAK;CAExB,MAAM,WAAgD,CAAC;CACvD,KAAM,MAAM,CAAE,KAAK,cAAe,OAAO,QAAS,SAAS,UAAW,GACrE,IAAK,oBAAqB,UAAU,IAAK,GACxC,SAAU,OAAQ;CAIpB,mBAAmB;CACnB,OAAO;AACR;;;;;;AAOA,eAAsB,gBAAwC;CAC7D,MAAM,aAAa,MAAM,gBAAgB;CACzC,OAAO,gBAAiB,UAAW;AACpC;;;;;;;AAQA,eAAsB,mBACrB,MACoC;CACpC,MAAM,aAAa,MAAM,gBAAgB;CACzC,OAAO,qBAAsB,YAAY,IAAK;AAC/C;;;;;;AAOA,eAAsB,kBAAkD;CACvE,IAAK,CAAE,cAAe;EACrB,MAAM,WAAW,MAAM,MAAO,iBAAkB;EAChD,IAAK,CAAE,SAAS,IACf,MAAM,IAAI,MACT,kCAAmC,SAAS,OAAQ,GAAI,SAAS,YAClE;EAGD,eAAe,MAAM,SAAS,KAAK;CACpC;CAEA,OAAO,EAAE,SAAS,aAAa;AAChC;;;;;;AAOA,eAAsB,cAAoC;CACzD,IAAK,gBACJ,OAAO;CAGR,MAAM,WAAW,MAAM,MAAO,iBAAkB;CAChD,IAAK,CAAE,SAAS,IACf,MAAM,IAAI,MACT,kCAAmC,SAAS,OAAQ,GAAI,SAAS,YAClE;CAGD,MAAM,WAGF,MAAM,SAAS,KAAK;CAExB,iBAAiB,cAAe,SAAS,IAAK;CAC9C,OAAO;AACR;;;;;;;AAQA,eAAsB,iBACrB,MAC4B;CAC5B,MAAM,WAAW,MAAM,YAAY;CACnC,MAAM,iBAAiB,KAAK,KAAK,CAAC,CAAC,YAAY;CAC/C,OACC,SAAS,MAAQ,YAAa,QAAQ,SAAS,cAAe,KAAK;AAErE"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// packages/design-system-mcp/src/find-each.ts
|
|
2
|
+
/**
|
|
3
|
+
* Look up each of one or more keys, and separate the items found from the keys
|
|
4
|
+
* that have no item.
|
|
5
|
+
*
|
|
6
|
+
* @param keys - The key, or keys, to look up.
|
|
7
|
+
* @param find - Returns the item for a key, or null if there is none.
|
|
8
|
+
* @return The items found, and the keys without an item.
|
|
9
|
+
*/
|
|
10
|
+
async function findEach(keys, find) {
|
|
11
|
+
const found = [];
|
|
12
|
+
const missing = [];
|
|
13
|
+
for (const key of Array.isArray(keys) ? keys : [keys]) {
|
|
14
|
+
const item = await find(key);
|
|
15
|
+
if (item) found.push(item);
|
|
16
|
+
else missing.push(key);
|
|
17
|
+
}
|
|
18
|
+
return {
|
|
19
|
+
found,
|
|
20
|
+
missing
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
export { findEach };
|
|
24
|
+
|
|
25
|
+
//# sourceMappingURL=find-each.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"find-each.mjs","names":[],"sources":["../src/find-each.ts"],"sourcesContent":["/**\n * Look up each of one or more keys, and separate the items found from the keys\n * that have no item.\n *\n * @param keys - The key, or keys, to look up.\n * @param find - Returns the item for a key, or null if there is none.\n * @return The items found, and the keys without an item.\n */\nexport async function findEach< T >(\n\tkeys: string | string[],\n\tfind: ( key: string ) => Promise< T | null >\n): Promise< { found: T[]; missing: string[] } > {\n\tconst found: T[] = [];\n\tconst missing: string[] = [];\n\n\t// Look up keys in order, so that only the first lookup fetches the data.\n\tfor ( const key of Array.isArray( keys ) ? keys : [ keys ] ) {\n\t\tconst item = await find( key );\n\t\tif ( item ) {\n\t\t\tfound.push( item );\n\t\t} else {\n\t\t\tmissing.push( key );\n\t\t}\n\t}\n\n\treturn { found, missing };\n}\n"],"mappings":";;;;;;;;;AAQA,eAAsB,SACrB,MACA,MAC+C;CAC/C,MAAM,QAAa,CAAC;CACpB,MAAM,UAAoB,CAAC;CAG3B,KAAM,MAAM,OAAO,MAAM,QAAS,IAAK,IAAI,OAAO,CAAE,IAAK,GAAI;EAC5D,MAAM,OAAO,MAAM,KAAM,GAAI;EAC7B,IAAK,MACJ,MAAM,KAAM,IAAK;OAEjB,QAAQ,KAAM,GAAI;CAEpB;CAEA,OAAO;EAAE;EAAO;CAAQ;AACzB"}
|
package/build-module/format.mjs
CHANGED
|
@@ -1,60 +1,71 @@
|
|
|
1
1
|
// packages/design-system-mcp/src/format.ts
|
|
2
|
+
/**
|
|
3
|
+
* Format a component's name, package, and description as markdown.
|
|
4
|
+
*
|
|
5
|
+
* @param component - The component to format.
|
|
6
|
+
* @param headingLevel - The heading level for the component name.
|
|
7
|
+
* @return Markdown lines.
|
|
8
|
+
*/
|
|
2
9
|
function formatComponentSummary(component, headingLevel) {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
lines.push("", component.description);
|
|
7
|
-
}
|
|
8
|
-
return lines;
|
|
10
|
+
const lines = [`${"#".repeat(headingLevel)} ${component.name}`];
|
|
11
|
+
if (component.description) lines.push("", component.description);
|
|
12
|
+
return lines;
|
|
9
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Format the component list as markdown.
|
|
16
|
+
*
|
|
17
|
+
* @param components - The components to format.
|
|
18
|
+
* @return Formatted markdown.
|
|
19
|
+
*/
|
|
10
20
|
function formatComponents(components) {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}
|
|
15
|
-
return lines.join("\n");
|
|
21
|
+
const lines = ["# WordPress Design System Components"];
|
|
22
|
+
for (const component of components) lines.push("", ...formatComponentSummary(component, 2));
|
|
23
|
+
return lines.join("\n");
|
|
16
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Format a single component's detail as markdown documentation.
|
|
27
|
+
*
|
|
28
|
+
* @param detail - The component detail to format.
|
|
29
|
+
* @return Formatted markdown.
|
|
30
|
+
*/
|
|
17
31
|
function formatComponentDetail(detail) {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
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");
|
|
32
|
+
const lines = formatComponentSummary(detail, 1);
|
|
33
|
+
lines.push("", `**Package:** \`${detail.packageName}\``);
|
|
34
|
+
if (detail.importStatement) lines.push("", "## Import", "", "```ts", detail.importStatement, "```");
|
|
35
|
+
if (detail.props.length > 0) {
|
|
36
|
+
lines.push("", "## Props", "");
|
|
37
|
+
for (const prop of detail.props) {
|
|
38
|
+
const required = prop.required ? " **(required)**" : "";
|
|
39
|
+
const defaultNote = prop.defaultValue ? ` (default: \`${prop.defaultValue}\`)` : "";
|
|
40
|
+
lines.push(`### \`${prop.name}\`: \`${prop.type}\`${required}${defaultNote}`, "");
|
|
41
|
+
if (prop.description) lines.push(prop.description, "");
|
|
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) lines.push("", "```tsx", story.snippet, "```");
|
|
49
|
+
lines.push("");
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
return lines.join("\n");
|
|
55
53
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
/**
|
|
55
|
+
* Format the pattern list as markdown.
|
|
56
|
+
*
|
|
57
|
+
* @param patterns - The patterns to format.
|
|
58
|
+
* @return Formatted markdown.
|
|
59
|
+
*/
|
|
60
|
+
function formatPatterns(patterns) {
|
|
61
|
+
const lines = [
|
|
62
|
+
"# WordPress Design System Patterns",
|
|
63
|
+
"",
|
|
64
|
+
"Call `get_pattern_details` with a slug for the full guidance."
|
|
65
|
+
];
|
|
66
|
+
for (const pattern of patterns) lines.push("", `## ${pattern.title}`, "", `**Slug:** \`${pattern.slug}\``, "", pattern.description);
|
|
67
|
+
return lines.join("\n");
|
|
68
|
+
}
|
|
69
|
+
export { formatComponentDetail, formatComponents, formatPatterns };
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=format.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/format.ts"],
|
|
4
|
-
"sourcesContent": ["import type { Component, ComponentDetail } from './types.ts';\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
|
-
}
|
|
1
|
+
{"version":3,"file":"format.mjs","names":[],"sources":["../src/format.ts"],"sourcesContent":["import type { Component, ComponentDetail, Pattern } from './types.ts';\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\n/**\n * Format the pattern list as markdown.\n *\n * @param patterns - The patterns to format.\n * @return Formatted markdown.\n */\nexport function formatPatterns( patterns: Pattern[] ): string {\n\tconst lines = [\n\t\t'# WordPress Design System Patterns',\n\t\t'',\n\t\t'Call `get_pattern_details` with a slug for the full guidance.',\n\t];\n\n\tfor ( const pattern of patterns ) {\n\t\tlines.push(\n\t\t\t'',\n\t\t\t`## ${ pattern.title }`,\n\t\t\t'',\n\t\t\t`**Slug:** \\`${ pattern.slug }\\``,\n\t\t\t'',\n\t\t\tpattern.description\n\t\t);\n\t}\n\n\treturn lines.join( '\\n' );\n}\n"],"mappings":";;;;;;;;AASA,SAAS,uBACR,WACA,cACW;CAEX,MAAM,QAAQ,CAAE,GADA,IAAI,OAAQ,YACF,EAAG,GAAI,UAAU,MAAQ;CAEnD,IAAK,UAAU,aACd,MAAM,KAAM,IAAI,UAAU,WAAY;CAGvC,OAAO;AACR;;;;;;;AAQA,SAAgB,iBAAkB,YAAkC;CACnE,MAAM,QAAQ,CAAE,sCAAuC;CAEvD,KAAM,MAAM,aAAa,YACxB,MAAM,KAAM,IAAI,GAAG,uBAAwB,WAAW,CAAE,CAAE;CAG3D,OAAO,MAAM,KAAM,IAAK;AACzB;;;;;;;AAQA,SAAgB,sBAAuB,QAAkC;CACxE,MAAM,QAAQ,uBAAwB,QAAQ,CAAE;CAEhD,MAAM,KAAM,IAAI,kBAAmB,OAAO,YAAa,GAAI;CAE3D,IAAK,OAAO,iBACX,MAAM,KACL,IACA,aACA,IACA,SACA,OAAO,iBACP,KACD;CAGD,IAAK,OAAO,MAAM,SAAS,GAAI;EAC9B,MAAM,KAAM,IAAI,YAAY,EAAG;EAC/B,KAAM,MAAM,QAAQ,OAAO,OAAQ;GAClC,MAAM,WAAW,KAAK,WAAW,oBAAoB;GACrD,MAAM,cAAc,KAAK,eACtB,gBAAiB,KAAK,aAAc,OACpC;GACH,MAAM,KACL,SAAU,KAAK,KAAM,QAAS,KAAK,KAAM,IAAK,WAAa,eAC3D,EACD;GACA,IAAK,KAAK,aACT,MAAM,KAAM,KAAK,aAAa,EAAG;EAEnC;CACD;CAEA,IAAK,OAAO,QAAQ,SAAS,GAAI;EAChC,MAAM,KAAM,IAAI,eAAe,EAAG;EAClC,KAAM,MAAM,SAAS,OAAO,SAAU;GACrC,MAAM,KAAM,OAAQ,MAAM,MAAQ;GAClC,IAAK,MAAM,SACV,MAAM,KAAM,IAAI,UAAU,MAAM,SAAS,KAAM;GAEhD,MAAM,KAAM,EAAG;EAChB;CACD;CAEA,OAAO,MAAM,KAAM,IAAK;AACzB;;;;;;;AAQA,SAAgB,eAAgB,UAA8B;CAC7D,MAAM,QAAQ;EACb;EACA;EACA;CACD;CAEA,KAAM,MAAM,WAAW,UACtB,MAAM,KACL,IACA,MAAO,QAAQ,SACf,IACA,eAAgB,QAAQ,KAAM,KAC9B,IACA,QAAQ,WACT;CAGD,OAAO,MAAM,KAAM,IAAK;AACzB"}
|
package/build-module/index.mjs
CHANGED
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
// packages/design-system-mcp/src/index.ts
|
|
2
1
|
import { McpServer } from "@modelcontextprotocol/server";
|
|
3
2
|
import { registerTools } from "./tools/index.mjs";
|
|
4
|
-
import {
|
|
3
|
+
import { parseComponentDetail, parseComponents } from "./parse-components.mjs";
|
|
4
|
+
import { parsePatterns } from "./parse-patterns.mjs";
|
|
5
|
+
// packages/design-system-mcp/src/index.ts
|
|
5
6
|
function createServer() {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
7
|
+
const server = new McpServer({
|
|
8
|
+
name: "WordPress Design System",
|
|
9
|
+
version: "0.1.0"
|
|
10
|
+
}, { instructions: [
|
|
11
|
+
"Provides guidance for building interfaces with the WordPress Design System, at three levels:",
|
|
12
|
+
[
|
|
13
|
+
"- Patterns describe how to approach a kind of interaction, such as confirming a destructive action or saving a form. A pattern says which components to choose for the situation and how to configure them.",
|
|
14
|
+
"- Components are the building blocks in `@wordpress/ui` and `@wordpress/components`, documented with their props, examples, and import statements.",
|
|
15
|
+
"- Design tokens are the themeable `--wpds-*` CSS custom properties from `@wordpress/theme` that the components are built on, for styling that no component covers."
|
|
16
|
+
].join("\n"),
|
|
17
|
+
"Use the appropriate tool for each request:",
|
|
18
|
+
[
|
|
19
|
+
"- To answer a question about a specific component, such as its props or how to import it, call `get_component_details`. When the request uses a generic name (\"dropdown menu\") instead of the export name, call `get_components` first to find it.",
|
|
20
|
+
"- To build an interface or a user flow, call `get_patterns` first to check whether a pattern covers the situation. If one does, call `get_pattern_details` and follow it: patterns record decisions that component documentation cannot, such as when to use one component instead of another. If none does, work from the components. In both cases, call `get_component_details` for the components you will use.",
|
|
21
|
+
"- For custom styling, call `get_design_tokens`. Prefer component props when a component already expresses the styling intent."
|
|
22
|
+
].join("\n")
|
|
23
|
+
].join("\n\n") });
|
|
24
|
+
registerTools(server);
|
|
25
|
+
return server;
|
|
21
26
|
}
|
|
22
|
-
export {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
parseComponents
|
|
26
|
-
};
|
|
27
|
-
//# sourceMappingURL=index.mjs.map
|
|
27
|
+
export { createServer, parseComponentDetail, parseComponents, parsePatterns };
|
|
28
|
+
|
|
29
|
+
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"version": 3,
|
|
3
|
-
"sources": ["../src/index.ts"],
|
|
4
|
-
"sourcesContent": ["import { McpServer } from '@modelcontextprotocol/server';\nimport { registerTools } from './tools/index.ts';\n\nexport { parseComponents, parseComponentDetail } from './parse-components.ts';\n\nexport function createServer() {\n\tconst server = new McpServer(\n\t\t{\n\t\t\tname: 'WordPress Design System',\n\t\t\tversion: '0.1.0',\n\t\t},\n\t\t{\n\t\t\tinstructions: [\n\t\t\t\t'Provides discovery and usage information for the WordPress Design System. Covers components in `@wordpress/components` and `@wordpress/ui`, and the underlying design tokens from `@wordpress/theme` exposed as `--wpds-*` CSS custom properties.',\n\t\t\t\t'In a typical flow, a user will often refer to components by generic names (\"button\", \"dropdown menu\") that don\\'t match the actual export. Call `get_components` first to map the request to canonical component names, then `get_component_details` for one or more of those names to get props, descriptions, and usage notes.',\n\t\t\t\t'`get_design_tokens` covers the semantic, themeable design tokens that the components are built on. While these can be used for custom styling that adapts to the current design system theme settings, prefer using the available component APIs when available.',\n\t\t\t].join( '\\n\\n' ),\n\t\t}\n\t);\n\n\tregisterTools( server );\n\n\treturn server;\n}\n"],
|
|
5
|
-
"mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;AAE9B,SAAS,iBAAiB,4BAA4B;AAE/C,SAAS,eAAe;AAC9B,QAAM,SAAS,IAAI;AAAA,IAClB;AAAA,MACC,MAAM;AAAA,MACN,SAAS;AAAA,IACV;AAAA,IACA;AAAA,MACC,cAAc;AAAA,QACb;AAAA,QACA;AAAA,QACA;AAAA,MACD,EAAE,KAAM,MAAO;AAAA,IAChB;AAAA,EACD;AAEA,gBAAe,MAAO;AAEtB,SAAO;AACR;",
|
|
6
|
-
"names": []
|
|
7
|
-
}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/index.ts"],"sourcesContent":["import { McpServer } from '@modelcontextprotocol/server';\nimport { registerTools } from './tools/index.ts';\n\nexport { parseComponents, parseComponentDetail } from './parse-components.ts';\nexport { parsePatterns } from './parse-patterns.ts';\n\nexport function createServer() {\n\tconst server = new McpServer(\n\t\t{\n\t\t\tname: 'WordPress Design System',\n\t\t\tversion: '0.1.0',\n\t\t},\n\t\t{\n\t\t\tinstructions: [\n\t\t\t\t'Provides guidance for building interfaces with the WordPress Design System, at three levels:',\n\t\t\t\t[\n\t\t\t\t\t'- Patterns describe how to approach a kind of interaction, such as confirming a destructive action or saving a form. A pattern says which components to choose for the situation and how to configure them.',\n\t\t\t\t\t'- Components are the building blocks in `@wordpress/ui` and `@wordpress/components`, documented with their props, examples, and import statements.',\n\t\t\t\t\t'- Design tokens are the themeable `--wpds-*` CSS custom properties from `@wordpress/theme` that the components are built on, for styling that no component covers.',\n\t\t\t\t].join( '\\n' ),\n\t\t\t\t'Use the appropriate tool for each request:',\n\t\t\t\t[\n\t\t\t\t\t'- To answer a question about a specific component, such as its props or how to import it, call `get_component_details`. When the request uses a generic name (\"dropdown menu\") instead of the export name, call `get_components` first to find it.',\n\t\t\t\t\t'- To build an interface or a user flow, call `get_patterns` first to check whether a pattern covers the situation. If one does, call `get_pattern_details` and follow it: patterns record decisions that component documentation cannot, such as when to use one component instead of another. If none does, work from the components. In both cases, call `get_component_details` for the components you will use.',\n\t\t\t\t\t'- For custom styling, call `get_design_tokens`. Prefer component props when a component already expresses the styling intent.',\n\t\t\t\t].join( '\\n' ),\n\t\t\t].join( '\\n\\n' ),\n\t\t}\n\t);\n\n\tregisterTools( server );\n\n\treturn server;\n}\n"],"mappings":";;;;;AAMA,SAAgB,eAAe;CAC9B,MAAM,SAAS,IAAI,UAClB;EACC,MAAM;EACN,SAAS;CACV,GACA,EACC,cAAc;EACb;EACA;GACC;GACA;GACA;EACD,CAAC,CAAC,KAAM,IAAK;EACb;EACA;GACC;GACA;GACA;EACD,CAAC,CAAC,KAAM,IAAK;CACd,CAAC,CAAC,KAAM,MAAO,EAChB,CACD;CAEA,cAAe,MAAO;CAEtB,OAAO;AACR"}
|