{"record":{"id":"050f3f4693acf600","repo":"dapr/dapr","slug":"flush-mcp-servers-w","errorCode":null,"errorMessage":"flush MCP servers: %w","messagePattern":"flush MCP servers: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/runtime/mcpservers.go","lineNumber":98,"sourceCode":"\t\treturn nil\n\tcase err := <-ch:\n\t\tif err == nil {\n\t\t\treturn nil\n\t\t}\n\t\terr = fmt.Errorf(\"process MCPServer %s error: %s\", s.Name, err)\n\t\tif s.Spec.IgnoreErrors {\n\t\t\tlog.Errorf(\"Ignoring error processing MCPServer: %s\", err)\n\t\t\treturn nil\n\t\t}\n\t\tlog.Warnf(\"Error processing MCPServer, daprd will exit gracefully: %s\", err)\n\t\treturn err\n\t}\n}\n\nfunc (a *DaprRuntime) flushOutstandingMCPServers(ctx context.Context) error {\n\tlog.Info(\"Waiting for all outstanding MCP servers to be processed…\")\n\tif err := a.processor.Flush(ctx); err != nil {\n\t\treturn fmt.Errorf(\"flush MCP servers: %w\", err)\n\t}\n\tlog.Info(\"All outstanding MCP servers processed\")\n\treturn nil\n}\n","sourceCodeStart":80,"sourceCodeEnd":103,"githubUrl":"https://github.com/dapr/dapr/blob/74ad41702745709bb15fe2114ff693b8c59bc3cc/pkg/runtime/mcpservers.go#L80-L103","documentation":"Raised while waiting for outstanding MCP server initializations: processor.Flush — the barrier over the shared root loop that resolves when every in-flight init completes — returned an error. Either a pending MCP server (or a component/HTTPEndpoint co-scheduled on the same root loop) failed to init, or the context was canceled before the drain finished.","triggerScenarios":"flushOutstandingMCPServers runs during daprd startup/shutdown; it fails when an MCP server init errors (auth failure, unreachable server) or ctx is canceled (shutdown timeout) while inits are still pending.","commonSituations":"An MCP server pointing at an endpoint that is not yet up blocks the flush; shutdown grace period shorter than slow MCP client construction; concurrent failing components on the shared root loop surfacing through this wrap.","solutions":["Inspect the init errors logged just before this line to identify the failing MCP server and fix its spec/auth","Delay applying MCP servers (or add readiness ordering) until target endpoints and secrets exist","Increase terminationGracePeriodSeconds if the failure happens at shutdown drain","Remove the offending MCPServer resource and restart daprd"],"exampleFix":"# before: MCP server applied before the target endpoint exists\n# after: init container / Helm hook waits for the endpoint\nstartupProbe / preHook: curl -fsS https://mcp.example.com/health","handlingStrategy":"validation","validationCode":"# pre-flight: target MCP endpoints answer before daprd starts\nfor url in $(kubectl get mcpservers -n <ns> -o json | jq -r '.items[].spec.serverUrl? // empty'); do curl -fsS --max-time 5 \"$url\" || echo \"not ready: $url\"; done","typeGuard":null,"tryCatchPattern":"if err := rt.flushOutstandingMCPServers(ctx); err != nil && errors.Is(err, context.Canceled) { /* graceful-shutdown drain cut short: extend grace period */ }","preventionTips":["Apply MCP servers only after target endpoints and secrets are ready","Keep terminationGracePeriodSeconds larger than slowest MCP client construction","Monitor ComponentInitFailed metrics to catch failing resources before flush"],"tags":["mcp","mcpserver","flush","processor","init","shutdown"],"backgroundTag":null,"analyzedSha":"74ad41702745709bb15fe2114ff693b8c59bc3cc","analyzedAt":"2026-08-16T04:22:26.543Z","schemaVersion":2},"datasetVersion":"2026-08-16T08:17:34.114Z"}