Skip to main content
Glama
api_utils.ts870 B
// accepting null | undefined just to allow other parts of the codebase flexibility // throwing if we ever hit that :( export type URLPattern = Array< string | Record<string, string | undefined | null> >; export const describePattern = (pattern: URLPattern): [string, string] => { const _url: string[] = []; const _urlName: string[] = []; pattern.forEach((p) => { if (typeof p === "string") { _url.push(p); _urlName.push(p); } else { const vals = Object.values(p); if (!vals[0]) throw Error( `Bad URLPattern ${JSON.stringify(pattern)} with: ${JSON.stringify(p)} `, ); else _url.push(vals[0]); // url gets the value const keys = Object.keys(p); if (keys.length > 0) _urlName.push(`:${keys[0]}`); // name gets the str } }); return [_url.join("/"), _urlName.join("/")]; };

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/systeminit/si'

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