Skip to main content
Glama

read_matrix_snapshot

Retrieve matrix entries for specified topics and date ranges to support revenue tracking and business management.

Instructions

Read Matrix entries for a date range. Returns all entries for specified topics and dates.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
startDateNoStart date YYYY-MM-DD (optional, defaults to beginning)
endDateNoEnd date YYYY-MM-DD (optional, defaults to today)
topicsNoArray of topics to include (optional, defaults to all)

Implementation Reference

  • index.js:420-440 (registration)
    Registers the 'read_matrix_snapshot' tool with the MCP server, 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)"
          }
        }
      }
    },
  • Input schema defining optional parameters startDate, endDate, and topics array for filtering matrix 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)"
        },
        topics: {
          type: "array",
          items: { type: "string" },
          description: "Array of topics to include (optional, defaults to all)"
        }
      }
  • Handler in the CallToolRequestSchema switch statement that invokes callAPI('readMatrixSnapshot', args) to execute the tool logic via Google Apps Script.
    case "read_matrix_snapshot":
      result = await callAPI("readMatrixSnapshot", args);
      break;
  • Helper function that makes HTTP POST requests to the Google Apps Script API endpoint, used by all matrix tools including read_matrix_snapshot to delegate execution.
    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;
      }
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/PromptishOperations/mcpSpec'

If you have feedback or need assistance with the MCP directory API, please join our Discord server