Skip to main content
Glama
storage-validation.js1.56 kB
/** * Utility functions for validating and ensuring proper storage configurations */ const fs = require('fs'); const path = require('path'); const validStorageTypes = ['json', 'memory']; /** * Validates that the provided storageType is supported * @param {string} storageType - The storage type to validate (e.g., "json" or "memory") * @throws {Error} If the storage type is not supported */ function validateStorageType(storageType) { if (!validStorageTypes.includes(storageType)) { throw new Error(`Unsupported storage type: ${storageType}. Supported types: ${validStorageTypes.join(', ')}`); } } /** * Ensures that a storagePath value is provided and not empty/null * @param {string} storagePath - The storage path to validate * @param {string} storageType - The storage type being used * @throws {Error} If the storagePath is not provided for the specified storageType */ function ensureStoragePathProvided(storagePath, storageType) { if (storageType === 'json' && (!storagePath || storagePath.trim() === '')) { throw new Error(`A storage path must be provided for JSON storage`); } } /** * Validates that the required directory for the storage path exists * @param {string} storagePath - The storage path to validate * @throws {Error} If the directory doesn't exist */ function validateStoragePath(storagePath) { if (!fs.existsSync(storagePath)) { fs.mkdirSync(path.dirname(storagePath), { recursive: true }); } } module.exports = { validateStorageType, ensureStoragePathProvided, validateStoragePath, };

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/Garblesnarff/gemini-mcp-server'

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