apimodels-mcp 0.2.1 → 0.2.2
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/dist/index.js +14 -6
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -21,16 +21,24 @@ const API_KEY = process.env.APIMODELS_API_KEY;
|
|
|
21
21
|
const BASE_URL = (process.env.APIMODELS_BASE_URL || 'https://api.apimodels.app/v1').replace(/\/$/, '');
|
|
22
22
|
const POLL_TIMEOUT_MS = Number(process.env.APIMODELS_TIMEOUT_MS) || 300_000;
|
|
23
23
|
const POLL_INTERVAL_MS = 3_000;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
// Do NOT exit when the key is missing: directory scanners and MCP inspectors start
|
|
25
|
+
// the server without credentials just to read the tool list. The key is checked
|
|
26
|
+
// when a tool actually needs the API (requireKey below).
|
|
27
|
+
const NO_KEY_MSG = 'APIMODELS_API_KEY is not set. Get a key at https://apimodels.app/console/api-keys and add it to this server\'s environment.';
|
|
28
|
+
if (!API_KEY)
|
|
29
|
+
console.error(`[apimodels-mcp] warning: ${NO_KEY_MSG}`);
|
|
30
|
+
function requireKey() {
|
|
31
|
+
if (!API_KEY)
|
|
32
|
+
throw new Error(NO_KEY_MSG);
|
|
33
|
+
return API_KEY;
|
|
27
34
|
}
|
|
28
35
|
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
29
36
|
async function apiFetch(path, init) {
|
|
37
|
+
const key = requireKey();
|
|
30
38
|
const res = await fetch(`${BASE_URL}${path}`, {
|
|
31
39
|
...init,
|
|
32
40
|
headers: {
|
|
33
|
-
Authorization: `Bearer ${
|
|
41
|
+
Authorization: `Bearer ${key}`,
|
|
34
42
|
'Content-Type': 'application/json',
|
|
35
43
|
...(init?.headers || {}),
|
|
36
44
|
},
|
|
@@ -118,7 +126,7 @@ async function uploadBytes(buf, filename, contentType) {
|
|
|
118
126
|
// No Content-Type header here on purpose — fetch must set the multipart boundary.
|
|
119
127
|
const res = await fetch(`${BASE_URL}/files`, {
|
|
120
128
|
method: 'POST',
|
|
121
|
-
headers: { Authorization: `Bearer ${
|
|
129
|
+
headers: { Authorization: `Bearer ${requireKey()}` },
|
|
122
130
|
body: form,
|
|
123
131
|
});
|
|
124
132
|
const json = await res.json().catch(() => ({}));
|
|
@@ -201,7 +209,7 @@ const REVIEW_SYSTEM = [
|
|
|
201
209
|
].join('\n');
|
|
202
210
|
const text = (s) => ({ content: [{ type: 'text', text: s }] });
|
|
203
211
|
const fail = (e) => ({ content: [{ type: 'text', text: `Error: ${e instanceof Error ? e.message : String(e)}` }], isError: true });
|
|
204
|
-
const server = new McpServer({ name: 'apimodels-mcp', version: '0.2.
|
|
212
|
+
const server = new McpServer({ name: 'apimodels-mcp', version: '0.2.2' });
|
|
205
213
|
server.tool('list_models', 'List the model ids available on apimodels.app (chat, image, video, audio). Use the returned ids with the other tools. Caveat: a handful of entries are internal names that the generation endpoints reject (e.g. seedance-2-fast, seedance-2, motion-control) — the public alias is the dotted form, e.g. seedance-2.0-fast. If an id comes back "Invalid model", try the dotted variant before giving up.', {}, async () => {
|
|
206
214
|
try {
|
|
207
215
|
const res = await apiFetch('/models');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "apimodels-mcp",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "MCP server for apimodels.app — call image, video, LLM chat and text-to-speech models with one API key, from Claude Desktop, Cursor and any MCP client.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|