Skip to content

Add scenario patterns to MCP pattern tools#8058

Merged
joshblack merged 2 commits into
mainfrom
mattobee-automatic-waddle
Jun 25, 2026
Merged

Add scenario patterns to MCP pattern tools#8058
joshblack merged 2 commits into
mainfrom
mattobee-automatic-waddle

Conversation

@mattobee

@mattobee mattobee commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Closes github/core-ux#2814

The Primer MCP server already lets an agent list and fetch UI patterns (forms, navigation, empty states, and so on). This adds four scenario patterns to those same tools: Copy, Delete, Filter, and Search. Scenario patterns describe a specific user task rather than a generic building block, so when one fits the job an agent should reach for it first. The tools now say so, and resolve scenario patterns ahead of UI patterns.

The scrape-and-convert mechanism is unchanged but two other things do change. The URL is now built from the pattern's category, so scenario patterns resolve to https://primer.style/product/scenario-patterns/{slug}/ while UI patterns keep /product/ui-patterns/{slug}/. Name resolution now prefers a scenario pattern when one matches. The four new pages are then scraped and converted exactly as before.

This is part 2 of github/core-ux#2795 brought forward. It is decoupled from the llms.txt route decision in that issue and relies only on the existing rendered-page scraping mechanism.

Changelog

New

  • MCP server: Copy, Delete, Filter, and Search scenario patterns available through list_patterns and get_pattern.

Changed

  • MCP server: get_pattern derives the documentation base path from a pattern's category; scenario patterns take precedence over UI patterns on a name match.
  • MCP server: list_patterns groups patterns under scenario and UI headings.

Removed

  • N/A

Rollout strategy

  • Patch release
  • Minor release
  • Major release; if selected, include a written rollout or migration plan
  • None; if selected, include a brief description as to why

Testing & Reviewing

The @primer/mcp package has no unit test suite (consistent with how the tools were originally added). The change was validated by:

  • Running the edited server end to end through an in-memory MCP client and calling the tools against the live docs. list_patterns returns the scenario-first grouping; get_pattern for Copy and Search resolves the scenario-patterns base path and returns real converted content; get_pattern for Forms still uses ui-patterns (no regression); an unknown name falls back to the not-found message.
  • Confirming all four scenario pages resolve with HTTP 200 and return content (they redirect to a trailing-slash URL, which fetch follows by default).
  • Checking that the do/don't guidance blocks on the scenario pages survive the scrape. The DosAndDonts component (shared with UI pattern pages) converts to legible markdown: each Do and Don't label is preserved as its own line immediately before its guidance statement, and the do/don't pairing is kept by document order. No change was needed for an agent to read these correctly.
  • An isolated TypeScript check of the edited source. The edited regions produce no type errors.

To review manually, run the MCP server and call list_patterns (scenario patterns should appear first under their own heading) and get_pattern with Copy, Delete, Filter, or Search.

Merge checklist

  • Added/updated tests
  • Added/updated documentation
  • Added/updated previews (Storybook)
  • Changes are SSR compatible
  • Tested in Chrome
  • Tested in Firefox
  • Tested in Safari
  • Tested in Edge
  • (GitHub staff only) Integration tests pass at github/github-ui

Expose the Copy, Delete, Filter and Search scenario patterns through
the existing list_patterns and get_pattern tools. A category field on
each entry selects the documentation base path, and scenario patterns
resolve first so they take precedence over UI patterns on a name match.
@changeset-bot

changeset-bot Bot commented Jun 25, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 0a6be28

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@primer/mcp Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

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.

Pull request overview

This PR extends the @primer/mcp server’s pattern tools to include scenario patterns (task-focused guidance) alongside existing UI patterns, and updates pattern resolution so scenario patterns are preferred on name collisions.

Changes:

  • Add four scenario patterns (Copy, Delete, Filter, Search) to the pattern registry and annotate patterns with a category.
  • Update list_patterns to group output by scenario vs UI patterns, and update get_pattern to prefer scenario matches and fetch from the correct docs base path.
  • Add a changeset for a minor release of @primer/mcp.
Show a summary per file
File Description
packages/mcp/src/server.ts Updates list_patterns output/description and get_pattern matching + URL base path selection based on pattern category.
packages/mcp/src/primer.ts Adds scenario patterns and introduces a category field on all patterns to support correct grouping and fetching.
.changeset/mcp-scenario-patterns.md Adds a minor-release changeset documenting the new scenario patterns in MCP tools.

Copilot's findings

  • Files reviewed: 3/3 changed files
  • Comments generated: 3

Comment thread packages/mcp/src/primer.ts
Comment thread packages/mcp/src/server.ts Outdated
Comment thread .changeset/mcp-scenario-patterns.md Outdated
Address review feedback: fix the list_patterns response grammar and make
the changeset terser and consumer-facing.

@joshblack joshblack left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Woo! 🥳

@joshblack joshblack added the integration-tests: skipped manually Changes in this PR do not require an integration test label Jun 25, 2026
@joshblack joshblack added this pull request to the merge queue Jun 25, 2026
Merged via the queue into main with commit 0a49d7d Jun 25, 2026
69 checks passed
@joshblack joshblack deleted the mattobee-automatic-waddle branch June 25, 2026 15:27
@primer primer Bot mentioned this pull request Jun 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

integration-tests: skipped manually Changes in this PR do not require an integration test staff Author is a staff member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants