search-figma-developer-docs
Search Figma developer documentation to find specific information across Plugin, Widget, and REST API sections. Get relevant page paths and content excerpts for development queries.
Instructions
Search across all Figma developer documentation for a keyword or phrase. Returns matching page paths and relevant excerpts. Useful when you know what you're looking for but not which page it's on.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| query | Yes | Search query — keyword or phrase to find in the documentation | |
| section | No | Optional: limit search to a specific section (e.g., 'plugins', 'rest-api', 'widgets') | |
| maxResults | No | Maximum number of results to return (default: 10) |
Implementation Reference
- src/index.ts:148-216 (handler)The handler function for 'search-figma-developer-docs' that performs a keyword search across indexed Figma developer documentation.
async ({ query, section, maxResults }) => { const index = loadIndex(); const queryLower = query.toLowerCase(); const results: Array<{ path: string; title: string; excerpt: string; score: number; }> = []; const sectionsToSearch = section ? { [section]: index.sections[section] } : index.sections; for (const [, sectionData] of Object.entries(sectionsToSearch)) { if (!sectionData) continue; for (const page of sectionData.pages) { const content = loadPage(page.path); if (!content) continue; const contentLower = content.toLowerCase(); const titleLower = page.title.toLowerCase(); let score = 0; if (titleLower.includes(queryLower)) score += 10; let idx = 0; let contentMatches = 0; while ( (idx = contentLower.indexOf(queryLower, idx)) !== -1 && contentMatches < 50 ) { contentMatches++; idx += queryLower.length; } score += contentMatches; if (score === 0) continue; let excerpt = ""; const firstMatch = contentLower.indexOf(queryLower); if (firstMatch !== -1) { const start = Math.max(0, firstMatch - 100); const end = Math.min(content.length, firstMatch + query.length + 200); excerpt = content.slice(start, end).replace(/\n/g, " ").trim(); if (start > 0) excerpt = "..." + excerpt; if (end < content.length) excerpt = excerpt + "..."; } results.push({ path: page.path, title: page.title, excerpt, score }); } } results.sort((a, b) => b.score - a.score); const topResults = results.slice(0, maxResults || 10); return { content: [ { type: "text" as const, text: JSON.stringify( { query, section: section || "all", totalMatches: results.length, results: topResults }, null, 2 ), }, ], }; - src/index.ts:125-147 (registration)The registration of the 'search-figma-developer-docs' tool, including its schema and metadata.
server.registerTool( "search-figma-developer-docs", { title: "Search Figma Developer Docs", description: "Search across all Figma developer documentation for a keyword or phrase. Returns matching page paths and relevant excerpts. Useful when you know what you're looking for but not which page it's on.", inputSchema: { query: z .string() .describe("Search query — keyword or phrase to find in the documentation"), section: z .string() .optional() .describe( "Optional: limit search to a specific section (e.g., 'plugins', 'rest-api', 'widgets')" ), maxResults: z .number() .optional() .default(10) .describe("Maximum number of results to return (default: 10)"), }, },