get-total-size-reduced
Calculate the total file size reduction achieved by Compresto’s compression app, providing insights into data optimization and storage efficiency.
Instructions
Get total file size reduced of Compresto
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:113-137 (handler)Handler function that fetches landing page data from Supabase API and returns the totalReducedSize as formatted text content, handling errors by returning an error message.async () => { const url = `${API_BASE}/v1/getLandingPageData`; const response = await makeSupabaseRequest<LandingPageDataResponse>(url); if (!response) { return { content: [ { type: "text", text: "Failed to fetch user data" } ], isError: true }; } return { content: [ { type: "text", text: `Reduced ${response.data.totalReducedSize} bytes` } ] }; },
- src/index.ts:109-138 (registration)Registration of the 'get-total-size-reduced' tool using McpServer.tool, with description, empty input schema, and inline async handler.server.tool( "get-total-size-reduced", "Get total file size reduced of Compresto", {}, async () => { const url = `${API_BASE}/v1/getLandingPageData`; const response = await makeSupabaseRequest<LandingPageDataResponse>(url); if (!response) { return { content: [ { type: "text", text: "Failed to fetch user data" } ], isError: true }; } return { content: [ { type: "text", text: `Reduced ${response.data.totalReducedSize} bytes` } ] }; }, );
- src/index.ts:19-35 (helper)Shared helper function for making API requests to Supabase functions with error handling and JSON parsing, used by the tool handler.async function makeSupabaseRequest<T>(url: string): Promise<T | null> { const headers = { "User-Agent": USER_AGENT, Accept: "application/json", }; try { const response = await fetch(url, { headers }); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return (await response.json()) as T; } catch (error) { console.error("Error making Supabase request:", error); return null; } }
- src/index.ts:38-45 (schema)Type definition for the API response structure, including the totalReducedSize field consumed by the tool.interface LandingPageDataResponse { data: { totalUsers: number; totalCompressedVideos: number; totalReducedSize: number; monthlyUsers: number; } }