Add scenario patterns to MCP pattern tools#8058
Merged
Merged
Conversation
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 detectedLatest commit: 0a6be28 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
Contributor
There was a problem hiding this comment.
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_patternsto group output by scenario vs UI patterns, and updateget_patternto 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
Address review feedback: fix the list_patterns response grammar and make the changeset terser and consumer-facing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
list_patternsandget_pattern.Changed
get_patternderives the documentation base path from a pattern's category; scenario patterns take precedence over UI patterns on a name match.list_patternsgroups patterns under scenario and UI headings.Removed
Rollout strategy
Testing & Reviewing
The
@primer/mcppackage has no unit test suite (consistent with how the tools were originally added). The change was validated by:list_patternsreturns the scenario-first grouping;get_patternforCopyandSearchresolves thescenario-patternsbase path and returns real converted content;get_patternforFormsstill usesui-patterns(no regression); an unknown name falls back to the not-found message.fetchfollows by default).DosAndDontscomponent (shared with UI pattern pages) converts to legible markdown: eachDoandDon'tlabel 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.To review manually, run the MCP server and call
list_patterns(scenario patterns should appear first under their own heading) andget_patternwithCopy,Delete,Filter, orSearch.Merge checklist