Skip to main content
Glama
lallen30
by lallen30

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
NameRequiredDescriptionDefault

No arguments

Implementation Reference

  • 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}`, }, ], }; } },
  • 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}`, }, ], }; } }, );

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/lallen30/mcp-remote-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server