Skip to main content
Glama
getExampleDirectories.ts844 B
import fs from "fs-extra"; import path from "path"; export const getExampleDirectories = async (examplesDir: string) => { const entries = fs.readdirSync(examplesDir, { withFileTypes: true }); const directories = entries.filter((entry) => entry.isDirectory()); if (directories.length === 0) { throw new Error("No examples found in the examples directory."); } const examples = await Promise.all( directories.map(async (dir) => { const packageJsonPath = path.join(examplesDir, dir.name, "package.json"); let description = "No description available."; if (fs.existsSync(packageJsonPath)) { const packageJson = await fs.readJson(packageJsonPath); description = packageJson.description || description; } return { description, name: dir.name }; }), ); return examples; };

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/ExpertVagabond/universal-blockchain'

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