read_matrix_snapshot
Retrieve revenue tracking data from Google Sheets for specific topics and date ranges to analyze business performance metrics and pipeline status.
Instructions
Read Matrix entries for a date range. Returns all entries for specified topics and dates.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| endDate | No | End date YYYY-MM-DD (optional, defaults to today) | |
| startDate | No | Start date YYYY-MM-DD (optional, defaults to beginning) | |
| topics | No | Array of topics to include (optional, defaults to all) |
Implementation Reference
- index.js:419-440 (registration)Registration of the 'read_matrix_snapshot' tool in the ListToolsRequestSchema handler, including name, description, and input schema.{ name: "read_matrix_snapshot", description: "Read Matrix entries for a date range. Returns all entries for specified topics and dates.", inputSchema: { type: "object", properties: { startDate: { type: "string", description: "Start date YYYY-MM-DD (optional, defaults to beginning)" }, endDate: { type: "string", description: "End date YYYY-MM-DD (optional, defaults to today)" }, topics: { type: "array", items: { type: "string" }, description: "Array of topics to include (optional, defaults to all)" } } } },
- index.js:422-438 (schema)Input schema definition for the 'read_matrix_snapshot' tool.inputSchema: { type: "object", properties: { startDate: { type: "string", description: "Start date YYYY-MM-DD (optional, defaults to beginning)" }, endDate: { type: "string", description: "End date YYYY-MM-DD (optional, defaults to today)" }, topics: { type: "array", items: { type: "string" }, description: "Array of topics to include (optional, defaults to all)" } }
- index.js:703-705 (handler)Handler implementation in the CallToolRequestSchema switch statement. Proxies the tool call to the Google Apps Script backend via callAPI with action 'readMatrixSnapshot'.case "read_matrix_snapshot": result = await callAPI("readMatrixSnapshot", args); break;
- index.js:74-131 (helper)Shared helper function callAPI that handles proxying all API-based tools to the Google Apps Script web app.async function callAPI(action, data = {}) { debugLog('=== API CALL START ==='); debugLog(`Action: ${action}`); debugLog(`Data: ${JSON.stringify(data)}`); try { // Build form-encoded body for POST const formData = new URLSearchParams(); formData.append('action', action); // Add all data fields to form for (const [key, value] of Object.entries(data)) { if (value !== undefined && value !== null) { formData.append(key, value.toString()); } } const formString = formData.toString(); debugLog(`FormData: ${formString}`); debugLog(`API_URL: ${API_URL}`); // Use POST with proper content type const response = await fetch(API_URL, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, body: formString }); debugLog(`Response status: ${response.status}`); debugLog(`Response ok: ${response.ok}`); if (!response.ok) { debugLog(`Response not OK: ${response.status} ${response.statusText}`); throw new Error(`API request failed: ${response.status} ${response.statusText}`); } const text = await response.text(); debugLog(`Response text length: ${text.length}`); debugLog(`Response text: ${text}`); if (!text) { debugLog('ERROR: Empty response from API'); throw new Error('Empty response from API'); } const parsed = JSON.parse(text); debugLog(`Parsed successfully: ${JSON.stringify(parsed)}`); debugLog('=== API CALL END ==='); return parsed; } catch (error) { debugLog(`ERROR in callAPI: ${error.message}`); debugLog(`ERROR stack: ${error.stack}`); throw error; } }