UNPKG

allthingsdev-mcp-server

Version:

🚀 Official MCP server for AllThingsDev API marketplace. Discover, search, and integrate 600+ APIs directly through Claude Desktop, Cursor IDE, and other AI assistants. Features real-time API search, pricing comparison, endpoint documentation, and seamles

100 lines • 3.63 kB
// Data decoder for morphed API structure export class DataDecoder { static FIELD_MAP = { dataset: "ZGF0YXNldA", category: "Y2F0ZWdvcnk", items: "aXRlbXM", identifier: "aWRlbnRpZmllcg", label: "bGFiZWw", payload: "cGF5bG9hZA", ref_id: "cmVmX2lk", alias: "YWxpYXM", links: "bGlua3M", _meta: "X21ldGE", _version: "X3ZlcnNpb24", _generated: "X2dlbmVyYXRlZA", _schema: "X3NjaGVtYQ", _ord: "X29yZA" }; static decodeBase64(encoded) { try { return Buffer.from(encoded, 'base64').toString('utf8'); } catch { return encoded; } } static decodeContent(payload) { try { const decoded = this.decodeBase64(payload); return JSON.parse(decoded); } catch { return { sd: '', ld: '', kw: '', ep: [], dc: '', pr: [] }; } } static extractAPIs(morphedData) { const apis = []; try { const datasets = morphedData[this.FIELD_MAP.dataset] || []; for (const section of datasets) { const items = section[this.FIELD_MAP.items] || []; for (const item of items) { const decodedPayload = this.decodeContent(item[this.FIELD_MAP.payload] || ''); const links = item[this.FIELD_MAP.links] || {}; const api = { id: item[this.FIELD_MAP.identifier] || '', title: this.decodeBase64(item[this.FIELD_MAP.label] || ''), content: this.reconstructContent(decodedPayload), apiId: item[this.FIELD_MAP.ref_id] || '', apiName: this.decodeBase64(item[this.FIELD_MAP.alias] || ''), endpointUrl: this.decodeBase64(links.e || ''), documentationUrl: this.decodeBase64(links.d || ''), tutorialUrl: this.decodeBase64(links.t || ''), discussionUrl: this.decodeBase64(links.s || ''), pricingUrl: this.decodeBase64(links.p || '') }; apis.push(api); } } } catch (error) { console.error('Error decoding morphed data:', error); } return apis; } static reconstructContent(payload) { try { let content = ''; if (payload.sd) { content += `shortDescription - ${payload.sd}\n\n`; } if (payload.ld) { content += `longDescription - ${payload.ld}\n\n`; } if (payload.kw) { content += `keyword - ${payload.kw}\n\n`; } if (payload.ep && payload.ep.length > 0) { content += 'Endpoints -\n'; payload.ep.forEach((ep) => { content += `name - ${ep.n}\nmethod - ${ep.m}\npathURL - ${ep.p}\n\n`; }); } if (payload.dc) { content += `Documentation -\n${payload.dc}\n\n`; } if (payload.pr && payload.pr.length > 0) { content += 'Pricing Plans -\n'; payload.pr.forEach((pr) => { content += `name - ${pr.n}\nrateLimit - ${pr.r}\nprice - ${pr.p}\n\n`; }); } return content.trim(); } catch { return ''; } } } //# sourceMappingURL=data-decoder.js.map