@aggc/or-info 0.2.14 → 0.2.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/mcp/server.mjs +21 -5
  2. package/package.json +1 -1
package/mcp/server.mjs CHANGED
@@ -254,6 +254,22 @@ function errorContent(msg) {
254
254
  return { content: [{ type: 'text', text: `Error: ${msg}` }], isError: true };
255
255
  }
256
256
 
257
+ async function safeGetElo(modelId, opts) {
258
+ try {
259
+ return await getElo(modelId, opts);
260
+ } catch {
261
+ return null;
262
+ }
263
+ }
264
+
265
+ async function safeGetAllElo(opts) {
266
+ try {
267
+ return await getAllElo(opts);
268
+ } catch {
269
+ return {};
270
+ }
271
+ }
272
+
257
273
  async function handleTool(name, args) {
258
274
  // Accept legacy flat names (get_model_info, list_models, ...) by mapping
259
275
  // them to the dot-notation canonical names exposed in tools/list.
@@ -266,7 +282,7 @@ async function handleTool(name, args) {
266
282
  const models = await fetchModels({ apiKey: key });
267
283
  const model = findModel(models, model_id);
268
284
  if (!model) return errorContent(`Model not found: ${model_id}`);
269
- const elo = await getElo(model_id);
285
+ const elo = await safeGetElo(model_id);
270
286
  return result({ ...safeModelSummary(model), lmarena_elo: elo ?? null });
271
287
  }
272
288
 
@@ -291,7 +307,7 @@ async function handleTool(name, args) {
291
307
  if (name === 'benchmarks.get') {
292
308
  const { model_id } = args;
293
309
  if (!model_id || typeof model_id !== 'string') return errorContent('model_id is required');
294
- const elo = await getElo(model_id);
310
+ const elo = await safeGetElo(model_id);
295
311
  return result({ model_id, lmarena_elo: elo ?? null });
296
312
  }
297
313
 
@@ -300,8 +316,8 @@ async function handleTool(name, args) {
300
316
  if (!model_a || !model_b) return errorContent('model_a and model_b are required');
301
317
  const [models, eloA, eloB] = await Promise.all([
302
318
  fetchModels({ apiKey: key }),
303
- getElo(model_a),
304
- getElo(model_b),
319
+ safeGetElo(model_a),
320
+ safeGetElo(model_b),
305
321
  ]);
306
322
  const mA = findModel(models, model_a);
307
323
  const mB = findModel(models, model_b);
@@ -316,7 +332,7 @@ async function handleTool(name, args) {
316
332
  const limit = Math.min(20, Math.max(1, args.limit ?? 5));
317
333
  const maxPrice = args.max_price_per_m_output ?? undefined;
318
334
 
319
- const [models, allElo] = await Promise.all([fetchModels({ apiKey: key }), getAllElo()]);
335
+ const [models, allElo] = await Promise.all([fetchModels({ apiKey: key }), safeGetAllElo()]);
320
336
  const ranked = rankModels(models, allElo, { task, pricing, maxPricePerMOutput: maxPrice, limit });
321
337
  return result({ task, results: ranked.map((r) => ({ ...safeModelSummary(r.model), score: r.score, lmarena_elo: r.eloEntry })) });
322
338
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aggc/or-info",
3
- "version": "0.2.14",
3
+ "version": "0.2.15",
4
4
  "description": "CLI + MCP server for OpenRouter models: prices, benchmarks, context and comparisons",
5
5
  "type": "module",
6
6
  "engines": {