Skip to main content
Glama

mcp-server-cloudflare

Official
by cloudflare
utils.ts1.04 kB
/** * Utility functions for common operations */ /** * Parse a relative time string into seconds */ export function parseRelativeTime(input: string): number { const units = { s: 1, m: 60, h: 3600, d: 86400, w: 604800 } as const const cleanedInput = input.replace(/\s+/g, '').toLowerCase() if (!/^[+-](?:\d+[smhdw]){1,}$/.test(cleanedInput)) { throw new Error(`Invalid relative time format: ${input}`) } const sign = cleanedInput.startsWith('-') ? -1 : 1 const timeStr = cleanedInput.slice(1) // Remove the sign const matches = timeStr.match(/\d+[smhdw]/g) if (!matches) { throw new Error(`No matches found while parsing relative time: ${timeStr}`) } const seconds = matches.reduce((total, match) => { const value = parseInt(match) const unit = match.slice(-1) as keyof typeof units return total + value * units[unit] }, 0) return sign * seconds } /** * Get the current time as an ISO string without milliseconds */ export function nowISO(): string { return new Date().toISOString().split('.')[0] + 'Z' }

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

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