Skip to content

Design System MCP: Add patterns tools using Storybook MDX manifest output - #84864

Merged
aduth merged 6 commits into
trunkfrom
add/design-system-mcp-patterns-docs-manifest
Oct 29, 2026
Merged

aduth merged 6 commits into
trunkfrom
add/design-system-mcp-patterns-docs-manifest

Conversation

@aduth

@aduth aduth commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

What?

Closes #82547

Adds new get_patterns and get_pattern_details tools to the @wordpress/design-system-mcp MCP server, and updates server instructions on how to consider patterns in relation to components.

This achieves the same goal as @juanmaguitar 's #82548, with the key implementation difference being that it relies on Storybook's default manifest behavior emitting docs.json instead of a custom patterns extraction.

Why?

The current set of MCP tools provide agents with an understanding of which components and tokens exist, but little in the form of guidance around how to compose components for common interface patterns. As a design system, we have started to document patterns for common interactions like destructive actions, error messages, and form submission, but these were until now these have not been surfaced to AI agents that use the design system MCP server. By adding patterns to the MCP server, we can continue to grow the library of patterns that describe how components can be composed together to solve common user interaction patterns.

How?

As mentioned above, this follows much of the same implementation direction as #82548 but relies on Storybook's native manifest feature. As such, it also follows the same expectations as how we document components through the MCP server by using the 'manifest' tag with patterns guidance through the <Meta /> component.

It's wort noting that this manifest shape is going to change in future iterations of Storybook, as the manifest feature we rely on is currently experimental. This applies to both the components manifest and documentation manifests. Early exploration of this is happening in #80697, but I'm waiting for the manifests feature to stabilize before making any changes.

It also goes further by rewriting the server instructions to account for how patterns fit alongside component and token tools in a more holistic sense, and which tools should be used for specific types of requests.

Testing Instructions

The most effective way to test this is using the MCP Inspector tool to see what an agent sees for the new tools:

  1. Run npm run storybook:build to build Storybook and its manifests
  2. Run cd storybook/build && php -S 127.0.0.1:8000 to host Storybook locally on a static file server (so the MCP server can reference the local manifests)
  3. Run npx @modelcontextprotocol/inspector node packages/design-system-mcp/bin/design-system-mcp.mjs -- -e DOCS_MANIFEST_URL=http://localhost:8000/manifests/docs.json -e COMPONENTS_MANIFEST_URL=http://localhost:8000/manifests/components.json to start the inspector process configured to the local server and manifest
  4. The inspector tool should launch in your browser
  5. Click the toggle button next to "Disconnected" to connect (screenshot)
  6. Switch from the "Servers" tab to "Tools" in the top bar (screenshot)
  7. Click "Get Patterns" under Tools sidebar and click "Execute Tool"
  8. Observe patterns listed content with title, slug, and description
  9. Click "Get Pattern Details" under Tools sidebar
  10. Enter a slug name or names as JSON in the field, as noted in the instructions (e.g. "destructive-actions" or ["destructive-actions", "error-messages"])
  11. Click "Execute Tool"
  12. Observe pattern content is shown

Screenshots or screencast

image image

Use of AI Tools

Used Claude Code + Opus 5.5

@aduth
aduth requested a review from juanmaguitar October 15, 2026 20:30
@aduth
aduth requested a review from a team as a code owner October 15, 2026 20:30
@aduth aduth added [Type] Enhancement A suggestion for improvement. Design System Issues related to the system of combining components according to best practices. [Package] Design System MCP /packages/design-system-mcp labels Oct 15, 2026
@github-actions

github-actions Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: aduth <aduth@git.wordpress.org>
Co-authored-by: juanmaguitar <juanmaguitar@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: simison <simison@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

📦 Bundle size

Size Change: 0 B

Total Size: 8.56 MB

a48a49f Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 5ab5f3c trunk % Change
timeToFirstByte 56.75 ms +2.91% -3.79% 55.45 ms +8.39% -3.07% 2.34%
largestContentfulPaint 98 ms +6.12% -6.12% 90 ms +6.67% -2.22% 8.89%
lcpMinusTtfb 39.2 ms +14.54% -13.52% 34.25 ms +8.76% -4.38% 14.45%
wpBeforeTemplate 29.39 ms +7.38% -2.45% 28.91 ms +11.03% -1.42% 1.66%
wpTemplate 22.57 ms +6.65% -5.05% 22.51 ms +5.38% -6.93% 0.27%
wpTotal 52.8 ms +2.88% -3.83% 51.63 ms +8.54% -2.83% 2.27%
wpMemoryUsage 7.70 MB +0% -0% 7.67 MB +0% -0% 0.43%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 5ab5f3c trunk % Change
timeToFirstByte 45.75 ms +13.44% -1.31% 46.9 ms +4.8% -1.71% -2.45%
largestContentfulPaint 100 ms +8% -0% 100 ms +4% -0% 0%
lcpMinusTtfb 54.85 ms +1.09% -1% 53.85 ms +0.74% -1.39% 1.86%
wpBeforeTemplate 26.64 ms +9.98% -2.82% 26.78 ms +2.35% -1.38% -0.52%
wpTemplate 16.69 ms +8.87% -4.01% 17.1 ms +1.64% -4.09% -2.4%
wpTotal 42.69 ms +12.93% -1.66% 43.69 ms +4.99% -1.56% -2.29%
wpMemoryUsage 6.40 MB +0% -0% 6.36 MB +0% -0% 0.53%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 5ab5f3c trunk % Change
mediaProcessingJpeg 407.52 ms +0.84% -0.51% 404.83 ms +1.39% -1.88% 0.66%
mediaProcessingAvif 6153.49 ms +0.19% -0.29% 6123.08 ms +0.29% -0.19% 0.5%
mediaProcessingJpegToAvif 4208.4 ms +0.55% -0.24% 4238.94 ms +0.27% -0.6% -0.72%

media-upload

Metric 5ab5f3c trunk % Change
jpegUploadProcessing 1487.58 ms +32.96% -1.56% 1495.02 ms +30.42% -1.41% -0.5%
pngUploadProcessing 169.45 ms +67.81% -6.53% 185.2 ms +58.63% -12.85% -8.5%
largeJpegUploadProcessing 1939.87 ms +0.36% -21.65% 1936.47 ms +1.01% -0.75% 0.18%
multipleImageUploadProcessing 2028.6 ms +0.74% -0.22% 2044.91 ms +0.34% -0.23% -0.8%

post-editor

Metric 5ab5f3c trunk % Change
serverResponse 552.65 ms +2.26% -4.7% 537.21 ms +6.39% -2.72% 2.87%
firstPaint 312.78 ms +68.31% -8.52% 412.94 ms +24.11% -40.41% -24.26%
domContentLoaded 925.65 ms +1.64% -0.2% 920.79 ms +1.58% -0.71% 0.53%
loaded 926.94 ms +1.63% -0.21% 922.32 ms +1.57% -0.73% 0.5%
firstContentfulPaint 533.84 ms +1.16% -1.39% 530.68 ms +3.9% -5.26% 0.6%
firstBlock 3090.51 ms +1.16% -1.4% 3094.68 ms +0.94% -0.39% -0.13%
type 20.29 ms +1.13% -14.83% 18.23 ms +4.77% -2.47% 11.3%
typeWithoutInspector 19.27 ms +5.55% -6.85% 18.29 ms +5.85% -6.29% 5.36%
typeWithTopToolbar 25.38 ms +3.23% -6.93% 24.42 ms +4.59% -7.29% 3.93%
typeContainer 8.52 ms +3.99% -10.56% 8.93 ms +13.89% -8.17% -4.59%
focus 127.47 ms +9.82% -6.5% 128.7 ms +1.06% -0.58% -0.96%
firstFocus 271.38 ms +0% -0% 257.1 ms +0% -0% 5.55%
selectAll 501.08 ms +4.15% -1.35% 470.8 ms +1.55% -0.84% 6.43%
undo 32.85 ms +3.87% -6.18% 32.05 ms +2.96% -6.93% 2.5%
listViewOpen 81.04 ms +6.24% -5.8% 81.49 ms +6.93% -15.97% -0.55%
inserterOpen 44.97 ms +17.81% -8.52% 41.11 ms +4.94% -6.4% 9.39%
inserterHover 11.47 ms +12.29% -8.98% 11.82 ms +11.76% -9.14% -2.96%
inserterSearch 9.58 ms +3.03% -4.7% 8.95 ms +5.92% -8.94% 7.04%
loadPatterns 678.7 ms +4.59% -2.48% 678 ms +6.94% -2.47% 0.1%
wpTotal 541.13 ms +2.3% -4.54% 526.3 ms +6.7% -2.74% 2.82%
wpMemoryUsage 14.73 MB +0% -0% 14.72 MB +0% -0% 0.1%
wpDbQueries 55 +0% -1.82% 55 +0% -1.82% 0%

site-editor

Metric 5ab5f3c trunk % Change
serverResponse 505.18 ms +2.72% -1.35% 521.42 ms +0.58% -4.81% -3.11%
firstPaint 252.32 ms +8.32% -4.58% 255.74 ms +27.15% -8.65% -1.34%
domContentLoaded 896 ms +0.6% -1.05% 882.01 ms +0.74% -2.22% 1.59%
loaded 896.94 ms +0.59% -1.03% 883.11 ms +0.73% -2.23% 1.57%
firstContentfulPaint 500.51 ms +1.96% -1.79% 476.41 ms +5.39% -5.02% 5.06%
firstBlock 3914.26 ms +1.28% -1% 3825.05 ms +1.18% -2.24% 2.33%
type 18.45 ms +11.17% -6.72% 19 ms +7.05% -12.05% -2.89%
navigate 123.33 ms +4.29% -5.95% 115.26 ms +4.97% -3.34% 7%
loadPatterns 1071.67 ms +5.42% -3.21% 1106.46 ms +6.31% -5.36% -3.14%
loadPages 1000.55 ms +1.57% -2.3% 997.33 ms +1.31% -1.91% 0.32%
wpTotal 495.79 ms +2.66% -1.47% 511.42 ms +0.57% -4.92% -3.06%
wpMemoryUsage 12.77 MB +0% -0% 12.73 MB +0% -0% 0.27%
wpDbQueries 44 +2.27% -0% 44 +2.27% -0% 0%

a48a49f Run

🏁 Flaky tests

Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

Delete (forward) in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  -  5
+ Received  + 11

@@ -1,25 +1,31 @@
  Array [
    Object {
      "innerBlocks": Array [
        Object {
          "attributes": Object {
-           "content": "1",
+           "content": "1‸a",
          },
-         "innerBlocks": Array [
+         "innerBlocks": Array [],
+         "name": "core/list-item",
+       },
        Object {
+         "attributes": Object {
+           "content": "2",
+         },
          "innerBlocks": Array [
            Object {
              "attributes": Object {
-                   "content": "a‸2",
+               "ordered": false,
+               "values": "",
              },
-                 "name": "core/list-item",
-               },
+             "innerBlocks": Array [
                Object {
                  "attributes": Object {
                    "content": "b",
                  },
+                 "innerBlocks": Array [],
                  "name": "core/list-item",
                },
              ],
              "name": "core/list",
            },

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:2056:42
clears the backup without a notice when the shared document contains it in /test/e2e/specs/editor/collaboration/collaboration-local-backup-notice-suppression.spec.ts, passed after 1 failed attempt.
Error: apiRequestContext.fetch: socket hang up
Call log:
  - → GET http://localhost:8891/wp-json/wp/v2/users?per_page=100
    - user-agent: Playwright/1.63.0 (x64; ubuntu 24.04) node/24.20 CI/1
    - accept: */*
    - accept-encoding: gzip,deflate,br
    - X-WP-Nonce: 6304c4cb42
    - cookie: wordpress_test_cookie=WP%20Cookie%20check; wordpress_logged_in_da433b7faafd8180ebeb1624ceeeab7e=admin%7C1793453687%7CVIKlberY1MdRxYoEMII1PrcNOpHkheCBSoLkLz4nqCj%7Cb630849bc143b6ba7a106819f3255fc22ea87b7b8db0204b9e6adee150fa6cd1; wp-settings-time-1=1793281006

    at RequestUtils.rest (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/rest.ts:111:39)
    at RequestUtils.listUsers (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/users.ts:34:30)
    at RequestUtils.deleteAllUsers (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/users.ts:106:44)
    at CollaborationUtils.teardown (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/fixtures/collaboration-utils.ts:609:28)
    at Object.collaborationUtils (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/fixtures/index.ts:31:5)
does not select blocks in the canvas preview when editing from the sidebar (Site Editor v2) in /test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator: getByRole('combobox', { name: 'Search or type URL' })
Expected: focused
Timeout: 5000ms
Error: element(s) not found

Call log:
  - Expect "toBeFocused" getByRole('combobox', { name: 'Search or type URL' }) with timeout 5000ms
  - waiting for getByRole('combobox', { name: 'Search or type URL' })

    at LinkControl.useLinkControlSearch (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:416:47)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:179:21
should create paragraph on Enter in quote block in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for getByRole('option', { name: 'List', exact: true })

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:751:67
should ignore styles inside noscript elements during navigation in /test/e2e/specs/interactivity/router-styles.spec.ts, passed after 1 failed attempt.
Error: apiRequestContext.fetch: socket hang up
Call log:
  - → DELETE http://localhost:8889/wp-json/wp/v2/posts/227?force=true
    - user-agent: Playwright/1.63.0 (x64; ubuntu 24.04) node/24.20 CI/1
    - accept: */*
    - accept-encoding: gzip,deflate,br
    - X-WP-Nonce: d4144c87c5
    - cookie: wordpress_test_cookie=WP%20Cookie%20check; wordpress_logged_in_23778236db82f19306f247e20a353a99=admin%7C1793453693%7C5SGScmhQwzD924gGr1PQOc873VaasaBpEng2WcDkjKC%7C8e791bb922b89a8a9efd442aa1ba8ddda9bb2d4a098d2ddd3abc30d37dc7eb22; wp-settings-time-1=1793281285

    at RequestUtils.rest (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/rest.ts:111:39)
    at map (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/posts.ts:44:9)
    at RequestUtils.deleteAllPosts (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/request-utils/posts.ts:43:9)
    at InteractivityUtils.deleteAllPosts (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/interactivity/fixtures/interactivity-utils.ts:91:3)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/interactivity/router-styles.spec.ts:58:3
should keep a full selection when outdenting nested items with Shift+Tab in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for locator('role=toolbar[name="Block tools"i]').locator('role=button[name="Indent"]')

    at Editor.clickBlockToolbarButton (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/editor/click-block-toolbar-button.ts:17:15)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:1166:3
should leave the rest of the list intact when merging into an empty list item in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 32
+ Received  +  1

- Array [
-   Object {
-     "innerBlocks": Array [
-       Object {
-         "attributes": Object {
-           "content": "1",
-         },
-         "innerBlocks": Array [
-           Object {
-             "innerBlocks": Array [
-               Object {
-                 "attributes": Object {
-                   "content": "a",
-                 },
-                 "name": "core/list-item",
-               },
-               Object {
-                 "attributes": Object {
-                   "content": "b",
-                 },
-                 "name": "core/list-item",
-               },
-             ],
-             "name": "core/list",
-           },
-         ],
-         "name": "core/list-item",
-       },
-     ],
-     "name": "core/list",
-   },
- ]
+ Array []
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:3118:38
should merge a following sibling list into the outermost list with Delete from a nested item (#77245) in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 2
+ Received  + 2

@@ -8,11 +8,11 @@
          "innerBlocks": Array [
            Object {
              "innerBlocks": Array [
                Object {
                  "attributes": Object {
-                   "content": "b‸",
+                   "content": "b",
                  },
                  "name": "core/list-item",
                },
              ],
              "name": "core/list",
@@ -25,11 +25,11 @@
    },
    Object {
      "innerBlocks": Array [
        Object {
          "attributes": Object {
-           "content": "1",
+           "content": "‸1",
          },
          "innerBlocks": Array [
            Object {
              "innerBlocks": Array [
                Object {

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:2854:41
should offer the formats every selected block allows in /test/e2e/specs/editor/various/multi-block-selection.spec.js, passed after 1 failed attempt.
Error: expect(received).toEqual(expected) // deep equality

- Expected  - 2
+ Received  + 2

  Object {
-   "anchorOffset": 1,
+   "anchorOffset": 0,
    "blocks": 2,
-   "focusOffset": 1,
+   "focusOffset": 0,
  }

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/multi-block-selection.spec.js:2553:5
should outdent with children in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for locator('role=toolbar[name="Block tools"i]').locator('role=button[name="Indent"]')

    at Editor.clickBlockToolbarButton (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/editor/click-block-toolbar-button.ts:17:15)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:1055:3
should place the caret at the click position when clicking a block that is not selected in /test/e2e/specs/editor/various/writing-flow.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 1
+ Received  + 1

@@ -1,9 +1,9 @@
  Array [
    Object {
      "attributes": Object {
-       "content": "First!",
+       "content": "First",
      },
      "name": "core/paragraph",
    },
    Object {
      "attributes": Object {

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/writing-flow.spec.js:952:41
should remove an anchored list when deleting its last item in /test/e2e/specs/editor/blocks/list.spec.js, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 1
+ Received  + 1

@@ -5,11 +5,11 @@
      },
      "innerBlocks": Array [
        Object {
          "attributes": Object {
            "anchor": "item",
-           "content": "x",
+           "content": "",
          },
          "name": "core/list-item",
        },
      ],
      "name": "core/list",

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/list.spec.js:2961:41

a48a49f Run

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The experimental Storybook manifest output and built MCP integration remain unverified and need human validation.

0 open findings

What changed in this PR

Exposes existing Storybook pattern guidance through the design system MCP server, helping agents choose and compose components for common interactions.

Changes:

  • Adds pattern discovery and detail tools backed by Storybook’s native docs manifest.
  • Updates server guidance and opts existing patterns into manifest generation.
  • Adds parsing, caching, handler tests, and manifest validation.
File Description
storybook/​test/​patterns-manifest.test.ts Checks pattern manifest tags and lead paragraphs.
storybook/​stories/​design-system/​patterns/​save-and-submit.mdx Makes the document standalone and manifest-enabled.
storybook/​stories/​design-system/​patterns/​error-messages.mdx Enables manifest inclusion.
storybook/​stories/​design-system/​patterns/​destructive-actions.mdx Enables manifest inclusion.
storybook/​README.md Documents manifest publishing requirements.
packages/​design-system-mcp/​src/​types.ts Adds document and pattern types.
packages/​design-system-mcp/​src/​tools/​test/​get-pattern-details.ts Tests detail responses and missing patterns.
packages/​design-system-mcp/​src/​tools/​index.ts Registers both pattern tools.
packages/​design-system-mcp/​src/​tools/​get-patterns.ts Adds pattern discovery.
packages/​design-system-mcp/​src/​tools/​get-pattern-details.ts Adds single and batched pattern retrieval.
packages/​design-system-mcp/​src/​tools/​get-component-details.ts Reuses the shared lookup helper.
packages/​design-system-mcp/​src/​test/​parse-patterns.ts Tests pattern extraction and filtering.
packages/​design-system-mcp/​src/​test/​fixtures/​docs-manifest.json Adds representative manifest data.
packages/​design-system-mcp/​src/​test/​data.ts Tests pattern fetching, caching, and lookup.
packages/​design-system-mcp/​src/​parse-patterns.ts Extracts patterns from manifest entries.
packages/​design-system-mcp/​src/​index.ts Exports parsing and updates server instructions.
packages/​design-system-mcp/​src/​format.ts Formats pattern listings.
packages/​design-system-mcp/​src/​find-each.ts Shares ordered lookup handling.
packages/​design-system-mcp/​src/​data.ts Fetches, caches, and retrieves patterns.
packages/​design-system-mcp/​scripts/​validate-manifest.mjs Validates generated pattern availability.
packages/​design-system-mcp/​README.md Documents pattern guidance capabilities.
packages/​design-system-mcp/​CHANGELOG.md Records the new tools.

🧠 Review effort: Balanced


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

}

const slug = componentId.slice( PATTERN_ID_PREFIX.length );
const content = source.slice( start ).trim();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

get_pattern_details returns the Save & Submit example as <Canvas of={ SaveSubmitStories.SaveFormLayoutCard } />, so MCP clients never receive the form code shown in Storybook.

Should we try to expand those nested canvases into the underlying code block?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a really good point. Ideally an AI agent should receive the same rendered documentation that a human would be able to see in the live Storybook.

Although ironically in this case it's not a great example, because the live Storybook code snippet is not all that helpful at the moment either 😅 (the rendered code is wrapped in a component and preview only shows the name of the wrapper)

image

The changes in 12b4564 adjust the story to assign the actual component code to render, and implement the behavior of expanding canvases.

Screenshot 2026-10-26 at 5 29 36 PM

I'm not super enthusiastic about the AI's implementation, particularly around using regular expressions for matching imports and components, but it's a relatively straight-forward approach and degrades gracefully.

Other ideas I had was to either change where we implement the story examples (e.g. inline in the .mdx), but I don't think this is very possible with how we want <Canvas /> to work.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One remaining item I need to address before this is ready is that referencing snippet code from components.json means that various scripts that use it as a canonical reference of components will start seeing "Save & Submit", now that it's marked as manifest. This isn't technically a problem for the MCP server because it ignores entries outside expected packages directories, but some tests and other consumers could be impacted.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The more I look at this, the more I think it might make sense to punt <Canvas /> expansion as a future improvement and keep the rest of this pull request as-is.

Specifically, the changes explored in my previous comments required that the pattern story code snippets be added to the components.json manifest. Until now, we've been treating the components.json manifest as the canonical list of design system components. Enabling manifest for these pattern stories also produces parser errors where it can't find an associated component. Essentially my concern is that it muddies what components.json actually is, where some components are linked to design system components, and others exist to satisfy this canvas expansion for patterns.

As part of exploring this, I also revisited and refreshed #80697, which is the proof-of-concept of migrating to Storybook's still-unfinished v1 manifest structure. In this structure, components.json and docs.json still exist, but they point to files at storybook/build/services, where parsed result of all stories (manifest or not) are included. You can check out the branch and test this locally if you want.

My thinking is that there might be a clearer path to unfurling canvas snippets under the v1 manifest. And frankly, the way that the v1 manifest is managing "related resources" with a $ref link structure leads me to think that Storybook itself could be linking these related resources.

Which is all to say: Rather than manipulate the component manifest to our purpose under the v0 manifest, I'd suggest we wait and solve this under the v1 manifest.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also checked Storybook's own MCP server implementation, and they don't do anything special for <Canvas /> either. Their design is a little different where documents that are attached to components bring all relevant documentation for the component along with the response. This doesn't transfer as well to our case here, because the stories in question are not actually associated with a component.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And frankly, the way that the v1 manifest is managing "related resources" with a $ref link structure leads me to think that Storybook itself could be linking these related resources.

Related upstream question: storybookjs/storybook#35333 (comment)

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted <Canvas /> expansion in 90d5e8e

Extracted the "Save & Submit" pattern code copy improvements in standalone PR at #85766

@ciampo ciampo Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deferring Canvas expansion until the manifest v1 work seems reasonable. Let's track it as a follow-up for both Save & Submit and Copy to Clipboard.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's track it as a follow-up for both Save & Submit and Copy to Clipboard.

Follow-up tracking issue at #85969

…tput

Co-authored-by: JuanMa <juanma.garrido@gmail.com>
@aduth
aduth force-pushed the add/design-system-mcp-patterns-docs-manifest branch from ebb2eed to de753a7 Compare October 26, 2026 20:58
@aduth
aduth marked this pull request as draft October 26, 2026 21:31
@aduth
aduth marked this pull request as ready for review October 27, 2026 17:16

@ciampo ciampo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No further feedback 🚀

@simison

simison commented Oct 28, 2026

Copy link
Copy Markdown
Member

Relatedly, mentioning here since it's related, I also looked at exposing other guidance documents ("how to use badge?") alongside patterns like in this PR ("how to build settings page?")

A few other design system MCPs also had similar tool. Alternatively surfacing those "howto" guides alongside get_component_details could work too.

@aduth

aduth commented Oct 28, 2026

Copy link
Copy Markdown
Member Author

Alternatively surfacing those "howto" guides alongside get_component_details could work too.

Yeah, this is how I was considering this, when I was looking at it before. I feel like "Usage guidelines" for using a particular component makes sense to be included as part of the details of that component, rather than through a separate tool. Particularly since agents are rather conservative with the number of tool calls they're willing to make (part of the reason we added bulk details requests in #78185).

@simison

simison commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

I feel like "Usage guidelines" for using a particular component makes sense to be included as part of the details of that component, rather than through a separate tool.

Yep! I think this makes sense.

@aduth

aduth commented Oct 29, 2026

Copy link
Copy Markdown
Member Author

Doing some last-minute testing here to see how this behaves in a real AI environment, I happened to get a really nice Before & After because I misconfigured the MCP in my first attempt, thus producing a result that didn't have access to the patterns. And in that case, it provided wrong advice, responding that deletion should happen immediately without any prompt for a reversible action. After the pattern guidance was made available, it provided the correct advice, with details about ConfirmDialog, not using destructive intents for buttons, and showing an Undo action afterward.

Before After
image image

Regarding some of the gaps it flagged: On further prompting, I think the failure to reach for get_component_details for Button and ConfirmDialog would be less likely to happen in a real-world implementation than the gap lets on. Because my initial prompt asked "which components" and not "implement the thing", it got enough information to answer my question with the pattern guidance alone. The included server instructions in these changes make it clear that the agent should "call get_component_details for the components you will use" in an actual implementaion.

@aduth
aduth merged commit 2b9f2e1 into trunk Oct 29, 2026
81 checks passed
@aduth
aduth deleted the add/design-system-mcp-patterns-docs-manifest branch October 29, 2026 18:51
@github-actions github-actions Bot added this to the Gutenberg 24.4 milestone Oct 29, 2026
Vedant-Gandhi pushed a commit to Vedant-Gandhi/gutenberg that referenced this pull request Nov 30, 2026
…tput (WordPress#84864)

* Design System MCP: Add patterns tools using Storybook MDX manifest output

Co-authored-by: JuanMa <juanma.garrido@gmail.com>

* Design System MCP: Expand canvases using component story code snippets

* Revert "Design System MCP: Expand canvases using component story code snippets"

This reverts commit 12b4564.

* design-system-mcp: Move CHANGELOG note under Unreleased

* Storybook: Add "Copy to Clipboard" pattern title and manifest tag

---------

Co-authored-by: JuanMa <juanma.garrido@gmail.com>
Co-authored-by: aduth <aduth@git.wordpress.org>
Co-authored-by: juanmaguitar <juanmaguitar@git.wordpress.org>
Co-authored-by: ciampo <mciampini@git.wordpress.org>
Co-authored-by: simison <simison@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Design System Issues related to the system of combining components according to best practices. [Package] Design System MCP /packages/design-system-mcp [Type] Enhancement A suggestion for improvement.

Projects

Status: 💫 Done

Development

Successfully merging this pull request may close these issues.

Design System: Serve pattern guidance documents through the MCP server

4 participants