@primer/mcp 0.3.1 → 0.3.2-rc.d5c143d51

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.js CHANGED
@@ -1,4 +1,4 @@
1
- export { s as server } from './server-owUZMSeG.js';
1
+ export { s as server } from './server-DRag4xtw.js';
2
2
  import '@modelcontextprotocol/sdk/server/mcp.js';
3
3
  import 'cheerio';
4
4
  import 'zod';
@@ -736,7 +736,7 @@ function runStylelint(css) {
736
736
  });
737
737
  }
738
738
 
739
- var version = "0.3.1";
739
+ var version = "0.3.2";
740
740
  var packageJson = {
741
741
  version: version};
742
742
 
@@ -833,10 +833,10 @@ server.registerTool('get_component', {
833
833
  content: []
834
834
  };
835
835
  }
836
- const llmsUrl = new URL(`/product/components/${match.slug}/llms.txt`, 'https://primer.style');
837
- const llmsResponse = await fetch(llmsUrl);
838
- if (llmsResponse.ok) {
839
- try {
836
+ try {
837
+ const llmsUrl = new URL(`/product/components/${match.slug}/llms.txt`, 'https://primer.style');
838
+ const llmsResponse = await fetch(llmsUrl);
839
+ if (llmsResponse.ok) {
840
840
  const llmsText = await llmsResponse.text();
841
841
  return {
842
842
  content: [{
@@ -844,35 +844,14 @@ server.registerTool('get_component', {
844
844
  text: llmsText
845
845
  }]
846
846
  };
847
- } catch (_) {
848
- // If there's an error fetching or processing the llms.txt, we fall back to the regular documentation
849
847
  }
848
+ } catch (_) {
849
+ // If there's an error fetching or processing the llms.txt, we fall back to a generic error message.
850
850
  }
851
- const url = new URL(`/product/components/${match.slug}`, 'https://primer.style');
852
- const response = await fetch(url);
853
- if (!response.ok) {
854
- throw new Error(`Failed to fetch ${url}: ${response.statusText}`);
855
- }
856
- const html = await response.text();
857
- if (!html) {
858
- return {
859
- content: []
860
- };
861
- }
862
- const $ = cheerio.load(html);
863
- const source = $('main').html();
864
- if (!source) {
865
- return {
866
- content: []
867
- };
868
- }
869
- const text = turndownService.turndown(source);
870
851
  return {
871
- content: [{
872
- type: 'text',
873
- text: `Here is the documentation for the \`${name}\` component from the @primer/react package:
874
- ${text}`
875
- }]
852
+ isError: true,
853
+ errorMessage: `There was an error fetching documentation for ${name}. Ensure the component exists.`,
854
+ content: []
876
855
  };
877
856
  });
878
857
  server.registerTool('get_component_examples', {
package/dist/stdio.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { StdioServerTransport } from '@modelcontextprotocol/sdk/server/stdio.js';
2
- import { s as server } from './server-owUZMSeG.js';
2
+ import { s as server } from './server-DRag4xtw.js';
3
3
  import '@modelcontextprotocol/sdk/server/mcp.js';
4
4
  import 'cheerio';
5
5
  import 'zod';
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.3.1",
4
+ "version": "0.3.2-rc.d5c143d51",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "mcp": "./bin/mcp.js"
@@ -37,7 +37,7 @@
37
37
  "@modelcontextprotocol/sdk": "^1.24.0",
38
38
  "@primer/octicons": "^19.15.5",
39
39
  "@primer/primitives": "10.x || 11.x",
40
- "@primer/react": "^38.15.0",
40
+ "@primer/react": "^38.19.1",
41
41
  "cheerio": "^1.0.0",
42
42
  "turndown": "^7.2.0",
43
43
  "zod": "^4.3.5"
package/src/server.ts CHANGED
@@ -133,11 +133,10 @@ server.registerTool(
133
133
  content: [],
134
134
  }
135
135
  }
136
-
137
- const llmsUrl = new URL(`/product/components/${match.slug}/llms.txt`, 'https://primer.style')
138
- const llmsResponse = await fetch(llmsUrl)
139
- if (llmsResponse.ok) {
140
- try {
136
+ try {
137
+ const llmsUrl = new URL(`/product/components/${match.slug}/llms.txt`, 'https://primer.style')
138
+ const llmsResponse = await fetch(llmsUrl)
139
+ if (llmsResponse.ok) {
141
140
  const llmsText = await llmsResponse.text()
142
141
  return {
143
142
  content: [
@@ -147,42 +146,15 @@ server.registerTool(
147
146
  },
148
147
  ],
149
148
  }
150
- } catch (_: unknown) {
151
- // If there's an error fetching or processing the llms.txt, we fall back to the regular documentation
152
- }
153
- }
154
-
155
- const url = new URL(`/product/components/${match.slug}`, 'https://primer.style')
156
- const response = await fetch(url)
157
- if (!response.ok) {
158
- throw new Error(`Failed to fetch ${url}: ${response.statusText}`)
159
- }
160
-
161
- const html = await response.text()
162
- if (!html) {
163
- return {
164
- content: [],
165
- }
166
- }
167
-
168
- const $ = cheerio.load(html)
169
- const source = $('main').html()
170
- if (!source) {
171
- return {
172
- content: [],
173
149
  }
150
+ } catch (_: unknown) {
151
+ // If there's an error fetching or processing the llms.txt, we fall back to a generic error message.
174
152
  }
175
153
 
176
- const text = turndownService.turndown(source)
177
-
178
154
  return {
179
- content: [
180
- {
181
- type: 'text',
182
- text: `Here is the documentation for the \`${name}\` component from the @primer/react package:
183
- ${text}`,
184
- },
185
- ],
155
+ isError: true,
156
+ errorMessage: `There was an error fetching documentation for ${name}. Ensure the component exists.`,
157
+ content: [],
186
158
  }
187
159
  },
188
160
  )
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- export { server } from './server';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,MAAM,EAAC,MAAM,UAAU,CAAA"}
package/dist/primer.d.ts DELETED
@@ -1,20 +0,0 @@
1
- type Component = {
2
- id: string;
3
- name: string;
4
- importPath: string;
5
- slug: string;
6
- };
7
- declare function listComponents(): Array<Component>;
8
- type Pattern = {
9
- id: string;
10
- name: string;
11
- };
12
- declare function listPatterns(): Array<Pattern>;
13
- type Icon = {
14
- name: string;
15
- keywords: Array<string>;
16
- heights: Array<string>;
17
- };
18
- declare function listIcons(): Array<Icon>;
19
- export { listComponents, listPatterns, listIcons };
20
- //# sourceMappingURL=primer.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"primer.d.ts","sourceRoot":"","sources":["../src/primer.ts"],"names":[],"mappings":"AAGA,KAAK,SAAS,GAAG;IACf,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AA2BD,iBAAS,cAAc,IAAI,KAAK,CAAC,SAAS,CAAC,CAE1C;AAED,KAAK,OAAO,GAAG;IACb,EAAE,EAAE,MAAM,CAAA;IACV,IAAI,EAAE,MAAM,CAAA;CACb,CAAA;AA6CD,iBAAS,YAAY,IAAI,KAAK,CAAC,OAAO,CAAC,CAEtC;AAED,KAAK,IAAI,GAAG;IACV,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;IACvB,OAAO,EAAE,KAAK,CAAC,MAAM,CAAC,CAAA;CACvB,CAAA;AAUD,iBAAS,SAAS,IAAI,KAAK,CAAC,IAAI,CAAC,CAEhC;AAED,OAAO,EAAC,cAAc,EAAE,YAAY,EAAE,SAAS,EAAC,CAAA"}
@@ -1,184 +0,0 @@
1
- declare const categories: {
2
- readonly base: {
3
- readonly motion: {
4
- name: string;
5
- type: string;
6
- value: number[] | {
7
- value: number;
8
- unit: string;
9
- } | {
10
- value: number;
11
- unit: string;
12
- } | {
13
- value: number;
14
- unit: string;
15
- } | {
16
- value: number;
17
- unit: string;
18
- } | {
19
- value: number;
20
- unit: string;
21
- } | {
22
- value: number;
23
- unit: string;
24
- } | {
25
- value: number;
26
- unit: string;
27
- } | {
28
- value: number;
29
- unit: string;
30
- } | {
31
- value: number;
32
- unit: string;
33
- } | {
34
- value: number;
35
- unit: string;
36
- } | {
37
- value: number;
38
- unit: string;
39
- } | {
40
- value: number;
41
- unit: string;
42
- };
43
- }[];
44
- readonly size: {
45
- name: string;
46
- type: string;
47
- value: string;
48
- }[];
49
- readonly typography: {
50
- name: string;
51
- type: string;
52
- value: string | number;
53
- }[];
54
- };
55
- readonly functional: {
56
- readonly border: {
57
- name: string;
58
- type: string;
59
- value: string;
60
- }[];
61
- readonly radius: {
62
- name: string;
63
- type: string;
64
- value: string;
65
- }[];
66
- readonly sizeCoarse: {
67
- name: string;
68
- type: string;
69
- value: string;
70
- }[];
71
- readonly sizeFine: {
72
- name: string;
73
- type: string;
74
- value: string;
75
- }[];
76
- readonly size: {
77
- name: string;
78
- type: string;
79
- value: string;
80
- }[];
81
- readonly themes: {
82
- readonly light: {
83
- name: string;
84
- type: string;
85
- value: string;
86
- }[];
87
- };
88
- readonly typography: {
89
- name: string;
90
- type: string;
91
- value: string | number;
92
- }[];
93
- };
94
- };
95
- declare const tokens: ({
96
- name: string;
97
- type: string;
98
- value: number[] | {
99
- value: number;
100
- unit: string;
101
- } | {
102
- value: number;
103
- unit: string;
104
- } | {
105
- value: number;
106
- unit: string;
107
- } | {
108
- value: number;
109
- unit: string;
110
- } | {
111
- value: number;
112
- unit: string;
113
- } | {
114
- value: number;
115
- unit: string;
116
- } | {
117
- value: number;
118
- unit: string;
119
- } | {
120
- value: number;
121
- unit: string;
122
- } | {
123
- value: number;
124
- unit: string;
125
- } | {
126
- value: number;
127
- unit: string;
128
- } | {
129
- value: number;
130
- unit: string;
131
- } | {
132
- value: number;
133
- unit: string;
134
- };
135
- } | {
136
- name: string;
137
- type: string;
138
- value: string | number;
139
- })[];
140
- declare function serialize(value: typeof tokens): string;
141
- type TokenGroup = {
142
- name: string;
143
- count: number;
144
- subGroups?: string[];
145
- };
146
- type TokenGroups = {
147
- semantic: TokenGroup[];
148
- component: TokenGroup[];
149
- };
150
- declare function listTokenGroups(): TokenGroups;
151
- export { categories, tokens, serialize, listTokenGroups, type TokenGroups };
152
- type TokenWithGuidelines = {
153
- name: string;
154
- value: string;
155
- useCase: string;
156
- rules: string;
157
- group: string;
158
- };
159
- declare function parseDesignTokensSpec(markdown: string): TokenWithGuidelines[];
160
- declare const GROUP_LABELS: Record<string, string>;
161
- declare function buildAllTokens(guidelinesTokens: TokenWithGuidelines[]): TokenWithGuidelines[];
162
- declare function findTokens(allTokens: TokenWithGuidelines[], query: string, group?: string): TokenWithGuidelines[];
163
- declare function expandTokenPattern(token: TokenWithGuidelines): TokenWithGuidelines[];
164
- declare function loadAllTokensWithGuidelines(): TokenWithGuidelines[];
165
- declare function loadDesignTokensGuide(): string;
166
- declare function loadDesignTokensSpec(): string;
167
- declare function getDesignTokenSpecsText(groups: TokenGroups): string;
168
- declare function getTokenUsagePatternsText(): string;
169
- declare function searchTokens(allTokens: TokenWithGuidelines[], query: string, group?: string): TokenWithGuidelines[];
170
- declare const GROUP_ALIASES: Record<string, string>;
171
- declare function tokenMatchesGroup(token: TokenWithGuidelines, resolvedGroup: string): boolean;
172
- declare function formatBundle(bundleTokens: TokenWithGuidelines[]): string;
173
- /**
174
- * Generates a sorted, unique list of group names from the current token cache.
175
- * Used for "Healing" error messages and the Design System Search Map.
176
- */
177
- declare function getValidGroupsList(validTokens: TokenWithGuidelines[]): string;
178
- declare const groupHints: Record<string, string>;
179
- declare function runStylelint(css: string): Promise<{
180
- stdout: string;
181
- stderr: string;
182
- }>;
183
- export { parseDesignTokensSpec, findTokens, buildAllTokens, expandTokenPattern, loadAllTokensWithGuidelines, loadDesignTokensGuide, loadDesignTokensSpec, getDesignTokenSpecsText, getTokenUsagePatternsText, getValidGroupsList, searchTokens, formatBundle, groupHints, GROUP_ALIASES, GROUP_LABELS, tokenMatchesGroup, runStylelint, type TokenWithGuidelines, };
184
- //# sourceMappingURL=primitives.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../src/primitives.ts"],"names":[],"mappings":"AAuBA,QAAA,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6EN,CAAA;AAEV,QAAA,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,uBAAuB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CA0C5D;AAGD,iBAAS,yBAAyB,IAAI,MAAM,CA6F3C;AAID,iBAAS,YAAY,CAAC,SAAS,EAAE,mBAAmB,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,GAAG,mBAAmB,EAAE,CAsB5G;AAGD,QAAA,MAAM,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA6EzC,CAAA;AAGD,iBAAS,iBAAiB,CAAC,KAAK,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAKrF;AAGD,iBAAS,YAAY,CAAC,YAAY,EAAE,mBAAmB,EAAE,GAAG,MAAM,CAoBjE;AAED;;;GAGG;AACH,iBAAS,kBAAkB,CAAC,WAAW,EAAE,mBAAmB,EAAE,GAAG,MAAM,CAatE;AAGD,QAAA,MAAM,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAStC,CAAA;AAKD,iBAAS,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAC,CAAC,CAkC5E;AAED,OAAO,EACL,qBAAqB,EACrB,UAAU,EACV,cAAc,EACd,kBAAkB,EAClB,2BAA2B,EAC3B,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,yBAAyB,EACzB,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,YAAY,EACZ,KAAK,mBAAmB,GACzB,CAAA"}
package/dist/server.d.ts DELETED
@@ -1,4 +0,0 @@
1
- import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- declare const server: McpServer;
3
- export { server };
4
- //# sourceMappingURL=server.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../src/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,SAAS,EAAC,MAAM,yCAAyC,CAAA;AAwBjE,QAAA,MAAM,MAAM,WAGV,CAAA;AA27BF,OAAO,EAAC,MAAM,EAAC,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=stdio.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"stdio.d.ts","sourceRoot":"","sources":["../../src/transports/stdio.ts"],"names":[],"mappings":""}