/**
* Schema Helper Utilities
*
* Shared utility functions for schema validation and preprocessing.
*/
/**
* Convert empty strings to undefined in an object (shallow transformation)
* Used for preprocessing Zod schemas with optional fields
*
* @param value - The value to process
* @returns The processed value with empty strings converted to undefined
*/
export function nullifyEmptyStrings(value: unknown): unknown {
if (value && typeof value === 'object' && !Array.isArray(value)) {
const copy: Record<string, unknown> = { ...(value as Record<string, unknown>) };
for (const key of Object.keys(copy)) {
const v = copy[key];
if (typeof v === 'string' && v.trim() === '') copy[key] = undefined;
}
return copy;
}
return value;
}
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/cameroncooke/XcodeBuildMCP'
If you have feedback or need assistance with the MCP directory API, please join our Discord server