@wordpress/design-system-mcp 0.2.1-next.v.202605131032.0 → 0.4.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/index.mjs +17 -5
- package/build-module/index.mjs.map +2 -2
- package/build-module/tools/get-component-details.mjs +54 -26
- package/build-module/tools/get-component-details.mjs.map +2 -2
- package/build-types/index.d.ts +1 -0
- package/build-types/index.d.ts.map +1 -1
- package/build-types/tools/get-component-details.d.ts +18 -0
- package/build-types/tools/get-component-details.d.ts.map +1 -1
- package/build-types/tools/test/get-component-details.d.ts +2 -0
- package/build-types/tools/test/get-component-details.d.ts.map +1 -0
- package/build-types/types.d.ts +2 -10
- package/build-types/types.d.ts.map +1 -1
- package/package.json +4 -3
package/build-module/index.mjs
CHANGED
|
@@ -1,15 +1,27 @@
|
|
|
1
1
|
// packages/design-system-mcp/src/index.ts
|
|
2
2
|
import { McpServer } from "@modelcontextprotocol/server";
|
|
3
3
|
import { registerTools } from "./tools/index.mjs";
|
|
4
|
+
import { parseComponents, parseComponentDetail } from "./parse-components.mjs";
|
|
4
5
|
function createServer() {
|
|
5
|
-
const server = new McpServer(
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const server = new McpServer(
|
|
7
|
+
{
|
|
8
|
+
name: "WordPress Design System",
|
|
9
|
+
version: "0.1.0"
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
instructions: [
|
|
13
|
+
"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.",
|
|
14
|
+
'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.',
|
|
15
|
+
"`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."
|
|
16
|
+
].join("\n\n")
|
|
17
|
+
}
|
|
18
|
+
);
|
|
9
19
|
registerTools(server);
|
|
10
20
|
return server;
|
|
11
21
|
}
|
|
12
22
|
export {
|
|
13
|
-
createServer
|
|
23
|
+
createServer,
|
|
24
|
+
parseComponentDetail,
|
|
25
|
+
parseComponents
|
|
14
26
|
};
|
|
15
27
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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(
|
|
5
|
-
"mappings": ";AAAA,SAAS,iBAAiB;AAC1B,SAAS,qBAAqB;
|
|
4
|
+
"sourcesContent": ["import { McpServer } from '@modelcontextprotocol/server';\nimport { registerTools } from './tools/index';\n\nexport { parseComponents, parseComponentDetail } from './parse-components';\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
6
|
"names": []
|
|
7
7
|
}
|
|
@@ -2,44 +2,72 @@
|
|
|
2
2
|
import { z } from "zod";
|
|
3
3
|
import { getComponentDetail } from "../data.mjs";
|
|
4
4
|
import { formatComponentDetail } from "../format.mjs";
|
|
5
|
+
var inputSchema = z.object({
|
|
6
|
+
name: z.union([
|
|
7
|
+
z.string().min(1),
|
|
8
|
+
z.array(z.string().min(1)).min(1).max(10)
|
|
9
|
+
]).describe(
|
|
10
|
+
'A component name, or an array of component names to fetch in a single call (e.g. "Button" or ["Button", "Tabs"]).'
|
|
11
|
+
)
|
|
12
|
+
});
|
|
13
|
+
async function handler({ name }) {
|
|
14
|
+
const names = Array.isArray(name) ? name : [name];
|
|
15
|
+
const sections = [];
|
|
16
|
+
const missing = [];
|
|
17
|
+
for (const componentName of names) {
|
|
18
|
+
const detail = await getComponentDetail(componentName);
|
|
19
|
+
if (detail) {
|
|
20
|
+
sections.push(formatComponentDetail(detail));
|
|
21
|
+
} else {
|
|
22
|
+
missing.push(componentName);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
if (sections.length === 0) {
|
|
26
|
+
const list = missing.map((n) => `"${n}"`).join(", ");
|
|
27
|
+
return {
|
|
28
|
+
content: [
|
|
29
|
+
{
|
|
30
|
+
type: "text",
|
|
31
|
+
text: `No components were found for: ${list}.`
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
isError: true
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
let text = sections.join("\n\n---\n\n");
|
|
38
|
+
if (missing.length > 0) {
|
|
39
|
+
const list = missing.map((n) => `"${n}"`).join(", ");
|
|
40
|
+
text += `
|
|
41
|
+
|
|
42
|
+
---
|
|
43
|
+
|
|
44
|
+
_No components were found for: ${list}._`;
|
|
45
|
+
}
|
|
46
|
+
return {
|
|
47
|
+
content: [
|
|
48
|
+
{
|
|
49
|
+
type: "text",
|
|
50
|
+
text
|
|
51
|
+
}
|
|
52
|
+
]
|
|
53
|
+
};
|
|
54
|
+
}
|
|
5
55
|
function register(server) {
|
|
6
56
|
server.registerTool(
|
|
7
57
|
"get_component_details",
|
|
8
58
|
{
|
|
9
59
|
title: "Get Component Details",
|
|
10
|
-
description: "Get detailed documentation for
|
|
11
|
-
inputSchema
|
|
12
|
-
name: z.string().min(1).describe('The component name (e.g. "Button", "Tabs")')
|
|
13
|
-
}),
|
|
60
|
+
description: "Get detailed documentation for one or more WordPress Design System components including props, usage examples, and import statements. Pass multiple names to fetch several components in a single call instead of making repeated calls.",
|
|
61
|
+
inputSchema,
|
|
14
62
|
annotations: {
|
|
15
63
|
readOnlyHint: true
|
|
16
64
|
}
|
|
17
65
|
},
|
|
18
|
-
|
|
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
|
-
}
|
|
66
|
+
handler
|
|
40
67
|
);
|
|
41
68
|
}
|
|
42
69
|
export {
|
|
70
|
+
handler,
|
|
43
71
|
register
|
|
44
72
|
};
|
|
45
73
|
//# sourceMappingURL=get-component-details.mjs.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
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\
|
|
5
|
-
"mappings": ";AACA,SAAS,SAAS;AAClB,SAAS,0BAA0B;AACnC,SAAS,6BAA6B;
|
|
4
|
+
"sourcesContent": ["import type { McpServer } from '@modelcontextprotocol/server';\nimport { z } from 'zod';\nimport { getComponentDetail } from '../data';\nimport { formatComponentDetail } from '../format';\n\nconst inputSchema = z.object( {\n\tname: z\n\t\t.union( [\n\t\t\tz.string().min( 1 ),\n\t\t\tz.array( z.string().min( 1 ) ).min( 1 ).max( 10 ),\n\t\t] )\n\t\t.describe(\n\t\t\t'A component name, or an array of component names to fetch in a single call (e.g. \"Button\" or [\"Button\", \"Tabs\"]).'\n\t\t),\n} );\n\nexport async function handler( { name }: z.infer< typeof inputSchema > ) {\n\tconst names = Array.isArray( name ) ? name : [ name ];\n\tconst sections: string[] = [];\n\tconst missing: string[] = [];\n\n\tfor ( const componentName of names ) {\n\t\tconst detail = await getComponentDetail( componentName );\n\t\tif ( detail ) {\n\t\t\tsections.push( formatComponentDetail( detail ) );\n\t\t} else {\n\t\t\tmissing.push( componentName );\n\t\t}\n\t}\n\n\tif ( sections.length === 0 ) {\n\t\tconst list = missing.map( ( n ) => `\"${ n }\"` ).join( ', ' );\n\t\treturn {\n\t\t\tcontent: [\n\t\t\t\t{\n\t\t\t\t\ttype: 'text' as const,\n\t\t\t\t\ttext: `No components were found for: ${ list }.`,\n\t\t\t\t},\n\t\t\t],\n\t\t\tisError: true,\n\t\t};\n\t}\n\n\tlet text = sections.join( '\\n\\n---\\n\\n' );\n\tif ( missing.length > 0 ) {\n\t\tconst list = missing.map( ( n ) => `\"${ n }\"` ).join( ', ' );\n\t\ttext += `\\n\\n---\\n\\n_No components were found for: ${ list }._`;\n\t}\n\n\treturn {\n\t\tcontent: [\n\t\t\t{\n\t\t\t\ttype: 'text' as const,\n\t\t\t\ttext,\n\t\t\t},\n\t\t],\n\t};\n}\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 one or more WordPress Design System components including props, usage examples, and import statements. Pass multiple names to fetch several components in a single call instead of making repeated calls.',\n\t\t\tinputSchema,\n\t\t\tannotations: {\n\t\t\t\treadOnlyHint: true,\n\t\t\t},\n\t\t},\n\t\thandler\n\t);\n}\n"],
|
|
5
|
+
"mappings": ";AACA,SAAS,SAAS;AAClB,SAAS,0BAA0B;AACnC,SAAS,6BAA6B;AAEtC,IAAM,cAAc,EAAE,OAAQ;AAAA,EAC7B,MAAM,EACJ,MAAO;AAAA,IACP,EAAE,OAAO,EAAE,IAAK,CAAE;AAAA,IAClB,EAAE,MAAO,EAAE,OAAO,EAAE,IAAK,CAAE,CAAE,EAAE,IAAK,CAAE,EAAE,IAAK,EAAG;AAAA,EACjD,CAAE,EACD;AAAA,IACA;AAAA,EACD;AACF,CAAE;AAEF,eAAsB,QAAS,EAAE,KAAK,GAAmC;AACxE,QAAM,QAAQ,MAAM,QAAS,IAAK,IAAI,OAAO,CAAE,IAAK;AACpD,QAAM,WAAqB,CAAC;AAC5B,QAAM,UAAoB,CAAC;AAE3B,aAAY,iBAAiB,OAAQ;AACpC,UAAM,SAAS,MAAM,mBAAoB,aAAc;AACvD,QAAK,QAAS;AACb,eAAS,KAAM,sBAAuB,MAAO,CAAE;AAAA,IAChD,OAAO;AACN,cAAQ,KAAM,aAAc;AAAA,IAC7B;AAAA,EACD;AAEA,MAAK,SAAS,WAAW,GAAI;AAC5B,UAAM,OAAO,QAAQ,IAAK,CAAE,MAAO,IAAK,CAAE,GAAI,EAAE,KAAM,IAAK;AAC3D,WAAO;AAAA,MACN,SAAS;AAAA,QACR;AAAA,UACC,MAAM;AAAA,UACN,MAAM,iCAAkC,IAAK;AAAA,QAC9C;AAAA,MACD;AAAA,MACA,SAAS;AAAA,IACV;AAAA,EACD;AAEA,MAAI,OAAO,SAAS,KAAM,aAAc;AACxC,MAAK,QAAQ,SAAS,GAAI;AACzB,UAAM,OAAO,QAAQ,IAAK,CAAE,MAAO,IAAK,CAAE,GAAI,EAAE,KAAM,IAAK;AAC3D,YAAQ;AAAA;AAAA;AAAA;AAAA,iCAA8C,IAAK;AAAA,EAC5D;AAEA,SAAO;AAAA,IACN,SAAS;AAAA,MACR;AAAA,QACC,MAAM;AAAA,QACN;AAAA,MACD;AAAA,IACD;AAAA,EACD;AACD;AAOO,SAAS,SAAU,QAA0B;AACnD,SAAO;AAAA,IACN;AAAA,IACA;AAAA,MACC,OAAO;AAAA,MACP,aACC;AAAA,MACD;AAAA,MACA,aAAa;AAAA,QACZ,cAAc;AAAA,MACf;AAAA,IACD;AAAA,IACA;AAAA,EACD;AACD;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/build-types/index.d.ts
CHANGED
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAGzD,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAE3E,wBAAgB,YAAY,cAkB3B"}
|
|
@@ -1,8 +1,26 @@
|
|
|
1
1
|
import type { McpServer } from '@modelcontextprotocol/server';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
declare const inputSchema: z.ZodObject<{
|
|
4
|
+
name: z.ZodUnion<readonly [z.ZodString, z.ZodArray<z.ZodString>]>;
|
|
5
|
+
}, z.core.$strip>;
|
|
6
|
+
export declare function handler({ name }: z.infer<typeof inputSchema>): Promise<{
|
|
7
|
+
content: {
|
|
8
|
+
type: 'text';
|
|
9
|
+
text: string;
|
|
10
|
+
}[];
|
|
11
|
+
isError: boolean;
|
|
12
|
+
} | {
|
|
13
|
+
isError?: undefined;
|
|
14
|
+
content: {
|
|
15
|
+
type: 'text';
|
|
16
|
+
text: string;
|
|
17
|
+
}[];
|
|
18
|
+
}>;
|
|
2
19
|
/**
|
|
3
20
|
* Register the get_component_details tool.
|
|
4
21
|
*
|
|
5
22
|
* @param server - The MCP server instance.
|
|
6
23
|
*/
|
|
7
24
|
export declare function register(server: McpServer): void;
|
|
25
|
+
export {};
|
|
8
26
|
//# sourceMappingURL=get-component-details.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-component-details.d.ts","sourceRoot":"","sources":["../../src/tools/get-component-details.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"get-component-details.d.ts","sourceRoot":"","sources":["../../src/tools/get-component-details.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAIxB,QAAA,MAAM,WAAW;;iBASd,CAAC;AAEJ,wBAAsB,OAAO,CAAE,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,KAAK,CAAE,OAAO,WAAW,CAAE;;cAmB3D,MAAM;;;;;;;cAiBP,MAAM;;;GAKf;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAE,MAAM,EAAE,SAAS,GAAI,IAAI,CAclD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-component-details.d.ts","sourceRoot":"","sources":["../../../src/tools/test/get-component-details.ts"],"names":[],"mappings":""}
|
package/build-types/types.d.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
name: string;
|
|
4
|
-
path: string;
|
|
5
|
-
description?: string;
|
|
6
|
-
stories?: Array<{
|
|
7
|
-
name: string;
|
|
8
|
-
snippet?: string;
|
|
9
|
-
description?: string;
|
|
10
|
-
}>;
|
|
1
|
+
import type { ComponentManifest } from 'storybook/internal/types';
|
|
2
|
+
export interface ManifestComponent extends ComponentManifest {
|
|
11
3
|
reactDocgen?: {
|
|
12
4
|
description?: string;
|
|
13
5
|
displayName?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAElE,MAAM,WAAW,iBAAkB,SAAQ,iBAAiB;IAC3D,WAAW,CAAC,EAAE;QACb,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,KAAK,CAAC,EAAE,MAAM,CACb,MAAM,EACN;YACC,QAAQ,CAAC,EAAE,OAAO,CAAC;YACnB,MAAM,CAAC,EAAE;gBAAE,IAAI,EAAE,MAAM,CAAC;gBAAC,GAAG,CAAC,EAAE,MAAM,CAAA;aAAE,CAAC;YACxC,WAAW,CAAC,EAAE,MAAM,CAAC;YACrB,YAAY,CAAC,EAAE;gBAAE,KAAK,EAAE,MAAM,CAAA;aAAE,CAAC;SACjC,CACD,CAAC;KACF,CAAC;CACF;AAED,MAAM,WAAW,SAAS;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC5B;AAED,MAAM,WAAW,eAAe;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,OAAO,EAAE,KAAK,CAAE;QACf,IAAI,EAAE,MAAM,CAAC;QACb,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,MAAM,CAAC;KACrB,CAAE,CAAC;CACJ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wordpress/design-system-mcp",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.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",
|
|
@@ -46,10 +46,11 @@
|
|
|
46
46
|
"zod": "4.3.6"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@types/jest": "^29.5.14"
|
|
49
|
+
"@types/jest": "^29.5.14",
|
|
50
|
+
"storybook": "^10.2.8"
|
|
50
51
|
},
|
|
51
52
|
"publishConfig": {
|
|
52
53
|
"access": "public"
|
|
53
54
|
},
|
|
54
|
-
"gitHead": "
|
|
55
|
+
"gitHead": "d653c5fd6161571a0c2ebde28553d6e25624eacc"
|
|
55
56
|
}
|