Skip to main content
Glama
utils.ts1.04 kB
import { MATCHING_ALGORITHM_OPTIONS, MatchingAlgorithm } from "./types"; export const headersToObject = (headers: any): Record<string, string> => { if (!headers) return {}; if (typeof headers.forEach === "function") { const obj: Record<string, string> = {}; headers.forEach((value: string, key: string) => { obj[key] = value; }); return obj; } return headers; }; export interface NamedItem { id: number; name: string; } export function enhanceMatchingAlgorithm< T extends { matching_algorithm: MatchingAlgorithm } >(obj: T): T & { matching_algorithm: NamedItem } { return { ...obj, matching_algorithm: { id: obj.matching_algorithm, name: MATCHING_ALGORITHM_OPTIONS[obj.matching_algorithm] || String(obj.matching_algorithm), }, }; } export function enhanceMatchingAlgorithmArray< T extends { matching_algorithm: MatchingAlgorithm } >(objects: T[]): (T & { matching_algorithm: NamedItem })[] { return objects.map((obj) => enhanceMatchingAlgorithm(obj)); }

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/baruchiro/paperless-mcp'

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