Azure MCP 服务器是一个借助 mcp-framework 构建的 Model Context Protocol (MCP) 服务器,它提供了与 Azure 服务进行交互的实用工具,能有效提升与 Azure 服务交互的效率。
以下是启动服务器的步骤:
# 安装依赖项
npm install
# 构建项目
npm run build
# 启动服务器
npm start
azure-mcp-server/
├── src/
│ ├── tools/ # MCP 工具
│ │ ├── Storage/ # Azure 存储工具
│ │ ├── VirtualMachine/ # Azure 虚拟机工具
│ │ └── AppService/ # Azure 应用服务工具
│ └── index.ts # 服务器入口点
├── package.json
└── tsconfig.json
此服务器提供了与多个 Azure 服务交互的工具,具体信息如下:
| 服务 | 工具前缀 | 描述 |
|---|---|---|
| 存储 | azure_* |
Blob 存储操作 |
| 虚拟机 | azure_vms_* |
VM 管理操作 |
| 应用服务 | azure_app_* |
应用服务操作 |
下面是创建新工具的示例代码:
import { MCPTool } from 'mcp-framework';
import { z } from 'zod';
interface MyToolInput {
message: string;
}
class MyTool extends MCPTool<MyToolInput> {
name = 'my_tool';
description = '描述你的工具的功能';
schema = {
message: {
type: z.string(),
description: '此输入参数的描述'
}
};
async execute(input: MyToolInput) {
// 你的工具逻辑在这里
return `处理结果:${input.message}`;
}
}
export default MyTool;
如果你在使用 Azure 工具时遇到问题,请检查控制台日志以获取详细的调试信息。常见问题包括:
npm run build 进行编译。