feat(mcp): add local server lifecycle telemetry#1052
Conversation
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Codex review: needs real behavior proof before merge. Reviewed July 24, 2026, 4:00 PM ET / 20:00 UTC. ClawSweeper reviewWhat this changesThis PR adds bounded OpenTelemetry traces and metrics for local MCP server start, stop, request handling, admission failures, timeouts, and listener errors, plus tests and telemetry documentation. Merge readiness⛔ Blocked until real behavior proof from a real setup is added - 4 items remain Keep this draft PR open for normal review. The patch adds a useful diagnostics surface and focused coverage, but its claimed real behavior proof is test-only, so it does not yet demonstrate telemetry exported from a live MCP server or the required MCP discovery/invocation path. Priority: P3 Review scores
Verification
How this fits togetherThe local MCP HTTP server accepts requests from MCP clients and forwards JSON-RPC tool calls into the Windows node bridge. This change instruments that transport boundary so configured telemetry backends can observe server lifecycle and request outcomes without exporting request content. flowchart LR
A[MCP client] --> B[Local MCP HTTP server]
B --> C[Admission and authentication]
C --> D[Request handler]
D --> E[Windows node bridge]
B --> F[Lifecycle and request telemetry]
F --> G[Configured telemetry backend]
Before merge
Agent review detailsSecurityNone. Review metrics
Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the shared transport-level telemetry design, then add redacted current-head proof from a live configured collector plus a Do we have a high-confidence way to reproduce the issue? Not applicable: this PR proposes a new operational telemetry surface rather than reporting a currently broken behavior. The server paths can be exercised by live MCP discovery, invocation, and collector capture. Is this the best way to solve the issue? Unclear: the shared server boundary is a maintainable location for lifecycle instrumentation, and the included tests cover many paths, but the proposed solution still needs live collector and MCP invocation evidence to validate its privacy and runtime claims. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against f50af187865c. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.
What Problem This Solves
The local MCP server is a core debugging path, especially in MCP-only mode, but operators currently cannot observe server startup and shutdown, listener failures, authentication rejection, handler saturation, request deadlines, or HTTP handling duration through OpenTelemetry.
Why This Change Was Made
This adds typed traces and metrics at the shared MCP HTTP server boundary so MCP-only and gateway-enabled local MCP use the same diagnostics. It preserves existing HTTP behavior, keeps node-tool invocation telemetry independent, and exports only finite operational classifications with no request content, addresses, headers, tokens, JSON-RPC fields, or error messages.
User Impact
Operators and developers can diagnose local MCP lifecycle failures, authentication rejection, busy responses, timeouts, shutdown cancellation, and request latency through the existing configured OpenTelemetry pipeline. No UI, configuration, command, or protocol changes are required.
Evidence
Change Type
Scope
winnodeValidation
./build.ps1dotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --filter "FullyQualifiedName~McpServerTelemetryTests|FullyQualifiedName~McpHttpServerTelemetryTests|FullyQualifiedName~McpHttpServerTests" --no-restoredotnet test ./tests/OpenClaw.Shared.Tests/OpenClaw.Shared.Tests.csproj --no-restoredotnet test ./tests/OpenClaw.Tray.Tests/OpenClaw.Tray.Tests.csproj --no-restoreReal Behavior Proof
947448c4McpServerTelemetryTests,McpHttpServerTelemetryTests, andMcpHttpServerTestscommand listed aboveYes/No/N/A): N/Awinnodediscovery/invocation were not rerun. The changed telemetry and cancellation behavior is covered by current-head deterministic MCP HTTP integration tests.Security Impact
Yes/No): NoYes/No): NoYes/No): NoYes/No): NoYes/No): NoYes, explain the risk and mitigation: N/ACompatibility and Migration
Yes/No): YesYes/No): NoYes/No): NoReview Conversations