Skip to main content
Glama

Joke MCP Server

by ericqian77
config.js2.36 kB
import { normalizeCategory, normalizeLang, sanitizeBlacklist, SUPPORTED_CATEGORIES, SUPPORTED_LANGS } from './validation.js'; const DEFAULTS = { provider: 'jokeapi', category: 'programming', lang: 'en', timeoutMs: 2000, retries: 2, allowNet: false, verbose: false, }; export function loadConfig(env = process.env) { const provider = normalizeProvider(env.JOKE_API ?? DEFAULTS.provider); const defaultCategory = normalizeCategory(env.JOKE_DEFAULT_CATEGORY, DEFAULTS.category); const lang = normalizeLang(env.JOKE_LANG, DEFAULTS.lang); const timeoutMs = parsePositiveInt(env.TIMEOUT_MS, DEFAULTS.timeoutMs, 'TIMEOUT_MS'); const retries = parseNonNegativeInt(env.RETRIES, DEFAULTS.retries, 'RETRIES'); const allowNet = parseBoolean(env.ALLOW_NET, DEFAULTS.allowNet); const verbose = parseBoolean(env.LOG_VERBOSE, DEFAULTS.verbose); return { provider, defaultCategory, lang, timeoutMs, retries, allowNet, verbose, supportedCategories: SUPPORTED_CATEGORIES, supportedLangs: SUPPORTED_LANGS, sanitizeBlacklist, }; } function normalizeProvider(value) { if (!value) return DEFAULTS.provider; const normalized = String(value).trim().toLowerCase(); if (normalized !== 'jokeapi' && normalized !== 'official') { throw new Error(`Unsupported JOKE_API provider: ${value}`); } return normalized; } function parsePositiveInt(value, fallback, field) { if (value === undefined || value === null || value === '') return fallback; const parsed = Number.parseInt(value, 10); if (!Number.isFinite(parsed) || parsed <= 0) { throw new Error(`${field} must be a positive integer`); } return parsed; } function parseNonNegativeInt(value, fallback, field) { if (value === undefined || value === null || value === '') return fallback; const parsed = Number.parseInt(value, 10); if (!Number.isFinite(parsed) || parsed < 0) { throw new Error(`${field} must be a non-negative integer`); } return parsed; } function parseBoolean(value, fallback) { if (value === undefined || value === null || value === '') return fallback; const normalized = String(value).trim().toLowerCase(); if (normalized === 'true' || normalized === '1') return true; if (normalized === 'false' || normalized === '0') return false; throw new Error(`Invalid boolean value: ${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/ericqian77/joke-mcp'

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