chat_health
Check service connectivity and latency for AI conversation components to verify operational status before sending messages.
Instructions
Ping Anthropic and Qdrant services. Returns latency for each. Use to verify the app is operational before sending messages.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/app.ts:320-340 (registration)Registration of the chat_health tool with name, description, empty inputSchema, and execute function that calls adapter.health() and adds totalLatencyMs and status calculation.
{ name: "chat_health", description: "Ping Anthropic and Qdrant services. Returns latency for each. Use to verify the app is operational before sending messages.", inputSchema: { type: "object", properties: {}, }, execute: async () => { const start = Date.now(); const h = await adapter.health(); return { ...h, totalLatencyMs: Date.now() - start, status: h.anthropic.latencyMs < 10000 && h.qdrant.latencyMs < 10000 ? "healthy" : "degraded", }; }, }, - src/adapters/env.ts:708-737 (handler)Implementation of the health() method that pings Anthropic API and Qdrant healthz endpoint, measuring and returning latency for each service in the ChatHealth format.
async health() { // Anthropic ping const anthropicStart = Date.now(); try { await anthropic.messages.create({ model: "claude-haiku-4-5-20251001", max_tokens: 1, messages: [{ role: "user", content: "ping" }], }); } catch { // Ignore — we measure latency regardless } const anthropicLatency = Date.now() - anthropicStart; // Qdrant ping const qdrantStart = Date.now(); try { await fetch(`${qdrantUrl}/healthz`, { headers: { "api-key": qdrantKey }, }); } catch { // Ignore — we measure latency regardless } const qdrantLatency = Date.now() - qdrantStart; return { anthropic: { latencyMs: anthropicLatency }, qdrant: { latencyMs: qdrantLatency }, }; }, - src/types.ts:70-73 (schema)ChatHealth interface definition specifying the return type with anthropic and qdrant latencyMs fields.
export interface ChatHealth { anthropic: { latencyMs: number }; qdrant: { latencyMs: number }; } - src/types.ts:138-138 (schema)health() method signature in the ChatAdapter interface, returning Promise<ChatHealth>.
health(): Promise<ChatHealth>;