Skip to main content
Glama
mieaa_mirbase_converter_handler.js5.62 kB
function sleep(ms) { return new Promise(resolve => setTimeout(resolve, ms)); } export class MiEAAMirBaseConverterHandler { async run(args) { const { mirnas, from_version, to_version } = args; if (!mirnas?.length) { throw new Error("mirnas must be a non-empty array"); } const url = "https://ccb-compute2.cs.uni-saarland.de/mieaa/api/v1/mirbase_converter/"; const params = new URLSearchParams(); mirnas.forEach(m => params.append("mirnas", m)); params.append("input_type", "mirna"); params.append("mirbase_input_version", from_version); params.append("mirbase_output_version", to_version); let res = null; for (let attempt = 1; attempt <= 3; attempt++) { res = await fetch(url, { method: "POST", headers: { "Content-Type": "application/x-www-form-urlencoded" }, body: params.toString() }); if (res.status !== 429) break; await sleep(1000 * attempt); } if (!res || !res.ok) { const errorText = await res?.text(); throw new Error(`miRBase conversion failed (${res?.status}): ${errorText}`); } const text = await res.text(); // API only returns problematic entries const apiResults = text .trim() .split("\n") .filter(Boolean) .map((line) => { const [input, output] = line.split(/\t+/); return { input, output: output ?? null }; }); // Normalize output for ALL inputs const conversions = mirnas.map(mirna => { const hit = apiResults.find(r => r.input === mirna); if (!hit) { return { input: mirna, output: mirna, status: "unchanged", reason: "miRNA name is identical across miRBase versions" }; } if (hit.output === null) { return { input: mirna, output: null, status: "unmappable", reason: `No unambiguous miRBase mapping from ${from_version} to ${to_version}` }; } return { input: mirna, output: hit.output, status: "converted", reason: `Renamed between miRBase ${from_version} and ${to_version}` }; }); // MCP tool result (clean + spec-correct) return { content: [ { type: "text", text: JSON.stringify({ conversions }) } ], structuredContent: { conversions } }; } } // function sleep(ms: number) { // return new Promise(resolve => setTimeout(resolve, ms)); // } // export class MiEAAMirBaseConverterHandler { // async run(args: { // mirnas: string[]; // from_version: string; // to_version: string; // }) { // const { mirnas, from_version, to_version } = args; // if (!mirnas?.length) { // throw new Error("mirnas must be a non-empty array"); // } // const url = // "https://ccb-compute2.cs.uni-saarland.de/mieaa/api/v1/mirbase_converter/"; // const params = new URLSearchParams(); // mirnas.forEach(m => params.append("mirnas", m)); // params.append("input_type", "mirna"); // params.append("mirbase_input_version", from_version); // params.append("mirbase_output_version", to_version); // let res: any = null; // for (let attempt = 1; attempt <= 3; attempt++) { // res = await fetch(url, { // method: "POST", // headers: { // "Content-Type": "application/x-www-form-urlencoded" // }, // body: params.toString() // }); // if (res.status !== 429) break; // await sleep(1000 * attempt); // } // if (!res || !res.ok) { // const errorText = await res?.text(); // throw new Error( // `miRBase conversion failed (${res?.status}): ${errorText}` // ); // } // const text: string = await res.text(); // // --- API only returns problematic entries --- // const apiResults = text // .trim() // .split("\n") // .filter(Boolean) // .map((line: string) => { // const [input, output] = line.split(/\t+/); // return { input, output: output ?? null }; // }); // // --- Normalize output for ALL inputs --- // const conversions = mirnas.map(mirna => { // const hit = apiResults.find(r => r.input === mirna); // if (!hit) { // return { // input: mirna, // output: mirna, // status: "unchanged", // reason: "miRNA name is identical across miRBase versions" // }; // } // if (hit.output === null) { // return { // input: mirna, // output: null, // status: "unmappable", // reason: // `No unambiguous miRBase mapping from ${from_version} to ${to_version}` // }; // } // return { // input: mirna, // output: hit.output, // status: "converted", // reason: `Renamed between miRBase ${from_version} and ${to_version}` // }; // }); // return { conversions }; // } // } //# sourceMappingURL=mieaa_mirbase_converter_handler.js.map

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/kkShrihari/miEAA3_mcp'

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