straitly-mcp 0.0.0-stage → 0.1.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.
- package/LICENSE +21 -0
- package/README.md +41 -2
- package/index.js +185 -0
- package/package.json +20 -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,42 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Straitly MCP Server
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](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 150+ models (Claude, GPT, Gemini, Grok, DeepSeek, Kimi, Qwen).
|
|
6
|
+
|
|
7
|
+
## Tools
|
|
8
|
+
|
|
9
|
+
- `list_models`: Search Straitly's live catalog of 150+ 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
|
+
- `chat_completion`: Run a completion against any model on `https://api.straitly.ai/v1` using your `STRAITLY_API_KEY`.
|
|
12
|
+
|
|
13
|
+
## Setup (Claude Desktop, Cursor, Claude Code)
|
|
14
|
+
|
|
15
|
+
```json
|
|
16
|
+
{
|
|
17
|
+
"mcpServers": {
|
|
18
|
+
"straitly": {
|
|
19
|
+
"command": "npx",
|
|
20
|
+
"args": ["-y", "straitly-mcp"],
|
|
21
|
+
"env": {
|
|
22
|
+
"STRAITLY_API_KEY": "sk-..."
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Claude Code: `claude mcp add straitly -e STRAITLY_API_KEY=sk-... -- npx -y straitly-mcp`
|
|
30
|
+
|
|
31
|
+
`list_models` and `get_model` work with no API key. `chat_completion` requires `STRAITLY_API_KEY` from [straitly.ai](https://straitly.ai).
|
|
32
|
+
|
|
33
|
+
## Links
|
|
34
|
+
|
|
35
|
+
- Website: https://straitly.ai
|
|
36
|
+
- Quickstart: https://straitly.ai/docs/quickstart
|
|
37
|
+
- Models: https://straitly.ai/models
|
|
38
|
+
- SDKs: https://github.com/Straitly-ai/straitly
|
|
39
|
+
|
|
40
|
+
## License
|
|
41
|
+
|
|
42
|
+
MIT. See [LICENSE](LICENSE).
|
package/index.js
ADDED
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Straitly MCP server (stdio JSON-RPC 2.0, zero external dependencies).
|
|
3
|
+
// Exposes live model catalog lookup, price comparison, and chat completions via https://api.straitly.ai/v1.
|
|
4
|
+
|
|
5
|
+
import readline from "node:readline";
|
|
6
|
+
|
|
7
|
+
process.stdout.on("error", (err) => {
|
|
8
|
+
if (err && err.code === "EPIPE") process.exit(0);
|
|
9
|
+
throw err;
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
const BASE_URL = process.env.STRAITLY_BASE_URL || "https://api.straitly.ai/v1";
|
|
13
|
+
const CATALOG_URL = "https://straitly.ai/api/catalog";
|
|
14
|
+
const SERVER_INFO = { name: "straitly-mcp", version: "0.1.0" };
|
|
15
|
+
const PROTOCOL_VERSION = "2024-11-05";
|
|
16
|
+
|
|
17
|
+
const TOOLS = [
|
|
18
|
+
{
|
|
19
|
+
name: "list_models",
|
|
20
|
+
description: "Search Straitly's live catalog of 150+ LLM models by name, lab, or ID. Returns context length and per-million-token pricing.",
|
|
21
|
+
inputSchema: {
|
|
22
|
+
type: "object",
|
|
23
|
+
properties: {
|
|
24
|
+
query: { type: "string", description: "Optional filter matched against model ID, name, or lab (e.g. claude, gpt, gemini, deepseek)." },
|
|
25
|
+
limit: { type: "integer", description: "Max models to return (default 20, max 100).", minimum: 1, maximum: 100 },
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "get_model",
|
|
31
|
+
description: "Get full live metadata, pricing, and links for one Straitly model ID or slug.",
|
|
32
|
+
inputSchema: {
|
|
33
|
+
type: "object",
|
|
34
|
+
properties: {
|
|
35
|
+
model: { type: "string", description: "Model ID or slug (e.g. anthropic/claude-sonnet-5-5 or claude-sonnet-5-5)." },
|
|
36
|
+
},
|
|
37
|
+
required: ["model"],
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "chat_completion",
|
|
42
|
+
description: "Run a chat completion through Straitly (requires STRAITLY_API_KEY env var).",
|
|
43
|
+
inputSchema: {
|
|
44
|
+
type: "object",
|
|
45
|
+
properties: {
|
|
46
|
+
model: { type: "string", description: "Straitly model key (e.g. deepseek/deepseek-v4-1-flash)." },
|
|
47
|
+
prompt: { type: "string", description: "User prompt." },
|
|
48
|
+
system: { type: "string", description: "Optional system prompt." },
|
|
49
|
+
max_tokens: { type: "integer", description: "Optional max output tokens." },
|
|
50
|
+
},
|
|
51
|
+
required: ["model", "prompt"],
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
];
|
|
55
|
+
|
|
56
|
+
async function fetchCatalog() {
|
|
57
|
+
const res = await fetch(CATALOG_URL, { headers: { "User-Agent": "straitly-mcp/0.1.0" } });
|
|
58
|
+
if (!res.ok) throw new Error(`Catalog HTTP ${res.status}`);
|
|
59
|
+
const data = await res.json();
|
|
60
|
+
const models = Array.isArray(data?.models) ? data.models : [];
|
|
61
|
+
return models.filter((m) => String(m?.id || "") !== "gemini-4-neon" && !String(m?.key || "").includes("gemini-4-neon"));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function formatModel(m) {
|
|
65
|
+
return {
|
|
66
|
+
key: m.key,
|
|
67
|
+
id: m.id,
|
|
68
|
+
name: m.name,
|
|
69
|
+
author: m.author?.label || m.author?.slug || null,
|
|
70
|
+
context: m.context ?? null,
|
|
71
|
+
released: m.released ?? null,
|
|
72
|
+
price_per_1m_usd: m.price ? { input: m.price.input ?? null, output: m.price.output ?? null } : null,
|
|
73
|
+
list_per_1m_usd: m.list ? { input: m.list.input ?? null, output: m.list.output ?? null } : null,
|
|
74
|
+
url: `https://straitly.ai/models/${m.id}`,
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
async function handleToolCall(name, args = {}) {
|
|
79
|
+
if (name === "list_models") {
|
|
80
|
+
const models = await fetchCatalog();
|
|
81
|
+
const q = String(args.query || "").trim().toLowerCase();
|
|
82
|
+
const limit = Math.min(Math.max(Number(args.limit) || 20, 1), 100);
|
|
83
|
+
const filtered = q
|
|
84
|
+
? models.filter((m) =>
|
|
85
|
+
[m.key, m.id, m.name, m.author?.label, m.author?.slug]
|
|
86
|
+
.filter(Boolean)
|
|
87
|
+
.some((v) => String(v).toLowerCase().includes(q)))
|
|
88
|
+
: models;
|
|
89
|
+
return {
|
|
90
|
+
content: [{ type: "text", text: JSON.stringify({ total_matched: filtered.length, models: filtered.slice(0, limit).map(formatModel) }, null, 2) }],
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
if (name === "get_model") {
|
|
95
|
+
const needle = String(args.model || "").trim().toLowerCase();
|
|
96
|
+
const models = await fetchCatalog();
|
|
97
|
+
const found = models.find((m) => String(m.key || "").toLowerCase() === needle || String(m.id || "").toLowerCase() === needle);
|
|
98
|
+
if (!found) {
|
|
99
|
+
return { isError: true, content: [{ type: "text", text: `Model not found: ${args.model}. Browse https://straitly.ai/models` }] };
|
|
100
|
+
}
|
|
101
|
+
return { content: [{ type: "text", text: JSON.stringify(formatModel(found), null, 2) }] };
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
if (name === "chat_completion") {
|
|
105
|
+
const apiKey = process.env.STRAITLY_API_KEY;
|
|
106
|
+
if (!apiKey) {
|
|
107
|
+
return { isError: true, content: [{ type: "text", text: "STRAITLY_API_KEY is not set. Create a key at https://straitly.ai" }] };
|
|
108
|
+
}
|
|
109
|
+
const messages = [];
|
|
110
|
+
if (args.system) messages.push({ role: "system", content: String(args.system) });
|
|
111
|
+
messages.push({ role: "user", content: String(args.prompt || "") });
|
|
112
|
+
const body = { model: String(args.model), messages };
|
|
113
|
+
if (args.max_tokens) body.max_tokens = Number(args.max_tokens);
|
|
114
|
+
const res = await fetch(`${BASE_URL}/chat/completions`, {
|
|
115
|
+
method: "POST",
|
|
116
|
+
headers: { Authorization: `Bearer ${apiKey}`, "Content-Type": "application/json" },
|
|
117
|
+
body: JSON.stringify(body),
|
|
118
|
+
});
|
|
119
|
+
const text = await res.text();
|
|
120
|
+
if (!res.ok) {
|
|
121
|
+
return { isError: true, content: [{ type: "text", text: `Straitly API HTTP ${res.status}: ${text.slice(0, 500)}` }] };
|
|
122
|
+
}
|
|
123
|
+
const json = JSON.parse(text);
|
|
124
|
+
const reply = json?.choices?.[0]?.message?.content ?? text;
|
|
125
|
+
return { content: [{ type: "text", text: String(reply) }] };
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
throw new Error(`Unknown tool: ${name}`);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
function send(msg) {
|
|
132
|
+
process.stdout.write(`${JSON.stringify(msg)}\n`);
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
async function handleMessage(msg) {
|
|
136
|
+
const { id, method, params } = msg;
|
|
137
|
+
if (method === "notifications/initialized" || id === undefined) return;
|
|
138
|
+
try {
|
|
139
|
+
if (method === "initialize") {
|
|
140
|
+
return send({
|
|
141
|
+
jsonrpc: "2.0",
|
|
142
|
+
id,
|
|
143
|
+
result: { protocolVersion: PROTOCOL_VERSION, capabilities: { tools: {} }, serverInfo: SERVER_INFO },
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
if (method === "ping") return send({ jsonrpc: "2.0", id, result: {} });
|
|
147
|
+
if (method === "tools/list") return send({ jsonrpc: "2.0", id, result: { tools: TOOLS } });
|
|
148
|
+
if (method === "tools/call") {
|
|
149
|
+
const result = await handleToolCall(params?.name, params?.arguments);
|
|
150
|
+
return send({ jsonrpc: "2.0", id, result });
|
|
151
|
+
}
|
|
152
|
+
send({ jsonrpc: "2.0", id, error: { code: -32601, message: `Method not found: ${method}` } });
|
|
153
|
+
} catch (err) {
|
|
154
|
+
send({ jsonrpc: "2.0", id, error: { code: -32000, message: err?.message || String(err) } });
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
const rl = readline.createInterface({ input: process.stdin, crlfDelay: Infinity });
|
|
159
|
+
let pending = 0;
|
|
160
|
+
let stdinClosed = false;
|
|
161
|
+
|
|
162
|
+
function maybeExit() {
|
|
163
|
+
if (stdinClosed && pending === 0) process.exit(0);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
rl.on("line", (line) => {
|
|
167
|
+
if (!line.trim()) return;
|
|
168
|
+
pending += 1;
|
|
169
|
+
let p;
|
|
170
|
+
try {
|
|
171
|
+
p = Promise.resolve(handleMessage(JSON.parse(line)));
|
|
172
|
+
} catch {
|
|
173
|
+
send({ jsonrpc: "2.0", id: null, error: { code: -32700, message: "Parse error" } });
|
|
174
|
+
p = Promise.resolve();
|
|
175
|
+
}
|
|
176
|
+
p.finally(() => {
|
|
177
|
+
pending -= 1;
|
|
178
|
+
maybeExit();
|
|
179
|
+
});
|
|
180
|
+
});
|
|
181
|
+
|
|
182
|
+
rl.on("close", () => {
|
|
183
|
+
stdinClosed = true;
|
|
184
|
+
maybeExit();
|
|
185
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "straitly-mcp",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
5
|
-
"description": "
|
|
6
|
-
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"mcpName": "io.github.Straitly-ai/straitly-mcp",
|
|
5
|
+
"description": "MCP server for Straitly: search 150+ LLM models, check live API pricing, 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": ["index.js", "README.md", "LICENSE"],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"homepage": "https://straitly.ai",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "https://github.com/Straitly-ai/straitly-mcp.git"
|
|
17
|
+
},
|
|
18
|
+
"keywords": ["mcp", "model-context-protocol", "straitly", "llm", "ai-gateway", "openai", "claude", "gemini"],
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=18"
|
|
21
|
+
}
|
|
22
|
+
}
|