Ticket IDs restart per tenant, and other things I learned wiring a .NET backend to an MCP server
说明与用途
将 .NET 后端与 MCP 服务器集成导致租户隔离问题。解决方案包括创建专用内部控制器、严格验证、重新键入作业以及改进遥测。
问题
Integrating a .NET multi‑tenant backend with an MCP server caused tenant‑resolution bugs, data leakage, and incorrect job keys.
结果
Tenant isolation was restored, job keys no longer collide, telemetry accurately reflects per‑tenant usage, and agent‑initiated actions are safer and more transparent.
工作流
- 1. Create a dedicated internal controller for service‑to‑service calls. 2. Require org and user IDs in every internal request. 3. Validate ticket existence, status, and link conflicts before performing actions. 4. Re‑key asynchronous jobs to (TenantId, TicketId). 5. Add optional user ID to usage records and map via usage controller. 6. Migrate connector records into per‑tenant tables. 7. Test with multiple tenants to ensure isolation and correct telemetry.
证据
Ticket IDs restart per tenant… Jobs are keyed on (TenantId, TicketId) now.
Internal endpoints are not your public API… Different trust models.
- 记录日期: 2026-09-15T12:16:53.066Z