straitly-mcp 0.0.0-stage → 0.2.0

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 (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +51 -2
  3. package/index.js +433 -0
  4. package/package.json +38 -4
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Straitly
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,52 @@
1
- # Temporary Holding Version
1
+ # Straitly MCP Server
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ [![Straitly MCP server](https://glama.ai/mcp/servers/Straitly-ai/straitly-mcp/badges/score.svg)](https://glama.ai/mcp/servers/Straitly-ai/straitly-mcp)
4
+
5
+ Official Model Context Protocol (MCP) server for [Straitly](https://straitly.ai): one OpenAI-compatible API gateway for 100+ models (Claude, GPT, Gemini, Grok, DeepSeek, Kimi, Qwen).
6
+
7
+ ## Tools
8
+
9
+ - `list_models`: Search Straitly's live catalog of 100+ models by lab, name, or ID with context window and per-million-token pricing.
10
+ - `get_model`: Fetch live metadata, pricing, and documentation URL for a specific model.
11
+ - `model_prices`: The maker's list price and the Straitly price per 1M tokens for one or more models, read live from the [Straitly catalog](https://straitly.ai/api/catalog). Some models show only the maker price and a link to their Straitly page.
12
+ - `compare_models`: Compare 2 to 5 models side by side: live prices, benchmark rows from Straitly's LLM value index when it is published, and links to Straitly's [head-to-head comparison pages](https://straitly.ai/compare).
13
+ - `chat_completion`: Run a completion against any model on `https://api.straitly.ai/v1` using your `STRAITLY_API_KEY`.
14
+
15
+ Example questions an agent can answer with no key: "What does Claude Opus cost per million tokens from the maker and on Straitly?", "Compare GPT Astra and Claude Opus."
16
+
17
+ ## Setup (Claude Desktop, Cursor, Claude Code)
18
+
19
+ ```json
20
+ {
21
+ "mcpServers": {
22
+ "straitly": {
23
+ "command": "npx",
24
+ "args": ["-y", "straitly-mcp"],
25
+ "env": {
26
+ "STRAITLY_API_KEY": "sk-..."
27
+ }
28
+ }
29
+ }
30
+ }
31
+ ```
32
+
33
+ Claude Code: `claude mcp add straitly -e STRAITLY_API_KEY=sk-... -- npx -y straitly-mcp`
34
+
35
+ Docker: `docker build -t straitly-mcp . && docker run -i --rm -e STRAITLY_API_KEY straitly-mcp`
36
+
37
+ `list_models`, `get_model`, `model_prices` and `compare_models` work with no API key. `chat_completion` requires `STRAITLY_API_KEY` from [straitly.ai](https://straitly.ai).
38
+
39
+ ## Development
40
+
41
+ `npm test` runs the server against a local mock of straitly.ai (Node 18+, no dependencies).
42
+
43
+ ## Links
44
+
45
+ - Website: https://straitly.ai
46
+ - Quickstart: https://straitly.ai/docs/quickstart
47
+ - Models: https://straitly.ai/models
48
+ - SDKs: https://github.com/Straitly-ai/straitly
49
+
50
+ ## License
51
+
52
+ MIT. See [LICENSE](LICENSE).
package/index.js ADDED
@@ -0,0 +1,433 @@
1
+ #!/usr/bin/env node
2
+ // Straitly MCP server (stdio JSON-RPC 2.0, zero external dependencies).
3
+ // Exposes live model catalog lookup, maker vs Straitly prices, model comparison, and chat completions
4
+ // via https://api.straitly.ai/v1.
5
+
6
+ import readline from "node:readline";
7
+
8
+ process.stdout.on("error", (err) => {
9
+ if (err && err.code === "EPIPE") process.exit(0);
10
+ throw err;
11
+ });
12
+
13
+ const VERSION = "0.2.0";
14
+ const BASE_URL = process.env.STRAITLY_BASE_URL || "https://api.straitly.ai/v1";
15
+ const SITE_URL = (process.env.STRAITLY_SITE_URL || "https://straitly.ai").replace(/\/+$/, "");
16
+ const CATALOG_URL = `${SITE_URL}/api/catalog`;
17
+ const VALUE_INDEX_URL = `${SITE_URL}/llm-value-index.json`;
18
+ const SITEMAP_URL = `${SITE_URL}/sitemap.xml`;
19
+ // Public links in tool output always point at the real site, even when tests read a local mock.
20
+ const PUBLIC_SITE = "https://straitly.ai";
21
+ const SERVER_INFO = { name: "straitly-mcp", version: VERSION };
22
+ const PROTOCOL_VERSION = "2024-11-05";
23
+ const UA = { "User-Agent": `straitly-mcp/${VERSION}` };
24
+
25
+ // Models whose Straitly rate is not published anywhere (mirrors straitly.ai's held list). For these the
26
+ // tools return the maker's price and a link to the model page, never a Straitly figure.
27
+ const HELD_IDS = new Set(["gemini-4-neon"]);
28
+
29
+ const slugOf = (id) => String(id || "").slice(String(id || "").lastIndexOf("/") + 1).toLowerCase();
30
+ const isHeld = (m) => HELD_IDS.has(slugOf(m?.id)) || HELD_IDS.has(slugOf(m?.key));
31
+ const modelUrl = (m) => `${PUBLIC_SITE}/models/${m.id}`;
32
+
33
+ const TOOLS = [
34
+ {
35
+ name: "list_models",
36
+ description: "Search Straitly's live catalog of 100+ LLM models by name, lab, or ID. Returns context length and per-million-token pricing.",
37
+ inputSchema: {
38
+ type: "object",
39
+ properties: {
40
+ query: { type: "string", description: "Optional filter matched against model ID, name, or lab (e.g. claude, gpt, gemini, deepseek)." },
41
+ limit: { type: "integer", description: "Max models to return (default 20, max 100).", minimum: 1, maximum: 100 },
42
+ },
43
+ },
44
+ },
45
+ {
46
+ name: "get_model",
47
+ description: "Get full live metadata, pricing, and links for one Straitly model ID or slug.",
48
+ inputSchema: {
49
+ type: "object",
50
+ properties: {
51
+ model: { type: "string", description: "Model ID or slug (e.g. anthropic/claude-sonnet-5-5 or claude-sonnet-5-5)." },
52
+ },
53
+ required: ["model"],
54
+ },
55
+ },
56
+ {
57
+ name: "model_prices",
58
+ description: "Free, no API key. Maker list price and Straitly price per 1M tokens for one or more models, read live from the Straitly catalog. Some models show only the maker price plus a link to their Straitly page.",
59
+ inputSchema: {
60
+ type: "object",
61
+ properties: {
62
+ models: {
63
+ type: "array",
64
+ items: { type: "string" },
65
+ description: "Model IDs, slugs, or names (e.g. claude-opus-5-5, gpt-6-astra, deepseek). Each entry may match several models.",
66
+ maxItems: 20,
67
+ },
68
+ query: { type: "string", description: "Alternative to models: filter by ID, name, or lab (e.g. anthropic, gemini)." },
69
+ limit: { type: "integer", description: "Max rows to return (default 20, max 100).", minimum: 1, maximum: 100 },
70
+ },
71
+ },
72
+ },
73
+ {
74
+ name: "compare_models",
75
+ description: "Free, no API key. Compare 2 to 5 models side by side: live maker and Straitly prices, benchmark rows from Straitly's LLM value index when published, and links to Straitly's head-to-head comparison pages.",
76
+ inputSchema: {
77
+ type: "object",
78
+ properties: {
79
+ models: {
80
+ type: "array",
81
+ items: { type: "string" },
82
+ minItems: 2,
83
+ maxItems: 5,
84
+ description: "Model IDs or slugs to compare (e.g. [\"claude-opus-5-5\", \"gpt-6-astra\"]).",
85
+ },
86
+ },
87
+ required: ["models"],
88
+ },
89
+ },
90
+ {
91
+ name: "chat_completion",
92
+ description: "Run a chat completion through Straitly (requires STRAITLY_API_KEY env var).",
93
+ inputSchema: {
94
+ type: "object",
95
+ properties: {
96
+ model: { type: "string", description: "Straitly model key (e.g. deepseek/deepseek-v4-1-flash)." },
97
+ prompt: { type: "string", description: "User prompt." },
98
+ system: { type: "string", description: "Optional system prompt." },
99
+ max_tokens: { type: "integer", description: "Optional max output tokens." },
100
+ },
101
+ required: ["model", "prompt"],
102
+ },
103
+ },
104
+ ];
105
+
106
+ async function fetchCatalog() {
107
+ const res = await fetch(CATALOG_URL, { headers: UA });
108
+ if (!res.ok) throw new Error(`Catalog HTTP ${res.status}`);
109
+ const data = await res.json();
110
+ const models = Array.isArray(data?.models) ? data.models : [];
111
+ return { models: models.filter((m) => m && m.id), generatedAt: data?.meta?.generatedAt ?? null };
112
+ }
113
+
114
+ const num = (v) => (typeof v === "number" && Number.isFinite(v) ? v : null);
115
+
116
+ // The maker's own list price: the catalog's list field, else its official direct price.
117
+ function makerPrice(m) {
118
+ if (m.list && (num(m.list.input) !== null || num(m.list.output) !== null)) {
119
+ return { input: num(m.list.input), output: num(m.list.output), source: "maker list price (Straitly catalog)" };
120
+ }
121
+ const d = m.direct;
122
+ if (d?.basis === "official" && d.price && (num(d.price.input) !== null || num(d.price.output) !== null)) {
123
+ return {
124
+ input: num(d.price.input),
125
+ output: num(d.price.output),
126
+ cache_read: num(d.price.cacheRead),
127
+ source: `${d.provider || "maker"} official price (Straitly catalog)`,
128
+ };
129
+ }
130
+ return null;
131
+ }
132
+
133
+ function straitlyPrice(m) {
134
+ if (isHeld(m) || !m.price) return null;
135
+ return { input: num(m.price.input), output: num(m.price.output), cache_read: num(m.price.cacheRead) };
136
+ }
137
+
138
+ function formatModel(m) {
139
+ const held = isHeld(m);
140
+ const maker = makerPrice(m);
141
+ return {
142
+ key: m.key,
143
+ id: m.id,
144
+ name: m.name,
145
+ author: m.author?.label || m.author?.slug || null,
146
+ context: m.context ?? null,
147
+ released: m.released ?? null,
148
+ price_per_1m_usd: held ? null : m.price ? { input: num(m.price.input), output: num(m.price.output) } : null,
149
+ list_per_1m_usd: maker ? { input: maker.input, output: maker.output } : null,
150
+ ...(held ? { straitly_price: `See ${modelUrl(m)}` } : {}),
151
+ url: modelUrl(m),
152
+ };
153
+ }
154
+
155
+ function priceRow(m) {
156
+ const held = isHeld(m);
157
+ const maker = makerPrice(m);
158
+ const row = {
159
+ id: m.id,
160
+ key: m.key,
161
+ name: m.name,
162
+ lab: m.author?.label || m.author?.slug || null,
163
+ maker_price_per_1m_usd: maker ? { input: maker.input, output: maker.output, ...(maker.cache_read != null ? { cache_read: maker.cache_read } : {}) } : null,
164
+ maker_price_source: maker ? maker.source : "No maker list price in the Straitly catalog for this model",
165
+ straitly_price_per_1m_usd: straitlyPrice(m),
166
+ url: modelUrl(m),
167
+ };
168
+ if (held) row.straitly_price = `See ${modelUrl(m)}`;
169
+ return row;
170
+ }
171
+
172
+ const lc = (v) => String(v || "").toLowerCase();
173
+
174
+ // Exact ID, key, or slug match first; otherwise a substring match on ID, key, name, or lab.
175
+ function findModels(models, needle) {
176
+ const n = lc(needle).trim();
177
+ if (!n) return [];
178
+ const exact = models.filter((m) => lc(m.id) === n || lc(m.key) === n || slugOf(m.id) === n || slugOf(m.key) === n);
179
+ if (exact.length) return exact;
180
+ return models.filter((m) =>
181
+ [m.key, m.id, m.name, m.author?.label, m.author?.slug].filter(Boolean).some((v) => lc(v).includes(n)));
182
+ }
183
+
184
+ // Family name used in /compare/<a>-vs-<b> slugs: the ID's words without version tokens
185
+ // (claude-opus-5-5 -> claude-opus, gpt-6.2-astra -> gpt-astra, deepseek-v4-1-flash-1017 -> deepseek-flash).
186
+ function familySlug(m) {
187
+ return slugOf(m.id)
188
+ .split("-")
189
+ .filter((t) => t && !/\d/.test(t))
190
+ .join("-");
191
+ }
192
+
193
+ async function fetchText(url) {
194
+ try {
195
+ const res = await fetch(url, { headers: UA });
196
+ return { status: res.status, text: res.ok ? await res.text() : null };
197
+ } catch (err) {
198
+ return { status: 0, text: null, error: err?.message || String(err) };
199
+ }
200
+ }
201
+
202
+ async function comparePages(families) {
203
+ const { text } = await fetchText(SITEMAP_URL);
204
+ if (!text) return [];
205
+ const urls = [...new Set(text.match(/https?:\/\/[^<\s]*\/compare\/[^<\s]+-vs-[^<\s]+/g) || [])];
206
+ const want = new Set(families.filter(Boolean));
207
+ const out = [];
208
+ for (const u of urls) {
209
+ const slug = u.slice(u.lastIndexOf("/compare/") + 9).replace(/\/$/, "");
210
+ const [a, b] = slug.split("-vs-");
211
+ if (a && b && a !== b && want.has(a) && want.has(b)) {
212
+ out.push({ pair: [a, b], url: `${PUBLIC_SITE}/compare/${slug}` });
213
+ }
214
+ }
215
+ return out;
216
+ }
217
+
218
+ // Rows from /llm-value-index.json for the requested models, or null when it is not published.
219
+ async function valueIndexRows(models) {
220
+ const { status, text } = await fetchText(VALUE_INDEX_URL);
221
+ if (!text) return { status, rows: null };
222
+ let data;
223
+ try {
224
+ data = JSON.parse(text);
225
+ } catch {
226
+ return { status, rows: null };
227
+ }
228
+ const list = Array.isArray(data) ? data : data?.models || data?.rows || data?.data || [];
229
+ if (!Array.isArray(list)) return { status, rows: null };
230
+ const rows = [];
231
+ for (const m of models) {
232
+ const ids = new Set([lc(m.id), lc(m.key), slugOf(m.id)]);
233
+ const hit = list.find((r) => r && [r.id, r.key, r.model, r.slug, r.model_id].some((v) => v && (ids.has(lc(v)) || ids.has(slugOf(v)))));
234
+ if (!hit) continue;
235
+ const row = { ...hit };
236
+ // A held model's row keeps only its benchmark facts: anything priced or per-dollar is dropped.
237
+ if (isHeld(m)) {
238
+ for (const k of Object.keys(row)) {
239
+ if (/straitly|price|cost|usd|dollar|value|per_\$|rate/i.test(k)) delete row[k];
240
+ }
241
+ row.straitly_price = `See ${modelUrl(m)}`;
242
+ }
243
+ rows.push(row);
244
+ }
245
+ return { status, rows, meta: Array.isArray(data) ? null : { updated: data?.updated || data?.updatedAt || data?.generatedAt || null, source: data?.source || null } };
246
+ }
247
+
248
+ const json = (obj) => ({ content: [{ type: "text", text: JSON.stringify(obj, null, 2) }] });
249
+
250
+ function clampLimit(v) {
251
+ return Math.min(Math.max(Number(v) || 20, 1), 100);
252
+ }
253
+
254
+ function dedupe(models) {
255
+ const seen = new Set();
256
+ return models.filter((m) => (seen.has(m.id) ? false : (seen.add(m.id), true)));
257
+ }
258
+
259
+ async function handleToolCall(name, args = {}) {
260
+ if (name === "list_models") {
261
+ const { models } = await fetchCatalog();
262
+ const q = String(args.query || "").trim().toLowerCase();
263
+ const limit = clampLimit(args.limit);
264
+ const filtered = q
265
+ ? models.filter((m) =>
266
+ [m.key, m.id, m.name, m.author?.label, m.author?.slug]
267
+ .filter(Boolean)
268
+ .some((v) => String(v).toLowerCase().includes(q)))
269
+ : models;
270
+ return {
271
+ content: [{ type: "text", text: JSON.stringify({ total_matched: filtered.length, models: filtered.slice(0, limit).map(formatModel) }, null, 2) }],
272
+ };
273
+ }
274
+
275
+ if (name === "get_model") {
276
+ const needle = String(args.model || "").trim().toLowerCase();
277
+ const { models } = await fetchCatalog();
278
+ const found = models.find((m) => lc(m.key) === needle || lc(m.id) === needle || slugOf(m.id) === needle);
279
+ if (!found) {
280
+ return { isError: true, content: [{ type: "text", text: `Model not found: ${args.model}. Browse ${PUBLIC_SITE}/models` }] };
281
+ }
282
+ return { content: [{ type: "text", text: JSON.stringify(formatModel(found), null, 2) }] };
283
+ }
284
+
285
+ if (name === "model_prices") {
286
+ const { models, generatedAt } = await fetchCatalog();
287
+ const limit = clampLimit(args.limit);
288
+ const wanted = Array.isArray(args.models) ? args.models.map(String).filter((s) => s.trim()).slice(0, 20) : [];
289
+ let matched;
290
+ const notFound = [];
291
+ if (wanted.length) {
292
+ matched = [];
293
+ for (const w of wanted) {
294
+ const hits = findModels(models, w);
295
+ if (hits.length) matched.push(...hits);
296
+ else notFound.push(w);
297
+ }
298
+ } else if (String(args.query || "").trim()) {
299
+ matched = findModels(models, args.query);
300
+ } else {
301
+ matched = [...models].sort((a, b) => lc(b.released).localeCompare(lc(a.released)));
302
+ }
303
+ matched = dedupe(matched);
304
+ return json({
305
+ source: `${PUBLIC_SITE}/api/catalog`,
306
+ catalog_generated_at: generatedAt,
307
+ unit: "USD per 1M tokens",
308
+ total_matched: matched.length,
309
+ models: matched.slice(0, limit).map(priceRow),
310
+ ...(notFound.length ? { not_found: notFound, browse: `${PUBLIC_SITE}/models` } : {}),
311
+ });
312
+ }
313
+
314
+ if (name === "compare_models") {
315
+ const wanted = Array.isArray(args.models) ? args.models.map(String).filter((s) => s.trim()) : [];
316
+ if (wanted.length < 2 || wanted.length > 5) {
317
+ return { isError: true, content: [{ type: "text", text: "compare_models needs 2 to 5 model IDs in `models`." }] };
318
+ }
319
+ const { models, generatedAt } = await fetchCatalog();
320
+ const resolved = [];
321
+ const notFound = [];
322
+ for (const w of wanted) {
323
+ const hits = findModels(models, w);
324
+ if (!hits.length) {
325
+ notFound.push(w);
326
+ continue;
327
+ }
328
+ // Prefer the newest match when a name is ambiguous ("opus" -> newest Opus).
329
+ resolved.push([...hits].sort((a, b) => lc(b.released).localeCompare(lc(a.released)))[0]);
330
+ }
331
+ const picked = dedupe(resolved);
332
+ if (picked.length < 2) {
333
+ return { isError: true, content: [{ type: "text", text: `Need at least 2 known models. Not found: ${notFound.join(", ") || "(duplicates)"}. Browse ${PUBLIC_SITE}/models` }] };
334
+ }
335
+ const [vi, pages] = await Promise.all([valueIndexRows(picked), comparePages(picked.map(familySlug))]);
336
+ return json({
337
+ prices: {
338
+ source: `${PUBLIC_SITE}/api/catalog`,
339
+ catalog_generated_at: generatedAt,
340
+ unit: "USD per 1M tokens",
341
+ models: picked.map(priceRow),
342
+ },
343
+ benchmarks: vi.rows
344
+ ? { source: `${PUBLIC_SITE}/llm-value-index`, data: `${PUBLIC_SITE}/llm-value-index.json`, ...(vi.meta || {}), rows: vi.rows }
345
+ : { available: false, note: "Benchmark index not published yet; see the comparison pages below." },
346
+ comparison_pages: pages,
347
+ all_comparisons: `${PUBLIC_SITE}/compare`,
348
+ ...(notFound.length ? { not_found: notFound } : {}),
349
+ });
350
+ }
351
+
352
+ if (name === "chat_completion") {
353
+ const apiKey = process.env.STRAITLY_API_KEY;
354
+ if (!apiKey) {
355
+ return { isError: true, content: [{ type: "text", text: `STRAITLY_API_KEY is not set. Create a key at ${PUBLIC_SITE}` }] };
356
+ }
357
+ const messages = [];
358
+ if (args.system) messages.push({ role: "system", content: String(args.system) });
359
+ messages.push({ role: "user", content: String(args.prompt || "") });
360
+ const body = { model: String(args.model), messages };
361
+ if (args.max_tokens) body.max_tokens = Number(args.max_tokens);
362
+ const res = await fetch(`${BASE_URL}/chat/completions`, {
363
+ method: "POST",
364
+ headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
365
+ body: JSON.stringify(body),
366
+ });
367
+ const text = await res.text();
368
+ if (!res.ok) {
369
+ return { isError: true, content: [{ type: "text", text: `Straitly API HTTP ${res.status}: ${text.slice(0, 500)}` }] };
370
+ }
371
+ const json = JSON.parse(text);
372
+ const reply = json?.choices?.[0]?.message?.content ?? text;
373
+ return { content: [{ type: "text", text: String(reply) }] };
374
+ }
375
+
376
+ throw new Error(`Unknown tool: ${name}`);
377
+ }
378
+
379
+ function send(msg) {
380
+ process.stdout.write(`${JSON.stringify(msg)}\n`);
381
+ }
382
+
383
+ async function handleMessage(msg) {
384
+ const { id, method, params } = msg;
385
+ if (method === "notifications/initialized" || id === undefined) return;
386
+ try {
387
+ if (method === "initialize") {
388
+ return send({
389
+ jsonrpc: "2.0",
390
+ id,
391
+ result: { protocolVersion: PROTOCOL_VERSION, capabilities: { tools: {} }, serverInfo: SERVER_INFO },
392
+ });
393
+ }
394
+ if (method === "ping") return send({ jsonrpc: "2.0", id, result: {} });
395
+ if (method === "tools/list") return send({ jsonrpc: "2.0", id, result: { tools: TOOLS } });
396
+ if (method === "tools/call") {
397
+ const result = await handleToolCall(params?.name, params?.arguments);
398
+ return send({ jsonrpc: "2.0", id, result });
399
+ }
400
+ send({ jsonrpc: "2.0", id, error: { code: -32601, message: `Method not found: ${method}` } });
401
+ } catch (err) {
402
+ send({ jsonrpc: "2.0", id, error: { code: -32000, message: err?.message || String(err) } });
403
+ }
404
+ }
405
+
406
+ const rl = readline.createInterface({ input: process.stdin, crlfDelay: Infinity });
407
+ let pending = 0;
408
+ let stdinClosed = false;
409
+
410
+ function maybeExit() {
411
+ if (stdinClosed && pending === 0) process.exit(0);
412
+ }
413
+
414
+ rl.on("line", (line) => {
415
+ if (!line.trim()) return;
416
+ pending += 1;
417
+ let p;
418
+ try {
419
+ p = Promise.resolve(handleMessage(JSON.parse(line)));
420
+ } catch {
421
+ send({ jsonrpc: "2.0", id: null, error: { code: -32700, message: "Parse error" } });
422
+ p = Promise.resolve();
423
+ }
424
+ p.finally(() => {
425
+ pending -= 1;
426
+ maybeExit();
427
+ });
428
+ });
429
+
430
+ rl.on("close", () => {
431
+ stdinClosed = true;
432
+ maybeExit();
433
+ });
package/package.json CHANGED
@@ -1,6 +1,40 @@
1
1
  {
2
2
  "name": "straitly-mcp",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "mcpName": "io.github.Straitly-ai/straitly-mcp",
5
+ "description": "MCP server for Straitly: search 100+ LLM models, compare maker and Straitly prices per model, and run chat completions via one OpenAI-compatible key.",
6
+ "type": "module",
7
+ "bin": {
8
+ "straitly-mcp": "./index.js"
9
+ },
10
+ "main": "./index.js",
11
+ "files": [
12
+ "index.js",
13
+ "README.md",
14
+ "LICENSE"
15
+ ],
16
+ "license": "MIT",
17
+ "homepage": "https://straitly.ai",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "https://github.com/Straitly-ai/straitly-mcp.git"
21
+ },
22
+ "keywords": [
23
+ "mcp",
24
+ "model-context-protocol",
25
+ "straitly",
26
+ "llm",
27
+ "ai-gateway",
28
+ "openai",
29
+ "claude",
30
+ "gemini",
31
+ "llm-pricing",
32
+ "model-comparison"
33
+ ],
34
+ "engines": {
35
+ "node": ">=18"
36
+ },
37
+ "scripts": {
38
+ "test": "node --test test/"
39
+ }
40
+ }