-
Notifications
You must be signed in to change notification settings - Fork 648
[MCP] Add support for the /llms.txt component endpoint
#7495
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
🦋 Changeset detectedLatest commit: f873384 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 |
There was a problem hiding this comment.
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 adds support for fetching component documentation via a new /llms.txt endpoint in the MCP (Model Context Protocol) server, which is designed to provide more concise, AI-agent-friendly documentation compared to the existing HTML-based approach.
Changes:
- Added fetch logic for the
/llms.txtendpoint with automatic fallback to the existing documentation approach - Modified the error response structure for the component-not-found case to use
isErroranderrorMessagefields - Added a changeset documenting this as a minor release
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/mcp/src/server.ts | Adds /llms.txt endpoint fetch logic with fallback mechanism and changes error response structure |
| .changeset/gold-snakes-smash.md | Documents the change as a minor release with appropriate description |
| return { | ||
| content: [ | ||
| { | ||
| type: 'text', | ||
| text: `There is no component named \`${name}\` in the @primer/react package. For a full list of components, use the \`list_components\` tool.`, | ||
| }, | ||
| ], | ||
| isError: true, | ||
| errorMessage: `There is no component named \`${name}\` in the @primer/react package. For a full list of components, use the \`list_components\` tool.`, | ||
| content: [], | ||
| } |
Copilot
AI
Feb 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error response structure using isError and errorMessage is inconsistent with the rest of the codebase. All other error cases in this file (e.g., get_component_examples at lines 186-194, get_component_usage_guidelines at lines 246-254) return error messages within the standard content array structure. This change breaks that established pattern.
Consider changing this to match the existing pattern by returning the error message in a content array instead of using isError and errorMessage fields.
With the new evals framework, we discovered that the existing Primer MCP tools for getting component documentation was insufficient. It would include HTML fragments, confusing formatting and other results that skewed the effectiveness. In one example it couldn't find the import path for a component via the docs.
Running our evals framework for Primer experience generation with and without the new endpoint enabled, we see a 5x reduction in token usage for much more actionable content.
Changelog
New
<component>/llms.txtendpoint. This is intended to serve as a more concise summary of the component documentation, tailed specifically for agent consumption.Rollout strategy