@wordpress/design-system-mcp 0.17.0 → 0.18.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/build-module/format.mjs +11 -15
- package/build-module/format.mjs.map +1 -1
- package/build-module/tools/get-components.mjs +1 -1
- package/build-module/tools/get-components.mjs.map +1 -1
- package/build-module/tools/index.mjs.map +1 -1
- package/build-types/format.d.ts.map +1 -1
- package/package.json +5 -5
package/build-module/format.mjs
CHANGED
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
// packages/design-system-mcp/src/format.ts
|
|
2
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
|
-
*/
|
|
9
|
-
function formatComponentSummary(component, headingLevel) {
|
|
10
|
-
const lines = [`${"#".repeat(headingLevel)} ${component.name}`];
|
|
11
|
-
if (component.description) lines.push("", component.description);
|
|
12
|
-
return lines;
|
|
13
|
-
}
|
|
14
|
-
/**
|
|
15
3
|
* Format the component list as markdown.
|
|
16
4
|
*
|
|
17
5
|
* @param components - The components to format.
|
|
@@ -19,7 +7,11 @@ function formatComponentSummary(component, headingLevel) {
|
|
|
19
7
|
*/
|
|
20
8
|
function formatComponents(components) {
|
|
21
9
|
const lines = ["# WordPress Design System Components"];
|
|
22
|
-
for (const component of components)
|
|
10
|
+
for (const component of components) {
|
|
11
|
+
const description = component.description.split(/\n\s*\n/, 1)[0];
|
|
12
|
+
lines.push("", `## ${component.name}`);
|
|
13
|
+
if (description) lines.push("", description);
|
|
14
|
+
}
|
|
23
15
|
return lines.join("\n");
|
|
24
16
|
}
|
|
25
17
|
/**
|
|
@@ -29,8 +21,12 @@ function formatComponents(components) {
|
|
|
29
21
|
* @return Formatted markdown.
|
|
30
22
|
*/
|
|
31
23
|
function formatComponentDetail(detail) {
|
|
32
|
-
const lines =
|
|
33
|
-
|
|
24
|
+
const lines = [
|
|
25
|
+
`# ${detail.name}`,
|
|
26
|
+
"",
|
|
27
|
+
`**Package:** \`${detail.packageName}\``
|
|
28
|
+
];
|
|
29
|
+
if (detail.description) lines.push("", detail.description);
|
|
34
30
|
if (detail.importStatement) lines.push("", "## Import", "", "```ts", detail.importStatement, "```");
|
|
35
31
|
if (detail.props.length > 0) {
|
|
36
32
|
lines.push("", "## Props", "");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.mjs","names":[],"sources":["../src/format.ts"],"sourcesContent":["import type { Component, ComponentDetail, Pattern } from './types.ts';\n\n/**\n * Format
|
|
1
|
+
{"version":3,"file":"format.mjs","names":[],"sources":["../src/format.ts"],"sourcesContent":["import type { Component, ComponentDetail, Pattern } from './types.ts';\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\t// Descriptions can continue with usage notes and code examples. Only\n\t\t// the first paragraph is short enough to summarize the component.\n\t\tconst description = component.description.split( /\\n\\s*\\n/, 1 )[ 0 ];\n\t\tlines.push( '', `## ${ component.name }` );\n\t\tif ( description ) {\n\t\t\tlines.push( '', description );\n\t\t}\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 = [\n\t\t`# ${ detail.name }`,\n\t\t'',\n\t\t`**Package:** \\`${ detail.packageName }\\``,\n\t];\n\n\tif ( detail.description ) {\n\t\tlines.push( '', detail.description );\n\t}\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.description ) {\n\t\t\t\tlines.push( '', story.description );\n\t\t\t}\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":";;;;;;;AAQA,SAAgB,iBAAkB,YAAkC;CACnE,MAAM,QAAQ,CAAE,sCAAuC;CAEvD,KAAM,MAAM,aAAa,YAAa;EAGrC,MAAM,cAAc,UAAU,YAAY,MAAO,WAAW,CAAE,CAAC,CAAE;EAC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T;CAGD,OAAO,MAAM,KAAM,IAAK;AACzB"}
|
|
@@ -9,7 +9,7 @@ import { formatComponents } from "../format.mjs";
|
|
|
9
9
|
function register(server) {
|
|
10
10
|
server.registerTool("get_components", {
|
|
11
11
|
title: "Get Components",
|
|
12
|
-
description: "Get a list of all available WordPress Design System components with
|
|
12
|
+
description: "Get a list of all available WordPress Design System components with short descriptions.",
|
|
13
13
|
annotations: { readOnlyHint: true }
|
|
14
14
|
}, async () => {
|
|
15
15
|
const components = await getComponents();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-components.mjs","names":[],"sources":["../../src/tools/get-components.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/server';\nimport { getComponents } from '../data.ts';\nimport { formatComponents } from '../format.ts';\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
|
|
1
|
+
{"version":3,"file":"get-components.mjs","names":[],"sources":["../../src/tools/get-components.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/server';\nimport { getComponents } from '../data.ts';\nimport { formatComponents } from '../format.ts';\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 short 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"],"mappings":";;;;;;;;AASA,SAAgB,SAAU,QAA0B;CACnD,OAAO,aACN,kBACA;EACC,OAAO;EACP,aACC;EACD,aAAa,EACZ,cAAc,KACf;CACD,GACA,YAAY;EACX,MAAM,aAAa,MAAM,cAAc;EACvC,OAAO,EACN,SAAS,CACR;GACC,MAAM;GACN,MAAM,iBAAkB,UAAW;EACpC,CACD,EACD;CACD,CACD;AACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../src/tools/index.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/server';\nimport { register as getComponents } from './get-components.ts';\nimport { register as getComponentDetails } from './get-component-details.ts';\nimport { register as getDesignTokens } from './get-design-tokens.ts';\nimport { register as getPatterns } from './get-patterns.ts';\nimport { register as getPatternDetails } from './get-pattern-details.ts';\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\tgetPatterns( server );\n\tgetPatternDetails( server );\n}\n"],"mappings":";;;;;;;;;;;AAYA,SAAgB,cAAe,QAA0B;
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["getComponents","getComponentDetails","getDesignTokens","getPatterns","getPatternDetails"],"sources":["../../src/tools/index.ts"],"sourcesContent":["import type { McpServer } from '@modelcontextprotocol/server';\nimport { register as getComponents } from './get-components.ts';\nimport { register as getComponentDetails } from './get-component-details.ts';\nimport { register as getDesignTokens } from './get-design-tokens.ts';\nimport { register as getPatterns } from './get-patterns.ts';\nimport { register as getPatternDetails } from './get-pattern-details.ts';\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\tgetPatterns( server );\n\tgetPatternDetails( server );\n}\n"],"mappings":";;;;;;;;;;;AAYA,SAAgB,cAAe,QAA0B;CACxDA,SAAe,MAAO;CACtBC,WAAqB,MAAO;CAC5BC,WAAiB,MAAO;CACxBC,WAAa,MAAO;CACpBC,WAAmB,MAAO;AAC3B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"format.d.ts","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAEtE;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAE,UAAU,EAAE,SAAS,EAAE,GAAI,MAAM,CAclE;AAED;;;;;GAKG;AACH,wBAAgB,qBAAqB,CAAE,MAAM,EAAE,eAAe,GAAI,MAAM,CAsDvE;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAE,QAAQ,EAAE,OAAO,EAAE,GAAI,MAAM,CAmB5D"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/design-system-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.18.0",
|
|
4
4
|
"description": "MCP server for the WordPress Design System.",
|
|
5
5
|
"author": "The WordPress Contributors",
|
|
6
6
|
"license": "GPL-2.0-or-later",
|
|
@@ -42,14 +42,14 @@
|
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@cfworker/json-schema": "^4.1.1",
|
|
44
44
|
"@modelcontextprotocol/server": "2.0.0-alpha.2",
|
|
45
|
-
"zod": "^4.
|
|
45
|
+
"zod": "^4.6.6"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@types/node": "^
|
|
49
|
-
"vitest": "^5.1.
|
|
48
|
+
"@types/node": "^22.20.5",
|
|
49
|
+
"vitest": "^5.1.1"
|
|
50
50
|
},
|
|
51
51
|
"publishConfig": {
|
|
52
52
|
"access": "public"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "7f19202f61aeba8f4bdce892a1a0df485ad76e2b"
|
|
55
55
|
}
|