matrix_time_analysis
Analyze time spent across Matrix entries by grouping data into topics, bugs, weeks, or days. Tracks total time using markers like [30m] or [2h] from entries to provide insights into time allocation.
Instructions
Analyze time spent across Matrix entries. Tracks total time by topic, bug UID, or week. Parses time markers like [30m], [2h] from entries.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| startDate | No | Start date YYYY-MM-DD (optional, defaults to beginning) | |
| endDate | No | End date YYYY-MM-DD (optional, defaults to today) | |
| groupBy | No | How to group the analysis |
Implementation Reference
- index.js:723-725 (handler)Handler for the matrix_time_analysis tool. Forwards the tool arguments to the Google Apps Script API endpoint 'matrixTimeAnalysis' using the callAPI helper function.case "matrix_time_analysis": result = await callAPI("matrixTimeAnalysis", args); break;
- index.js:520-537 (schema)Input schema for the matrix_time_analysis tool, defining optional parameters startDate, endDate, and groupBy with enum values.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)" }, groupBy: { type: "string", description: "How to group the analysis", enum: ["topic", "bug", "week", "day"] } } }
- index.js:517-538 (registration)Registration of the matrix_time_analysis tool in the MCP server's ListTools response, including name, description, and input schema.{ name: "matrix_time_analysis", description: "Analyze time spent across Matrix entries. Tracks total time by topic, bug UID, or week. Parses time markers like [30m], [2h] from entries.", 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)" }, groupBy: { type: "string", description: "How to group the analysis", enum: ["topic", "bug", "week", "day"] } } } },
- index.js:74-131 (helper)Helper function callAPI used by all proxied tools, including matrix_time_analysis, to make HTTP POST requests 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; } }