get-component-changelog
Retrieve the changelog for a specific Ant Design component to track updates, determine feature availability, and decide if dependency upgrades are needed.
Instructions
列出 Ant Design 特定组件的更新日志 适用场景:
用户询问特定组件的更新日志
在知道用户 antd 版本的情况下,当用户需要实现相关组件功能时判断是否在后续版本中才实现,来决定是否需要升级依赖
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| componentName | Yes |
Implementation Reference
- The main handler function that fetches the changelog data using the helper, processes it for the specific component (handling case variations), formats it into a readable string, and returns it as structured text content.async ({ componentName }) => { const componentsChangelog = await getComponentsChangelog(componentName); if (typeof componentsChangelog === 'string') return { content: [ { type: "text", text: componentsChangelog, }, ], } const currentComponentChangelog = componentsChangelog[componentName] || componentsChangelog[componentName.charAt(0).toUpperCase() + componentName.slice(1)] const reduceChangelogContent = currentComponentChangelog?.reduce((acc, item) => { return `${acc}${item.version}:${item.releaseDate}:${item.changelog}\n` }, '') return { content: [ { type: "text", text: currentComponentChangelog ? `以下是 ${ componentName } 组件的更新日志: ${reduceChangelogContent}` : '当前组件没有找到更新日志', }, ], };
- Input schema defined with Zod, requiring a single string parameter 'componentName'.{ componentName: z.string() },
- src/tools/get-component-changelog.ts:7-41 (registration)Primary registration of the tool with the MCP server, specifying name, description, input schema, and handler function.server.tool( "get-component-changelog", `列出 Ant Design 特定组件的更新日志 适用场景: 1. 用户询问特定组件的更新日志 2. 在知道用户 antd 版本的情况下,当用户需要实现相关组件功能时判断是否在后续版本中才实现,来决定是否需要升级依赖`, { componentName: z.string() }, async ({ componentName }) => { const componentsChangelog = await getComponentsChangelog(componentName); if (typeof componentsChangelog === 'string') return { content: [ { type: "text", text: componentsChangelog, }, ], } const currentComponentChangelog = componentsChangelog[componentName] || componentsChangelog[componentName.charAt(0).toUpperCase() + componentName.slice(1)] const reduceChangelogContent = currentComponentChangelog?.reduce((acc, item) => { return `${acc}${item.version}:${item.releaseDate}:${item.changelog}\n` }, '') return { content: [ { type: "text", text: currentComponentChangelog ? `以下是 ${ componentName } 组件的更新日志: ${reduceChangelogContent}` : '当前组件没有找到更新日志', }, ], }; }, );
- src/tools/index.ts:9-11 (registration)Central tool registry function that invokes the individual tool registry functions, including getComponentChangelog.[getComponentDocs, listComponentExamples, getComponentChangelog, listComponents].forEach((registryFn) => { registryFn(server) })
- src/utils/components.ts:126-148 (helper)Supporting utility that finds the component, loads and caches the changelog JSON data from file, and returns the full changelog record or an error message if not found.export const getComponentsChangelog = async (componentName: string): Promise<Record<string, ComponentChangelogItem[]> | string> => { const component = await findComponentByName(componentName); if (!component) { return `${component} 组件不存在`; } try { const cacheComponentChangelog = componentCache.get('componentsChangelog') if (cacheComponentChangelog) { return cacheComponentChangelog } const componentChangelog = await readFile(EXTRACTED_COMPONENTS_DATA_CHANGELOG_PATH, "utf-8"); const componentChangelogJson = JSON.parse(componentChangelog) componentCache.set('componentsChangelog', componentChangelogJson) return componentChangelogJson } catch (error) { console.error(`获取组件更新记录错误 ${component.name}: ${(error as Error).message}`); return `未找到 ${component.name} 更新日志`; } };