AntDesign。克利
一个命令行工具和MCP(模型上下文协议)服务器,用于查询Ant Design Async组件信息。它帮助开发人员直接从命令行或通过GitHub Copilot快速访问组件文档和API详细信息。
有关详细的实施指南和技术讨论,请查看我们的博客文章:
特性
- 搜索特定组件信息
- 列出所有可用组件
- 按类别过滤组件
- 支持CLI和MCP服务器模式
- GitHub Copilot集成
支持的工具
CLI命令
list:列出所有组件search -n:按名称批量搜索组件category -n:按类别过滤组件demo-list:列出所有组件演示demo -n:查看特定组件的演示
MCP服务器工具
SearchComponents:按名称批量搜索组件ListComponents:列出所有组件GetComponentsByCategory:按类别获取组件ListAllDemos:列出所有组件演示SearchComponentDemos:按组件名称和场景获取演示
安装
dotnet tool install --global AntDesign.Cli用法
命令行接口命令模式
# List all components
antblazor list
# Search for a specific component
antblazor search -n Button
# Get components by category
antblazor category -n NavigationMCP服务器模式(适用于GitHub Copilot)
- 全局安装该工具
- 将以下配置添加到VS代码中
mcp.json:
{
"servers": {
"antblazor": {
"type": "stdio",
"command": "antblazor",
"args": ["-mcp"]
}
}
}或者使用安装链接:
vscode:mcp/install?{"name":"antblazor","command":"antblazor","args":["-mcp"]}实现细节
本项目演示了如何:
- 创建一个。NET全局工具
- 实现MCP服务器功能
- 加载并解析组件文档
- 提供干净的CLI界面
- 启用GitHub Copilot集成
使用的关键技术:
- .NET 9.0
- 系统。命令行
- 模型上下文协议
- 系统。文本。JSON
技术细节
转换a。NET CLI工具到MCP服务器
转换a的过程。NET CLI工具到MCP服务器需要几个步骤:
- 添加所需包
- 创建MCP工具类
[McpServerToolType]
public sealed class AntDesignTools
{
[McpServerTool]
[Description("Search for an Ant Design Blazor component by name")]
public async Task SearchComponent(
[Description("The name of the component to search for")] string name)
{
// Implementation
}
}- 配置MCP服务器
if (args.Length == 1 && args[0] == "-mcp")
{
var builder = Host.CreateApplicationBuilder(args);
builder.Services.AddMcpServer()
.WithStdioServerTransport()
.WithTools();
await builder.Build().RunAsync();
return 0;
}- 同时处理CLI和MCP模式
- 维护现有CLI功能
- 添加MCP服务器支持
- 共享核心业务逻辑
- 益处
- 增强的开发人员体验
- 人工智能辅助
- 与GitHub Copilot无缝集成
- 改进文档可访问性
贡献
欢迎投稿!请随时提交拉取请求。
许可证
麻省理工学院
