@primer/mcp 0.3.4 → 0.4.0-rc.2d1806208
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/dist/index.d.ts +6 -0
- package/dist/index.js +2 -19
- package/dist/server-BTJ9W5jN.js +1190 -0
- package/dist/stdio.js +5 -21
- package/dist/transports/stdio.d.ts +1 -0
- package/package.json +6 -15
- package/src/primer.ts +33 -0
- package/src/server.ts +24 -11
- package/dist/server-C2QaEv-c.js +0 -1504
- package/dist/server-CGPYmiEJ.js +0 -1504
- package/dist/server-CaSuVJt0.js +0 -1561
package/dist/stdio.js
CHANGED
|
@@ -1,23 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import 'cheerio';
|
|
5
|
-
import 'zod';
|
|
6
|
-
import 'turndown';
|
|
7
|
-
import '@primer/react/generated/components.json' with { type: 'json' };
|
|
8
|
-
import '@primer/octicons/build/data.json' with { type: 'json' };
|
|
9
|
-
import 'node:fs';
|
|
10
|
-
import 'node:module';
|
|
11
|
-
import 'child_process';
|
|
12
|
-
import '@primer/primitives/dist/docs/base/motion/motion.json' with { type: 'json' };
|
|
13
|
-
import '@primer/primitives/dist/docs/base/size/size.json' with { type: 'json' };
|
|
14
|
-
import '@primer/primitives/dist/docs/base/typography/typography.json' with { type: 'json' };
|
|
15
|
-
import '@primer/primitives/dist/docs/functional/size/border.json' with { type: 'json' };
|
|
16
|
-
import '@primer/primitives/dist/docs/functional/size/size-coarse.json' with { type: 'json' };
|
|
17
|
-
import '@primer/primitives/dist/docs/functional/size/size-fine.json' with { type: 'json' };
|
|
18
|
-
import '@primer/primitives/dist/docs/functional/size/size.json' with { type: 'json' };
|
|
19
|
-
import '@primer/primitives/dist/docs/functional/themes/light.json' with { type: 'json' };
|
|
20
|
-
import '@primer/primitives/dist/docs/functional/typography/typography.json' with { type: 'json' };
|
|
21
|
-
|
|
1
|
+
import { t as server } from "./server-BTJ9W5jN.js";
|
|
2
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
3
|
+
//#region src/transports/stdio.ts
|
|
22
4
|
const transport = new StdioServerTransport();
|
|
23
5
|
await server.connect(transport);
|
|
6
|
+
//#endregion
|
|
7
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@primer/mcp",
|
|
3
3
|
"description": "An MCP server that connects AI tools to the Primer Design System",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.4.0-rc.2d1806208",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
7
7
|
"mcp": "./bin/mcp.js"
|
|
@@ -28,34 +28,25 @@
|
|
|
28
28
|
},
|
|
29
29
|
"scripts": {
|
|
30
30
|
"clean": "rimraf dist",
|
|
31
|
-
"build": "
|
|
31
|
+
"build": "rolldown -c",
|
|
32
32
|
"type-check": "tsc --noEmit",
|
|
33
|
-
"watch": "
|
|
33
|
+
"watch": "rolldown -c -w"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@babel/runtime": "^7.28.6",
|
|
37
36
|
"@modelcontextprotocol/sdk": "^1.24.0",
|
|
38
37
|
"@primer/octicons": "^19.15.5",
|
|
39
38
|
"@primer/primitives": "10.x || 11.x",
|
|
40
|
-
"@primer/react": "^38.
|
|
39
|
+
"@primer/react": "^38.30.0",
|
|
41
40
|
"cheerio": "^1.0.0",
|
|
42
41
|
"turndown": "^7.2.0",
|
|
43
42
|
"zod": "^4.3.5"
|
|
44
43
|
},
|
|
45
44
|
"devDependencies": {
|
|
46
|
-
"@babel/core": "^7.29.0",
|
|
47
|
-
"@babel/plugin-transform-runtime": "^7.29.0",
|
|
48
|
-
"@babel/preset-env": "^7.29.0",
|
|
49
|
-
"@babel/preset-typescript": "^7.28.5",
|
|
50
45
|
"@modelcontextprotocol/inspector": "^0.16.6",
|
|
51
|
-
"@rollup/plugin-babel": "^6.1.0",
|
|
52
|
-
"@rollup/plugin-commonjs": "^29.0.0",
|
|
53
|
-
"@rollup/plugin-json": "^6.1.0",
|
|
54
|
-
"@rollup/plugin-node-resolve": "^16.0.3",
|
|
55
46
|
"@types/turndown": "^5.0.5",
|
|
56
47
|
"rimraf": "^6.0.1",
|
|
57
|
-
"
|
|
58
|
-
"
|
|
48
|
+
"rolldown": "^1.1.2",
|
|
49
|
+
"rolldown-plugin-dts": "^0.26.0",
|
|
59
50
|
"typescript": "^6.0.3"
|
|
60
51
|
}
|
|
61
52
|
}
|
package/src/primer.ts
CHANGED
|
@@ -40,48 +40,81 @@ function listComponents(): Array<Component> {
|
|
|
40
40
|
type Pattern = {
|
|
41
41
|
id: string
|
|
42
42
|
name: string
|
|
43
|
+
// 'scenario' maps to the /product/scenario-patterns/ base path, 'ui' to /product/ui-patterns/
|
|
44
|
+
category: 'scenario' | 'ui'
|
|
43
45
|
}
|
|
44
46
|
|
|
47
|
+
// Scenario patterns are listed first so name resolution favours them over UI patterns.
|
|
45
48
|
const patterns: Array<Pattern> = [
|
|
49
|
+
{
|
|
50
|
+
id: 'copy',
|
|
51
|
+
name: 'Copy',
|
|
52
|
+
category: 'scenario',
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
id: 'delete',
|
|
56
|
+
name: 'Delete',
|
|
57
|
+
category: 'scenario',
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
id: 'filter',
|
|
61
|
+
name: 'Filter',
|
|
62
|
+
category: 'scenario',
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
id: 'search',
|
|
66
|
+
name: 'Search',
|
|
67
|
+
category: 'scenario',
|
|
68
|
+
},
|
|
46
69
|
{
|
|
47
70
|
id: 'data-visualization',
|
|
48
71
|
name: 'Data Visualization',
|
|
72
|
+
category: 'ui',
|
|
49
73
|
},
|
|
50
74
|
{
|
|
51
75
|
id: 'degraded-experiences',
|
|
52
76
|
name: 'Degraded Experiences',
|
|
77
|
+
category: 'ui',
|
|
53
78
|
},
|
|
54
79
|
{
|
|
55
80
|
id: 'empty-states',
|
|
56
81
|
name: 'Empty States',
|
|
82
|
+
category: 'ui',
|
|
57
83
|
},
|
|
58
84
|
{
|
|
59
85
|
id: 'feature-onboarding',
|
|
60
86
|
name: 'Feature Onboarding',
|
|
87
|
+
category: 'ui',
|
|
61
88
|
},
|
|
62
89
|
{
|
|
63
90
|
id: 'forms',
|
|
64
91
|
name: 'Forms',
|
|
92
|
+
category: 'ui',
|
|
65
93
|
},
|
|
66
94
|
{
|
|
67
95
|
id: 'loading',
|
|
68
96
|
name: 'Loading',
|
|
97
|
+
category: 'ui',
|
|
69
98
|
},
|
|
70
99
|
{
|
|
71
100
|
id: 'navigation',
|
|
72
101
|
name: 'Navigation',
|
|
102
|
+
category: 'ui',
|
|
73
103
|
},
|
|
74
104
|
{
|
|
75
105
|
id: 'notification-messaging',
|
|
76
106
|
name: 'Notification message',
|
|
107
|
+
category: 'ui',
|
|
77
108
|
},
|
|
78
109
|
{
|
|
79
110
|
id: 'progressive-disclosure',
|
|
80
111
|
name: 'Progressive disclosure',
|
|
112
|
+
category: 'ui',
|
|
81
113
|
},
|
|
82
114
|
{
|
|
83
115
|
id: 'saving',
|
|
84
116
|
name: 'Saving',
|
|
117
|
+
category: 'ui',
|
|
85
118
|
},
|
|
86
119
|
]
|
|
87
120
|
|
package/src/server.ts
CHANGED
|
@@ -372,18 +372,28 @@ ${text}`,
|
|
|
372
372
|
// -----------------------------------------------------------------------------
|
|
373
373
|
server.registerTool(
|
|
374
374
|
'list_patterns',
|
|
375
|
-
{
|
|
375
|
+
{
|
|
376
|
+
description:
|
|
377
|
+
'List all of the patterns available from Primer React. Scenario patterns describe specific user tasks (copy, delete, filter, search). Prefer a scenario pattern when one fits the task, and fall back to the more generic UI patterns otherwise.',
|
|
378
|
+
annotations: {readOnlyHint: true},
|
|
379
|
+
},
|
|
376
380
|
async () => {
|
|
377
|
-
const
|
|
378
|
-
|
|
379
|
-
})
|
|
381
|
+
const all = listPatterns()
|
|
382
|
+
const scenario = all.filter(pattern => pattern.category === 'scenario').map(pattern => `- ${pattern.name}`)
|
|
383
|
+
const ui = all.filter(pattern => pattern.category === 'ui').map(pattern => `- ${pattern.name}`)
|
|
380
384
|
return {
|
|
381
385
|
content: [
|
|
382
386
|
{
|
|
383
387
|
type: 'text',
|
|
384
|
-
text: `The following patterns are available
|
|
388
|
+
text: `The following patterns are available from \`@primer/react\` for use in TypeScript projects. Scenario patterns describe specific user tasks. Prefer a scenario pattern when one fits the task, and fall back to the UI patterns otherwise.
|
|
385
389
|
|
|
386
|
-
|
|
390
|
+
## Scenario patterns
|
|
391
|
+
|
|
392
|
+
${scenario.join('\n')}
|
|
393
|
+
|
|
394
|
+
## UI patterns
|
|
395
|
+
|
|
396
|
+
${ui.join('\n')}`,
|
|
387
397
|
},
|
|
388
398
|
],
|
|
389
399
|
}
|
|
@@ -393,7 +403,8 @@ ${patterns.join('\n')}`,
|
|
|
393
403
|
server.registerTool(
|
|
394
404
|
'get_pattern',
|
|
395
405
|
{
|
|
396
|
-
description:
|
|
406
|
+
description:
|
|
407
|
+
'Get a specific pattern by name. Scenario patterns describe specific user tasks (copy, delete, filter, search). Prefer a scenario pattern when one fits the task, and fall back to the more generic UI patterns otherwise.',
|
|
397
408
|
inputSchema: {
|
|
398
409
|
name: z.string().describe('The name of the pattern to retrieve'),
|
|
399
410
|
},
|
|
@@ -401,9 +412,10 @@ server.registerTool(
|
|
|
401
412
|
},
|
|
402
413
|
async ({name}) => {
|
|
403
414
|
const patterns = listPatterns()
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
415
|
+
// Resolve scenario patterns first so a name clash favours the scenario pattern.
|
|
416
|
+
const match =
|
|
417
|
+
patterns.find(pattern => pattern.category === 'scenario' && pattern.name === name) ??
|
|
418
|
+
patterns.find(pattern => pattern.name === name)
|
|
407
419
|
if (!match) {
|
|
408
420
|
return {
|
|
409
421
|
content: [
|
|
@@ -415,7 +427,8 @@ server.registerTool(
|
|
|
415
427
|
}
|
|
416
428
|
}
|
|
417
429
|
|
|
418
|
-
const
|
|
430
|
+
const basePath = match.category === 'scenario' ? 'scenario-patterns' : 'ui-patterns'
|
|
431
|
+
const url = new URL(`/product/${basePath}/${match.id}`, 'https://primer.style')
|
|
419
432
|
const response = await fetch(url)
|
|
420
433
|
if (!response.ok) {
|
|
421
434
|
throw new Error(`Failed to fetch ${url} - ${response.statusText}`)
|