list_available_examples
Browse available React Native code examples organized by category to find implementation patterns and coding standards.
Instructions
List all available code examples by category
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:590-613 (handler)The MCP tool handler function for 'list_available_examples'. It calls the helper listAvailableExamples(), stringifies the result as JSON, and returns it as text content. Includes error handling.async () => { try { const examples = listAvailableExamples(); return { content: [ { type: "text", text: JSON.stringify(examples, null, 2), }, ], }; } catch (err) { console.error("Error listing available examples:", err); return { content: [ { type: "text", text: `Error listing available examples: ${err}`, }, ], }; } },
- src/index.ts:112-146 (helper)Core helper function that lists all available code examples by scanning the 'resources/code-examples/react-native' subdirectories (components, hooks, services, screens, themes) for JS/TS/JSX/TSX files and collecting their basenames without extensions.function listAvailableExamples() { const examples: Record<string, string[]> = { components: [], hooks: [], services: [], screens: [], themes: [] }; const categories = [ { key: "components", dir: "components" }, { key: "hooks", dir: "hooks" }, { key: "services", dir: "services" }, { key: "screens", dir: "screens" }, { key: "themes", dir: "theme" } ]; const extensions = ['.js', '.jsx', '.ts', '.tsx']; for (const category of categories) { const dirPath = path.join(CODE_EXAMPLES_DIR, "react-native", category.dir); if (fs.existsSync(dirPath)) { for (const ext of extensions) { const files = glob.sync(`${dirPath}/**/*${ext}`); for (const filePath of files) { const fileName = path.basename(filePath); const fileNameNoExt = path.basename(fileName, path.extname(fileName)); examples[category.key].push(fileNameNoExt); } } } } return examples; }
- src/index.ts:586-614 (registration)Registers the 'list_available_examples' tool with the MCP server, specifying name, description, empty input schema, and the inline handler function.server.tool( "list_available_examples", "List all available code examples by category", {}, async () => { try { const examples = listAvailableExamples(); return { content: [ { type: "text", text: JSON.stringify(examples, null, 2), }, ], }; } catch (err) { console.error("Error listing available examples:", err); return { content: [ { type: "text", text: `Error listing available examples: ${err}`, }, ], }; } }, );