Pigello模拟API和MCP服务器
Pigello物业管理的完整解决方案,包括模拟API和MCP服务器。
项目结构
PigelloMockAPI/
├── PigelloMockAPI/ # Mock API (REST)
│ ├── Controllers/ # 7 API controllers
│ ├── Models/ # 7 datamodeller
│ ├── Data/ # InMemoryDataStore + JSON seed data
│ └── Port: 5059
│
└── PigelloMCP/ # MCP Server (HTTP/SSE)
├── McpTools/ # MCP verktyg som anropar Mock API
├── Program.cs # MCP server konfiguration
└── Port: 5063开始
1.启动模拟API
cd PigelloMockAPI/PigelloMockAPI
dotnet run模拟API运行: http://localhost:5059
- Swagger用户界面:
http://localhost:5059/swagger - 测试数据:5个用户,4个物业,6栋建筑,9个房间,7个组件模型,9个组件,10个案例
2.启动MCP服务器
cd PigelloMCP/PigelloMCP
dotnet runMCP 服务器运行: http://localhost:5063
- 信息:
http://localhost:5063/ - 健康:
http://localhost:5063/health - MCP端点:
http://localhost:5063/api/mcp
MCP 服务器工具
MCP服务器通过模型上下文协议暴露14个工具:
案例(Cases)
- GetCases - 通过过滤获取项目(用户,建筑物,属性,状态)
- GetCase 获取具体案例
- 更新案例状态 - 更新案件状态(关闭/关闭)
- CreateCase - 创建新案例
建筑物和房间
- GetBuildings 可选属性过滤器(Optional Property Filter)
- GetRooms 可选建筑过滤器(Optional building filter)
组件
- GetComponents - 获取组件(房间/建筑/状态过滤器)
- 创建组件 在空间中创建组件
- GetComponentModels 分类过滤器(Category filter)
- 创建组件模型 创建组件模型
其它
- GetUsers 的 下载用户
- 获取属性 - 获取房地产
使用范例
从 GitHub Copilot 连接到 MCP 服务器
Konfigurera i与Code eller代码空间:
{
"mcpServers": {
"pigello": {
"type": "sse",
"url": "http://localhost:5063/api/mcp"
}
}
}Copilot 问题示例
配置 MCP 服务器后:
"Visa mina ärenden"
→ Anropar GetCases med din user ID
"Vilka ärenden finns för byggnad Rosenlund?"
→ Filtrerar på buildingId
"Stäng ärende 11111111-1111-1111-1111-111111111111"
→ Anropar UpdateCaseStatus med status=Closed (3)
"Skapa ett ärende om trasig diskmaskin i kök"
→ Anropar CreateCase med lämpliga parametrar
"Vilka komponenter finns i tvättstugan?"
→ Anropar GetComponents filtrerat på roomId测试数据ID
对于测试,请使用这些 ID:
用户:
- 安娜·安德森:
11111111-1111-1111-1111-111111111111 - 埃里克·埃里克森:
22222222-2222-2222-2222-222222222222 - 玛丽亚·斯文森(VVS):
33333333-3333-3333-3333-333333333333
属性:
- 罗森伦德:
aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa - 利杰霍姆:
bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb
建筑:
- Rosenlund Hus A:
11111111-1111-1111-1111-111111111111 - Rosenlund Hus B:
12222222-2222-2222-2222-222222222222
房间:
- 厨房(A):
11111111-1111-1111-1111-111111111111 - 巴德鲁姆(Hus A):
12222222-2222-2222-2222-222222222222 - 洗衣房:
15555555-5555-5555-5555-555555555555
部署到Azure
模拟API直到Azure应用服务
cd PigelloMockAPI/PigelloMockAPI
az webapp up --name pigello-mock-api --resource-group your-rg --runtime "DOTNET:9.0"MCP服务器到Azure应用服务
cd PigelloMCP/PigelloMCP
az webapp up --name pigello-mcp-server --resource-group your-rg --runtime "DOTNET:9.0"Konfigurera应用程序设置i Azure:
az webapp config appsettings set --name pigello-mcp-server --resource-group your-rg \
--settings PigelloMockAPI__BaseUrl="https://pigello-mock-api.azurewebsites.net"更新 Azure 的 MCP 配置:
{
"mcpServers": {
"pigello": {
"type": "sse",
"url": "https://pigello-mcp-server.azurewebsites.net/api/mcp"
}
}
}技术栈
- .NET 9.0
- ASP。NET核心Web API
- 模型上下文协议。AspNetCore (预览)
- HTTP/SSE传输 关于MCP
- 内存数据库 med JSON种子数据
- CORS已启用 跨来源请求 Cross-origin requests
- Azure应用服务就绪
Endpoint 概述
模拟API(端口5059)
GET /api/users用户列表GET /api/properties房地产列表GET /api/buildings建筑物清单GET /api/rooms-房间列表GET /api/cases- 事项列表GET /api/componentmodels- 组件模型列表GET /api/components-组件列表- 所有 CRUD 操作
MCP服务器(端口5063)
GET /-服务信息GET /health-健康检查POST /api/mcp-MCP端点(SSE/HTTP)
发展
# Restore alla dependencies
dotnet restore
# Bygg båda projekten
dotnet build
# Kör tester
dotnet test
# Publicera för produktion
dotnet publish -c Release许可证
Pigello物业管理的内部原型。 模拟API来模拟Pigellos API的部分。创建用于测试针对Pigello构建MCP服务器,而无需任何Pigello环境
