apimodels-mcp 0.2.0 → 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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/dist/index.js +14 -6
  3. package/package.json +11 -2
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 apimodels.app
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/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
- if (!API_KEY) {
25
- console.error('[apimodels-mcp] APIMODELS_API_KEY is not set. Get one at https://apimodels.app/console/api-keys');
26
- process.exit(1);
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 ${API_KEY}`,
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 ${API_KEY}` },
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.0' });
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.0",
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",
@@ -9,7 +9,8 @@
9
9
  "apimodels-mcp": "dist/index.js"
10
10
  },
11
11
  "files": [
12
- "dist"
12
+ "dist",
13
+ "LICENSE"
13
14
  ],
14
15
  "keywords": [
15
16
  "mcp",
@@ -37,6 +38,14 @@
37
38
  "optionalDependencies": {
38
39
  "sharp": "^0.34.0"
39
40
  },
41
+ "repository": {
42
+ "type": "git",
43
+ "url": "git+https://github.com/stimQQ/apimodels-mcp.git"
44
+ },
45
+ "bugs": {
46
+ "url": "https://github.com/stimQQ/apimodels-mcp/issues"
47
+ },
48
+ "mcpName": "io.github.stimQQ/apimodels-mcp",
40
49
  "scripts": {
41
50
  "build": "tsc",
42
51
  "start": "node dist/index.js",