MonitorClient & Transport Layer
MonitorClient is a thin HTTP wrapper used by MCP tool handlers to communicate with the monitor server. The most important goal of this layer is "to ensure that monitoring failures do not become agent task failures".
Core Files
packages/mcp/src/client.tspackages/mcp/src/result.ts
Current Role
MonitorClient
- Uses
MONITOR_BASE_URLor defaulthttp://127.0.0.1:3847 - Provides
get()andpost() - Does not throw exceptions even if network fails or abnormal response comes
- Always returns in
SafePostResultform
toToolResponse()
- Converts
SafePostResultto MCP tool response format contentcontains a short text messagestructuredContentcontains the full result object
Why This Design
The monitor server is an auxiliary system. If the server dies, the actual work of Claude or manual clients should not stop, so the transport layer has a strong "best effort" policy.
Because of this, the skill/hook/plugin side can be used simply like this:
- On success:
ok: true,message: "monitor event recorded" - On failure:
ok: false,message: "monitor server unavailable; event ignored"
Current Strengths
- Caller side doesn't get complex with exception handling.
- Works well with gap report policy when monitor server is unavailable.
- Easy client injection in tests makes MCP server validation simple.
Considerations
- Strong assumption that successful responses are JSON.
- If changed to 204 responses or text/plain responses, supplementation is needed.
- Currently no retry or backoff, so transient network errors are silently ignored.