query_matrix
Search for keywords across topics and dates within the Revenue Engine MCP to analyze business data and track revenue-related information.
Instructions
Search Matrix for keyword across topics and dates
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| keyword | Yes | Search term | |
| topics | No | Topics to search (optional, defaults to all) | |
| limit | No | Max results (default 50) |
Implementation Reference
- index.js:711-713 (handler)Handler for the 'query_matrix' tool. Delegates execution to the external Google Apps Script API via callAPI function with action 'queryMatrix' and tool arguments.case "query_matrix": result = await callAPI("queryMatrix", args); break;
- index.js:454-476 (registration)Registration of the 'query_matrix' tool in the ListTools response, including name, description, and input schema definition.{ name: "query_matrix", description: "Search Matrix for keyword across topics and dates", inputSchema: { type: "object", properties: { keyword: { type: "string", description: "Search term" }, topics: { type: "array", items: { type: "string" }, description: "Topics to search (optional, defaults to all)" }, limit: { type: "number", description: "Max results (default 50)" } }, required: ["keyword"] } },
- index.js:457-474 (schema)Input schema for the 'query_matrix' tool, defining parameters: keyword (required), topics (optional array), limit (optional number).inputSchema: { type: "object", properties: { keyword: { type: "string", description: "Search term" }, topics: { type: "array", items: { type: "string" }, description: "Topics to search (optional, defaults to all)" }, limit: { type: "number", description: "Max results (default 50)" } }, required: ["keyword"]
- index.js:74-131 (helper)Helper function callAPI used by query_matrix handler to make POST request to Google Apps Script endpoint with action 'queryMatrix' and arguments.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; } }