Skip to content

Commit e1268ff

Browse files
joshblackCopilot
andauthored
fix(mcp): add component slug for better docs lookup (#6488)
Co-authored-by: Copilot <[email protected]>
1 parent 6d74cee commit e1268ff

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

packages/mcp/src/primer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@ type Component = {
44
id: string
55
name: string
66
importPath: string
7+
slug: string
78
}
89

910
const components: Array<Component> = Object.entries(componentsMetadata.components).map(([id, component]) => {
1011
return {
1112
id,
1213
name: component.name,
1314
importPath: component.importPath,
15+
slug: id.replaceAll('_', '-'),
1416
}
1517
})
1618

packages/mcp/src/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ server.tool(
4343
async ({name}) => {
4444
const components = listComponents()
4545
const match = components.find(component => {
46-
return component.name === name
46+
return component.name === name || component.name.toLowerCase() === name.toLowerCase()
4747
})
4848
if (!match) {
4949
return {
@@ -56,7 +56,7 @@ server.tool(
5656
}
5757
}
5858

59-
const url = new URL(`/product/components/${match.id}`, 'https://primer.style')
59+
const url = new URL(`/product/components/${match.slug}`, 'https://primer.style')
6060
const response = await fetch(url)
6161
if (!response.ok) {
6262
throw new Error(`Failed to fetch ${url}: ${response.statusText}`)

0 commit comments

Comments
 (0)