free-api-mcp-server 0.2.5 → 0.2.6

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "free-api-mcp-server",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "mcpName": "io.github.aiconvg/free-api-mcp",
5
5
  "type": "module",
6
6
  "description": "MCP server exposing the free TTS/ASR/OCR open API (voices, tts, asr, ocr, account, dubbing, video) over stdio and Streamable HTTP",
package/server.json CHANGED
@@ -2,12 +2,12 @@
2
2
  "$schema": "https://static.modelcontextprotocol.io/schemas/2025-09-29/server.schema.json",
3
3
  "name": "io.github.aiconvg/free-api-mcp",
4
4
  "description": "Free API MCP server: text-to-speech, speech-to-text, ASR jobs, OCR, multi-voice dubbing and video transcription over the free open API. Per-user Bearer token; standard engine free.",
5
- "version": "0.2.5",
5
+ "version": "0.2.6",
6
6
  "packages": [
7
7
  {
8
8
  "registryType": "npm",
9
9
  "identifier": "free-api-mcp-server",
10
- "version": "0.2.5",
10
+ "version": "0.2.6",
11
11
  "transport": {
12
12
  "type": "stdio"
13
13
  }
package/src/lib/errors.js CHANGED
@@ -36,6 +36,19 @@ export function invalidParamHint(toolName) {
36
36
 
37
37
  export function errorToMcpContent(err, { toolName } = {}) {
38
38
  if (err instanceof UpstreamError) {
39
+ // 502/503(网关/上游繁忙,或上游返回空体被解析成 INTERNAL_ERROR):统一「服务繁忙,请稍后重试」,
40
+ // retryAfter 按上游给的透出。避免把裸 502/503 当 INTERNAL_ERROR 直出、客户端不知怎么办。
41
+ const isBusy = err.httpStatus === 502 || err.httpStatus === 503
42
+ || err.code === 'UPSTREAM_UNAVAILABLE' || err.code === 'UPSTREAM_OVERLOAD';
43
+ if (isBusy) {
44
+ const code = (err.code === 'UPSTREAM_UNAVAILABLE' || err.code === 'UPSTREAM_OVERLOAD')
45
+ ? err.code
46
+ : (err.httpStatus === 502 ? 'UPSTREAM_OVERLOAD' : 'UPSTREAM_UNAVAILABLE');
47
+ const lines = [`[${code}] 服务繁忙,请稍后重试` + (err.retryAfter != null ? `(retryAfter ${err.retryAfter} 秒)` : '')];
48
+ if (err.retryAfter != null) lines.push(`retryAfter: ${err.retryAfter}s`);
49
+ if (err.requestId) lines.push(`requestId: ${err.requestId}`);
50
+ return { isError: true, content: [{ type: 'text', text: lines.join('\n') }] };
51
+ }
39
52
  const hint = err.code === 'INVALID_PARAM' ? invalidParamHint(toolName) : (HINTS[err.code] || '');
40
53
  const lines = [`[${err.code}] ${err.message}`, '', hint].filter(Boolean);
41
54
  if (err.retryAfter != null) lines.push(`retryAfter: ${err.retryAfter}s`);