fleet_session_delete
Delete a fleet session by ID to free server resources after monitoring is complete. Confirm deletion with the session ID.
Instructions
Delete a fleet session by ID. Response: { deleted: true, session_id }. Call when monitoring is complete to free server resources.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| session_id | Yes | Fleet session ID to delete |
Implementation Reference
- src/index.ts:685-701 (registration)Registration of the fleet_session_delete tool using server.tool() with the name 'fleet_session_delete'.
server.tool( "fleet_session_delete", "Delete a fleet session by ID. Response: { deleted: true, session_id }. Call when monitoring is complete to free server resources.", { session_id: z.string().describe("Fleet session ID to delete"), }, async ({ session_id }) => { const guard = requireApiKey(); if (guard) return guard; const result = await apiFetch("/api/fleet-session", { method: "POST", headers: apiKeyHeaders(), body: { action: "delete", session_id }, }); return formatResult(result); } ); - src/index.ts:689-689 (schema)Input schema: session_id parameter defined as z.string() for the fleet session ID to delete.
session_id: z.string().describe("Fleet session ID to delete"), - src/index.ts:691-700 (handler)Handler function that calls the API endpoint /api/fleet-session with action 'delete' and the provided session_id.
async ({ session_id }) => { const guard = requireApiKey(); if (guard) return guard; const result = await apiFetch("/api/fleet-session", { method: "POST", headers: apiKeyHeaders(), body: { action: "delete", session_id }, }); return formatResult(result); } - src/index.ts:33-38 (helper)apiKeyHeaders helper used by the handler to attach authentication headers.
/** Headers using X-API-Key auth (for all authenticated endpoints) */ function apiKeyHeaders(extra?: Record<string, string>): Record<string, string> { const h: Record<string, string> = { "Content-Type": "application/json" }; if (API_KEY) h["X-API-Key"] = API_KEY; return { ...h, ...extra }; } - src/index.ts:47-70 (helper)apiFetch helper used by the handler to make the HTTP POST request to the backend API.
async function apiFetch( path: string, opts: { method?: string; headers?: Record<string, string>; body?: unknown } = {} ): Promise<ApiResult> { const url = `${BASE_URL}${path}`; try { const res = await fetch(url, { method: opts.method || "GET", headers: opts.headers || { "Content-Type": "application/json" }, body: opts.body ? JSON.stringify(opts.body) : undefined, }); const text = await res.text(); let data: unknown; try { data = JSON.parse(text); } catch { data = { raw: text }; } return { ok: res.ok, status: res.status, data }; } catch (err: unknown) { const message = err instanceof Error ? err.message : String(err); return { ok: false, status: 0, data: { error: `Network error: ${message}` } }; } }