Skip to main content
Glama

get-component-docs

Retrieve detailed documentation for specific Ant Design components, including API properties and usage instructions, to streamline development and integration.

Instructions

获取 Ant Design 特定组件的详细文档 适用场景:

  1. 用户询问如何使用特定组件

  2. 用户需要查看该组件的 api 属性

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
componentNameYes

Implementation Reference

  • The handler function that executes the tool logic: fetches component documentation using the helper function and formats it into MCP response content.
    async ({ componentName }) => { const documentation = await getComponentDocumentation(componentName); return { content: [ { type: "text", text: `${componentName} 组件的文档: ${documentation} 如有版本说明需要提醒用户需要使用某个版本及以上的版本`, }, ], }; },
  • Registers the 'get-component-docs' tool on the MCP server, including name, description, input schema { componentName: z.string() }, and inline handler.
    const registryTool = (server: McpServer) => { server.tool( "get-component-docs", `获取 Ant Design 特定组件的详细文档 适用场景: 1. 用户询问如何使用特定组件 2. 用户需要查看该组件的 api 属性`, { componentName: z.string() }, async ({ componentName }) => { const documentation = await getComponentDocumentation(componentName); return { content: [ { type: "text", text: `${componentName} 组件的文档: ${documentation} 如有版本说明需要提醒用户需要使用某个版本及以上的版本`, }, ], }; }, ); }
  • Central registry function that invokes the individual tool registry functions, including the one for get-component-docs.
    export default function registryTools(server: McpServer) { [getComponentDocs, listComponentExamples, getComponentChangelog, listComponents].forEach((registryFn) => { registryFn(server) }) }
  • Key helper function that retrieves and caches the documentation for a specific Ant Design component from extracted data files.
    export const getComponentDocumentation = async (componentName: string) => { const component = await findComponentByName(componentName); if (!component) { return ` "${componentName}" 组件文档不存在`; } const docPath = join(EXTRACTED_COMPONENTS_DATA_PATH, component.dirName, DOC_FILE_NAME); try { const cacheComponentDoc = componentCache.get('componentsDoc') || {} if (cacheComponentDoc?.[component.name]) { return cacheComponentDoc[component.name] } if (existsSync(docPath)) { const docResult = await readFile(docPath, "utf-8"); cacheComponentDoc[component.name] = docResult componentCache.set('componentsDoc', cacheComponentDoc) return docResult } return `${component.name} 组件文档不存在`; } catch (error) { console.error(`获取 ${component.name} 组件文档错误: ${(error as Error).message}`); return `获取 ${component.name} 组件文档错误: ${(error as Error).message}`; } };

Other Tools

Related Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/zhixiaoqiang/antd-components-mcp'

If you have feedback or need assistance with the MCP directory API, please join our Discord server