Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/gold-snakes-smash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@primer/mcp': minor
---

Adds support for fetching docs via the `/llms.txt` endpoint per-component
27 changes: 21 additions & 6 deletions packages/mcp/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,27 @@ server.registerTool(
})
if (!match) {
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: [],
}
Comment on lines 113 to +117
Copy link

Copilot AI Feb 2, 2026

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.

Copilot uses AI. Check for mistakes.
}

const llmsUrl = new URL(`/product/components/${match.slug}/llms.txt`, 'https://primer.style')
const llmsResponse = await fetch(llmsUrl)
if (llmsResponse.ok) {
try {
const llmsText = await llmsResponse.text()
return {
content: [
{
type: 'text',
text: llmsText,
},
],
}
} catch (_: unknown) {
// If there's an error fetching or processing the llms.txt, we fall back to the regular documentation
}
}

Expand Down
Loading