get-component-changelog
Retrieve changelogs for Ant Design components to check version compatibility and track feature updates.
Instructions
列出 Ant Design 特定组件的更新日志 适用场景:
用户询问特定组件的更新日志
在知道用户 antd 版本的情况下,当用户需要实现相关组件功能时判断是否在后续版本中才实现,来决定是否需要升级依赖
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| componentName | Yes |
Implementation Reference
- The core handler function for the 'get-component-changelog' tool. It fetches the changelog data using the helper, handles both error string and object responses, normalizes component name casing, reduces changelog items into a formatted string, and returns MCP-formatted 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}` : '当前组件没有找到更新日志', }, ], };
- src/tools/get-component-changelog.ts:6-42 (registration)Registers the 'get-component-changelog' tool on the MCP server, including the tool name, description, input schema (componentName: string), and references the handler function.const registryTool = (server: McpServer) => { 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/utils/components.ts:126-148 (helper)Helper utility that loads, parses, and caches the changelog data for all components from a JSON file. Returns the full changelog record or an error message if the component is not found or file issues occur.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} 更新日志`; } };
- src/tools/index.ts:5-12 (registration)Aggregator that imports the registryTool for get-component-changelog and invokes it along with other tools during server setup.import getComponentChangelog from "./get-component-changelog"; import listComponents from "./list-components"; export default function registryTools(server: McpServer) { [getComponentDocs, listComponentExamples, getComponentChangelog, listComponents].forEach((registryFn) => { registryFn(server) }) }
- Zod schema for tool input: requires a 'componentName' string.{ componentName: z.string() },