Azure服务总线MCP服务器
A. 模型上下文协议(MCP) 提供与Azure服务总线队列交互工具的服务器。
此工具的功能被故意限制,因为发送ServiceBus消息是一项潜在的敏感操作。
\[!警告\] 此仓库中的HTTP(未经身份验证)项目在没有任何身份验证的情况下运行,不建议您在生产环境中运行它,它主要是作为如何使用HTTP传输的基本示例。
特性
可用工具
- GetQueues -列出Service Bus命名空间中的所有可用队列
- 获取消息计数。 -获取Service Bus队列中活动消息的数量
- GetDeadletterMessageCount -获取队列中死信消息的数量
- 获取消息 -从服务总线队列中检索消息(仅限活动消息)
- Get死锁 -从队列中检索死信
- 结果 -将特定死信消息重新提交回活动队列
- 报道 -将队列中的所有死信重新提交回活动队列
配置
应用程序参数
创建或更新您的 appsettings.json 包含服务总线配置的文件:
{
"ServiceBus": {
"ConnectionString": "your-service-bus-connection-string",
"Namespace": "your-service-bus-namespace"
}
}认证
服务器使用Azure Identity通过Azure ServiceBus进行身份验证。您可以使用以下方式进行身份验证:
- Azure命令行界面:
az login - Visual Studio:登录您的Azure帐户
- 环境变量:设置
AZURE_CLIENT_ID,AZURE_CLIENT_SECRET,AZURE_TENANT_ID - 管理身份:在Azure中运行时
运行MCP服务器
现在,您只需修改MCP.json,并通过stdio添加对可执行文件的引用,即可运行MCP服务器。
"servicebus": {
"type": "stdio",
"command": "
"
},示例用法
连接后,您可以通过MCP客户端使用这些工具:
"How many messages are in the 'orders' queue?"
→ Uses GetMessageCount tool
"Show me the dead letter messages in the 'payments' queue"
→ Uses GetDeadletterMessages tool
"What queues are available?"
→ Uses GetQueues tool
"Resubmit the dead letter message with ID 'abc123' from the 'orders' queue"
→ Uses ResubmitDeadletterMessage tool