Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

MCP: get_component_examples and get_component_accessibility_guidelines still use the component id instead of the slug (home page returned for multi-word components)

未关闭 适合新手
#8,561 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 2 天内回复

@bindu-yogesh 已经在做这个了。

开始于 2026年10月17日。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
82/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
领域
tooling

调研方向

两个 URL 在 packages/mcp/src/server.ts 中构建,分别位于 get_component_examples 处理程序(约 L256)和 get_component_accessibility_guidelines 处理程序(约 L390),两者都使用 match.id。请与已经使用 match.slug 的 usage-guidelines 处理程序进行比较。运行 MCP 服务器,并以 name 为 TextInput 调用这两个工具。当两者都返回 TextInput 页面而非首页,且 Button 仍然正常工作时,即完成。

由索引模型根据 Issue 内容生成。

描述

Description

get_component_examples and get_component_accessibility_guidelines build the primer.style URL from the component id (for example text_input) instead of its slug (text-input). For multi-word components the wrong path does not 404: primer.style answers HTTP 200 with the home page, so both tools return the home page as if it were the component's examples or accessibility guidance.

#8530 fixed the same problem for get_component_usage_guidelines; these two calls were not changed. On main (e236683):

  • L256 get_component_examples: new URL(`/product/components/${match.id}`, ...)
  • L390 get_component_accessibility_guidelines: new URL(`/product/components/${match.id}/accessibility`, ...)

get_component (L141) and the usage tool after #8530 (L317) already use match.slug.

In @primer/react/generated/components.json, 43 of 80 component ids contain an underscore (action_list, icon_button, text_input, ...), so these two tools fail for about half of the components.

Suggested fix: use match.slug in both places. Because a wrong path returns 200, a guard on the response (for example, checking that the fetched page title names the component) would also catch future id/slug mismatches.

Steps to reproduce
  1. Run npx @primer/[email protected] and connect an MCP client.
  2. Call get_component_accessibility_guidelines with {"name": "TextInput"}.
  3. The text starts with the Primer home page ("The design system for GitHub") instead of the TextInput accessibility page.
  4. Call get_component_examples with {"name": "TextInput"}: same result.
  5. {"name": "Button"} works, because its id and slug are the same.

Direct check: https://primer.style/product/components/text_input/accessibility returns <title>Primer</title>, while https://primer.style/product/components/text-input/accessibility/ returns <title>Accessibility - TextInput | Primer</title>.

Version

@primer/mcp 1.1.0 from npm (it also still has the usage-guidelines bug fixed in #8530, so a release would help). Source checked against main at e236683 on 2026-10-16.

Browser

N/A (MCP server on Node.js)

主要语言
TypeScript
星标
3.9k
派生
697
平均合并
3 天 21 小时
30 天内合并 PR
51

环境准备

在 Codespaces 中打开

在浏览器里用你自己的 GitHub 账号启动这个项目的开发容器。

  • 没有 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

primer/react 的其他 Issue

查看 primer/react 的全部 Issue

相似的 Issue

更多 TypeScript Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。