metrics.search
Search Facebook Insights metrics by name, description, or tags to quickly find relevant analytics data for your reporting needs.
Instructions
Performs fuzzy search over metrics by name, description, or tags
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| limit | No | Maximum number of results (default: 20) | |
| q | Yes | Search query |
Implementation Reference
- src/search.ts:41-52 (handler)Core implementation of the metrics.search tool logic using Fuse.js for fuzzy searching metrics by name, description, tags, and level.search(query: string, limit: number = 20): SearchResult[] { if (!query.trim()) { return this.metrics.slice(0, limit).map(metric => ({ item: metric })); } const results = this.fuse.search(query, { limit }); return results.map(result => ({ item: result.item, score: result.score, matches: result.matches ? [...result.matches] : undefined })); }
- src/server.ts:177-194 (handler)MCP server tool dispatcher case for 'metrics.search', validates input and calls the MetricsSearch engine.case 'metrics.search': { const { q, limit = 20 } = args as { q: string; limit?: number }; if (!q) { throw new Error('q parameter is required'); } const searchEngine = this.getSearchEngine(); const results = searchEngine.search(q, limit); return { content: [ { type: 'text', text: JSON.stringify(results, null, 2) } ] }; }
- src/server.ts:99-117 (schema)Input schema and metadata for the metrics.search tool, returned by listTools.{ name: 'metrics.search', description: 'Performs fuzzy search over metrics by name, description, or tags', inputSchema: { type: 'object', properties: { q: { type: 'string', description: 'Search query', }, limit: { type: 'number', description: 'Maximum number of results (default: 20)', default: 20, }, }, required: ['q'], }, },
- src/server.ts:285-291 (helper)Lazy initialization of the MetricsSearch instance used by the metrics.search handler.private getSearchEngine(): MetricsSearch { if (!this.searchEngine) { const metrics = this.getMetrics(); this.searchEngine = new MetricsSearch(metrics); } return this.searchEngine; }