Troubleshooting & Root Cause Analysis (RCA) Overview
Home > Operations Troubleshooting & RCA
This guide provides an overview of operational troubleshooting, root cause analysis (RCA), and remediation runbooks for Model Context Gateway (MCG).
1. Modular Troubleshooting Runbooks
Subprocess & STDIO Transports Runbook Subprocess execution timeouts, stdio line-buffering, process signal traps (
SIGTERM/SIGKILL), and container STDIO execution using thelatest-fullimage variant.Authentication & Token Failures Runbook OIDC audience/issuer mismatches, RFC 9207 security enforcement, AppKey scope rejection, expired secret providers (Vault/DPAPI), and HTTP 401/403 header handling.
Database Locks & Migration Recovery Runbook SQLite lock contention (
database is locked), WAL journal mode, DDL migration recovery across SQLite/MSSQL/MySQL, master key re-encryption recovery, and database seeder idempotency.
2. Root Cause Analysis (RCA): Routing & Admin Issues
The sections below document a comprehensive Root Cause Analysis (RCA) performed on gateway session lifecycle management, tool routing synchronization, and Admin MCP server execution.
Executive Summary
During maintenance operations, automated tool execution via /sse failed with Tool not found in routing table, despite successful search_tools discovery and direct test_tool_call execution via /admin/sse. Deep architectural inspection revealed seven distinct bugs across session lifecycle management, cache synchronization, and Admin endpoints.
Key Issues & Architectural Root Causes
Issue 1: Stateless Session Lifecycle & Disposed HttpContext
- Mechanism: MCP clients making HTTP POST requests use stateless global session mappings. When an HTTP request completes (< 5ms), ASP.NET Core disposes
HttpContextand itsIFeatureCollection. Parallel background tasks inInitializeBackendsAsyncor retry loops that accessed_clientResponse.HttpContext.RequestServicesthrewObjectDisposedException. - Remediation: Decoupled service and identity resolution from request
HttpContext, utilizing rootIServiceProviderdirectly and guarding background accessors.
Issue 2: Routing Table Asymmetry in Meta-Mode Cold-Start
- Mechanism: When
search_toolsexecuted under "Cold-Start Fallback 1", it populated_cachedToolsfromSessionManager.GetAllCachedTools()but omitted populating_toolRoutingTable. Subsequentexecute_toolcalls failed withKeyNotFoundException. - Remediation: Updated cold-start fallback in
ToolRoutingManagerto populate_toolRoutingTablewhenever_cachedToolsis seeded.
Issue 3: Resilient Prefix-Based Tool Routing
- Mechanism: Direct tool execution failed when routing table entries were missing or cold-started.
- Remediation: Implemented resilient prefix parsing in
ExecuteTargetToolAsyncto dynamically resolve{serverId}__{toolName}or{serverId}/{toolName}prefixes directly against active enabled backends.
Issue 4: Admin MCP manage_servers: reconnect_all Session Sync
- Mechanism:
reconnect_allprobed servers inHealthCheckServicebut failed to trigger backend initialization on active client sessions. - Remediation: Updated
reconnect_allto notify all activeClientSessioninstances to start backend initialization.
Issue 5: SecretRetriever Injection into Admin test_tool_call
- Mechanism:
test_tool_callconstructedBackendConnectionwith anullISecretRetriever, preventing credential resolution for Vault or encrypted key backends. - Remediation: Injected
CompositeSecretRetrieverintoAdminMcpServerand passed it toBackendConnection.
3. Operations & Diagnostic Commands
Run diagnostic checks and query audit history using the Admin MCP Server:
{
"name": "manage_system",
"arguments": {
"action": "diagnostics"
}
}{
"name": "manage_system",
"arguments": {
"action": "query_audit",
"limit": 50
}
}