metrics.refreshNow
Refresh the in-memory cache by re-parsing the Markdown file to ensure access to current Facebook Insights metrics data.
Instructions
Re-parses the Markdown file and reloads the in-memory cache
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/server.ts:196-206 (handler)Handler for the metrics.refreshNow tool: calls refreshMetrics() and returns success response.case 'metrics.refreshNow': { await this.refreshMetrics(); return { content: [ { type: 'text', text: 'Metrics refreshed successfully' } ] }; }
- src/server.ts:118-125 (registration)Registration of metrics.refreshNow tool including name, description, and input schema.{ name: 'metrics.refreshNow', description: 'Re-parses the Markdown file and reloads the in-memory cache', inputSchema: { type: 'object', properties: {}, }, },
- src/server.ts:293-315 (helper)Core helper function implementing metric refresh: parses markdown, saves to loader, clears cache, updates search engine.private async refreshMetrics(): Promise<void> { try { const parser = new MarkdownParser(this.markdownPath); const parsedMetrics = parser.parseMetrics(); const metricsFile: MetricsFile = { version: parser.getVersion(), updatedAt: parser.getLastUpdated(), metrics: parsedMetrics }; this.metricsLoader.saveMetrics(metricsFile); this.metricsLoader.clearCache(); // Update search engine this.searchEngine = new MetricsSearch(parsedMetrics); // console.log(`Refreshed ${parsedMetrics.length} metrics from markdown`); } catch (error) { console.error('Failed to refresh metrics:', error); throw error; } }