@primer/mcp 1.1.1-rc.fd837f586 → 1.1.2-rc.0c54ada7c

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 +1 @@
1
- export { t as createServer, n as server } from "./server-malh_dny.js";
1
+ export { t as createServer, n as server } from "./server-CZDOBVxP.js";
@@ -718,7 +718,7 @@ function runStylelint(css) {
718
718
  }
719
719
  //#endregion
720
720
  //#region package.json
721
- var version = "1.1.1";
721
+ var version = "1.1.2";
722
722
  //#endregion
723
723
  //#region src/server.ts
724
724
  const turndownService = new TurndownService();
@@ -847,7 +847,7 @@ Use \`get_component\` for exactly one component and \`get_component_batch\` for
847
847
  type: "text",
848
848
  text: `There is no component named \`${name}\` in the @primer/react package. For a full list of components, use the \`list_components\` tool.`
849
849
  }] };
850
- const url = new URL(`/product/components/${match.id}`, "https://primer.style");
850
+ const url = new URL(`/product/components/${match.slug}`, "https://primer.style");
851
851
  const response = await fetch(url);
852
852
  if (!response.ok) throw new Error(`Failed to fetch ${url}: ${response.statusText}`);
853
853
  const html = await response.text();
@@ -905,7 +905,7 @@ ${turndownService.turndown(source)}`
905
905
  type: "text",
906
906
  text: `There is no component named \`${name}\` in the @primer/react package. For a full list of components, use the \`list_components\` tool.`
907
907
  }] };
908
- const url = new URL(`/product/components/${match.id}/accessibility`, "https://primer.style");
908
+ const url = new URL(`/product/components/${match.slug}/accessibility`, "https://primer.style");
909
909
  const response = await fetch(url);
910
910
  if (!response.ok) {
911
911
  if (response.status >= 400 && response.status < 500 || response.status >= 300 && response.status < 400) return { content: [{
package/dist/stdio.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as createServer } from "./server-malh_dny.js";
1
+ import { t as createServer } from "./server-CZDOBVxP.js";
2
2
  import { serveStdio } from "@modelcontextprotocol/server/stdio";
3
3
  //#region src/transports/stdio.ts
4
4
  serveStdio(createServer);
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": "1.1.1-rc.fd837f586",
4
+ "version": "1.1.2-rc.0c54ada7c",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "mcp": "./bin/mcp.js"
@@ -37,11 +37,11 @@
37
37
  "watch": "rolldown -c -w"
38
38
  },
39
39
  "dependencies": {
40
- "@modelcontextprotocol/client": "^2.2.0",
41
- "@modelcontextprotocol/server": "^2.0.0",
40
+ "@modelcontextprotocol/client": "^2.3.0",
41
+ "@modelcontextprotocol/server": "^2.3.0",
42
42
  "@primer/octicons": "^19.15.5",
43
43
  "@primer/primitives": "10.x || 11.x",
44
- "@primer/react": "^38.42.0",
44
+ "@primer/react": "^38.43.0",
45
45
  "cheerio": "^1.0.0",
46
46
  "turndown": "^7.2.0",
47
47
  "zod": "^4.3.5"
@@ -51,7 +51,7 @@
51
51
  "@primer/vitest-config": "^0.0.0",
52
52
  "@types/turndown": "^5.0.5",
53
53
  "rimraf": "^6.0.1",
54
- "rolldown": "^1.2.13",
54
+ "rolldown": "^1.2.14",
55
55
  "rolldown-plugin-dts": "^0.26.0",
56
56
  "typescript": "^6.0.3"
57
57
  }
@@ -482,6 +482,56 @@ describe('MCP server', () => {
482
482
  },
483
483
  )
484
484
 
485
+ it.each([
486
+ {
487
+ tool: 'get_component_examples',
488
+ expectedPath: '/product/components/text-input',
489
+ rawIdPath: '/product/components/text_input',
490
+ },
491
+ {
492
+ tool: 'get_component_accessibility_guidelines',
493
+ expectedPath: '/product/components/text-input/accessibility',
494
+ rawIdPath: '/product/components/text_input/accessibility',
495
+ },
496
+ ] as const)('$tool uses the TextInput slug in its URL', async ({tool, expectedPath, rawIdPath}) => {
497
+ const expectedUrl = `https://primer.style${expectedPath}`
498
+ const rawIdUrl = `https://primer.style${rawIdPath}`
499
+ const responseBody = 'synthetic-text-input-documentation'
500
+ const homepageBody = 'homepage-body-not-text-input-documentation'
501
+ const fetchMock = vi.mocked(fetch)
502
+ fetchMock.mockImplementation(async input => {
503
+ const url = input.toString()
504
+
505
+ if (url === expectedUrl) {
506
+ return responseWithFinalUrl(`<main><p>${responseBody}</p></main>`, expectedUrl)
507
+ }
508
+
509
+ if (url === rawIdUrl) {
510
+ return responseWithFinalUrl(`<main><p>${homepageBody}</p></main>`, 'https://primer.style/')
511
+ }
512
+
513
+ throw new Error(`Unexpected fetch request: ${url}`)
514
+ })
515
+
516
+ const result = await client.callTool({name: tool, arguments: {name: 'TextInput'}})
517
+
518
+ expect(result.isError).not.toBe(true)
519
+ expect(result.content).toContainEqual(
520
+ expect.objectContaining({
521
+ type: 'text',
522
+ text: expect.stringContaining(responseBody),
523
+ }),
524
+ )
525
+ expect(result.content).not.toContainEqual(
526
+ expect.objectContaining({
527
+ type: 'text',
528
+ text: expect.stringContaining(homepageBody),
529
+ }),
530
+ )
531
+ expect(fetchMock).toHaveBeenCalledTimes(1)
532
+ expect(fetchMock.mock.calls[0]?.[0].toString()).toBe(expectedUrl)
533
+ })
534
+
485
535
  it.each(['ConfirmationDialog', 'confirmationdialog'])(
486
536
  'retrieves ConfirmationDialog documentation for %s from its published URL',
487
537
  async name => {
package/src/server.ts CHANGED
@@ -253,7 +253,7 @@ Use \`get_component\` for exactly one component and \`get_component_batch\` for
253
253
  }
254
254
  }
255
255
 
256
- const url = new URL(`/product/components/${match.id}`, 'https://primer.style')
256
+ const url = new URL(`/product/components/${match.slug}`, 'https://primer.style')
257
257
  const response = await fetch(url)
258
258
  if (!response.ok) {
259
259
  throw new Error(`Failed to fetch ${url}: ${response.statusText}`)
@@ -387,7 +387,7 @@ ${text}`,
387
387
  }
388
388
  }
389
389
 
390
- const url = new URL(`/product/components/${match.id}/accessibility`, 'https://primer.style')
390
+ const url = new URL(`/product/components/${match.slug}/accessibility`, 'https://primer.style')
391
391
  const response = await fetch(url)
392
392
  if (!response.ok) {
393
393
  if ((response.status >= 400 && response.status < 500) || (response.status >= 300 && response.status < 400)) {