free-api-mcp-server 0.2.8 → 0.2.9

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/README.md CHANGED
@@ -30,6 +30,8 @@
30
30
  | 13 | `get_video_transcribe` | 付费·视频 | 否 | 轮询视频转写(返回 text / markdown 分段 / 字数 / 实扣积分) |
31
31
 
32
32
  > 「免费」= 标准引擎、按每日免费额度计量、不扣积分;「付费」= 按积分计费(配音按字、视频按字数)。查询/轮询类工具不计费。
33
+ >
34
+ > **ASR 准度说明**:标准引擎 ASR 为 SenseVoice-Small(**自语言识别 auto**,不强制/不区分语种),对**技术术语、中英混识**及短句/数字有准度上限,这是**免费档的设计取舍(非 bug)**;需要更高识别精度的场景请改用 premium 引擎。
33
35
 
34
36
  ## 鉴权与配置
35
37
 
@@ -122,6 +124,17 @@ FREE_API_TOKEN=<你的令牌> FREE_API_BASE_URL=https://www.open-api.aiconvg.xin
122
124
  - `UPSTREAM_OVERLOAD`:上游过载(502/503 繁忙)→ 返回 `[UPSTREAM_OVERLOAD] 服务繁忙,请稍后重试(retryAfter N 秒)`,按 `retryAfter` 稍后重试。
123
125
  - `UPSTREAM_UNAVAILABLE`:上游网络不可达/暂不可用,稍后重试。
124
126
 
127
+ ## 最近变更
128
+
129
+ ### 0.2.9(2026-11-26)
130
+ - **发布修正(0.2.9)**:npm 上此前的 `0.2.8` 实为旧内容(`c04c9ad`,仅 account/voices/tts/server 等部分工具带 `outputSchema`)。本 `0.2.9` 打包 HEAD 全量修复重发——**13 个工具全部声明 `outputSchema` 并随结果返回 `structuredContent`**,OCR `conf/bbox`+`mode`、`get_account`→`ipHash` 等一并生效。
131
+ - **OCR 字段统一**:`blocks[].conf`(置信度 0–1)/ `blocks[].bbox`(四点坐标 `[[x,y],...]`),与引擎返回一致;旧文档的 `confidence` / `box` 作废。
132
+ - **OCR `mode` 三档生效**:`full` 只回 `fullText`(`blocks` 为空)、`structured` 只回 `blocks`(`fullText` 为空)、`auto` 两者都回;在 BFF `/v1/ocr` 层过滤,REST 与 MCP 一致。
133
+ - **多 content 块取值约定**:只读 `content[0]`(纯 JSON)或 `structuredContent`,**不要**拼接多个 content 块(游客试用时第二块是「剩余次数」提示)。本版起每个工具都随结果返回 `structuredContent`(与 `content[0].text` 同源)。
134
+ - **`get_account` 游客视图**:`personal.ip` 改为 `personal.ipHash`(客户端 IP 的 sha256 前 12 位),不再回传明文或网段。
135
+ - **`outputSchema` 全覆盖**:13 个工具全部声明 `outputSchema`,便于客户端结构化解析与平台审核。
136
+ - **ASR 免费档准度说明**:标准引擎 ASR 为 SenseVoice-Small(**自语言识别 auto**,不强制/不区分语种),对**技术术语、中英混识**及短句/数字有准度上限,这是**免费档的设计取舍(非 bug)**;对精度要求高的场景请改用 premium 引擎。
137
+
125
138
  ## 许可
126
139
 
127
140
  MIT,见 [LICENSE](LICENSE)。
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "free-api-mcp-server",
3
- "version": "0.2.8",
3
+ "version": "0.2.9",
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.8",
5
+ "version": "0.2.9",
6
6
  "packages": [
7
7
  {
8
8
  "registryType": "npm",
9
9
  "identifier": "free-api-mcp-server",
10
- "version": "0.2.8",
10
+ "version": "0.2.9",
11
11
  "transport": {
12
12
  "type": "stdio"
13
13
  }
@@ -1,16 +1,17 @@
1
1
  import { z } from 'zod';
2
+ import { createHash } from 'node:crypto';
2
3
  import { api } from '../lib/apiClient.js';
3
4
  import { getRequestTrial, isGuestMode } from '../context.js';
4
5
  import { GUEST_LIMITS, nextBeijingResetAt } from '../lib/guestGate.js';
5
6
  import { getTrialUsage } from '../lib/trialStore.js';
6
7
  import { getLocalUsage } from '../lib/localCounter.js';
7
8
 
8
- function maskIp(ip) {
9
+ // P2-6:personal.ip 原只掩最后一段(113.88.12.*),仍暴露出口网段/归属地线索。
10
+ // 改为不可逆哈希(sha256 前 12 hex),只用于「同一 IP 复用」自证,不泄露任何网段信息。
11
+ function hashIp(ip) {
9
12
  const s = String(ip || '');
10
13
  if (!s) return null;
11
- const parts = s.split('.');
12
- if (parts.length === 4) return `${parts[0]}.${parts[1]}.${parts[2]}.*`;
13
- return s.replace(/:[^:]+$/, ':*');
14
+ return 'sha256:' + createHash('sha256').update(s).digest('hex').slice(0, 12);
14
15
  }
15
16
 
16
17
  // P0-2:游客/trial 上下文追加「本 IP / 本实例」的个人额度视图(30/15/15,北京 00:00 重置)。
@@ -22,7 +23,7 @@ async function buildPersonalView() {
22
23
  let usage; let scope; let ip = null;
23
24
  if (trial?.active) {
24
25
  usage = await getTrialUsage(trial.ip, GUEST_LIMITS);
25
- scope = 'ip'; ip = maskIp(trial.ip);
26
+ scope = 'ip'; ip = hashIp(trial.ip);
26
27
  } else {
27
28
  usage = getLocalUsage();
28
29
  scope = 'local-instance';
@@ -36,7 +37,7 @@ async function buildPersonalView() {
36
37
  }
37
38
  return {
38
39
  scope,
39
- ...(ip ? { ip } : {}),
40
+ ...(ip ? { ipHash: ip } : {}),
40
41
  resetAt: nextBeijingResetAt(),
41
42
  capabilities,
42
43
  exhausted,
@@ -58,7 +59,7 @@ export const getAccountTool = {
58
59
  requestId: { type: 'string' },
59
60
  app: { type: 'object', additionalProperties: true },
60
61
  quota: { type: 'object', additionalProperties: true },
61
- personal: { type: 'object', additionalProperties: true, description: '游客个人额度视图(仅 guest/trial 返回)' },
62
+ personal: { type: 'object', additionalProperties: true, description: '游客个人额度视图(仅 guest/trial 返回);ipHash=客户端 IP 的 sha256 前 12 位,不回传明文/网段' },
62
63
  },
63
64
  },
64
65
  zodSchema: z.object({}),
@@ -15,6 +15,21 @@ export const asrGetTool = {
15
15
  taskId: { type: 'string', description: 'submit_asr_job 返回的任务 ID' },
16
16
  },
17
17
  },
18
+ outputSchema: {
19
+ type: 'object', additionalProperties: true,
20
+ properties: {
21
+ requestId: { type: 'string' },
22
+ taskId: { type: 'string' },
23
+ status: { type: 'string', enum: ['queued', 'running', 'done', 'failed'] },
24
+ text: { type: 'string', description: 'status=done 时返回' },
25
+ duration: { type: 'number', nullable: true },
26
+ segments_done: { type: 'integer', description: '轮询进度' },
27
+ processed_s: { type: 'number', description: '已处理秒数' },
28
+ segments: { type: 'array', items: { type: 'object', additionalProperties: true } },
29
+ engine: { type: 'string' },
30
+ error: { type: 'string', description: 'status=failed 时返回,额度已自动返还' },
31
+ },
32
+ },
18
33
  zodSchema: z.object({ taskId: z.string().min(1, 'taskId 必填') }),
19
34
  async handler(args) {
20
35
  return api.asrGet(args.taskId);
@@ -16,6 +16,16 @@ export const asrSubmitTool = {
16
16
  lang: { type: 'string', description: '语种,auto 自动判定(默认)' },
17
17
  },
18
18
  },
19
+ outputSchema: {
20
+ type: 'object', additionalProperties: true,
21
+ properties: {
22
+ requestId: { type: 'string' },
23
+ taskId: { type: 'string' },
24
+ status: { type: 'string', enum: ['queued', 'running'] },
25
+ duration: { type: 'number', nullable: true },
26
+ quota: { type: 'object', additionalProperties: true },
27
+ },
28
+ },
19
29
  zodSchema: z.object({
20
30
  audioUrl: z.string().url('audioUrl 必须是 http(s) 公网 URL'),
21
31
  lang: z.string().optional(),
@@ -17,6 +17,21 @@ export const asrSyncTool = {
17
17
  engine: { type: 'string', enum: ['standard', 'premium'], description: '引擎:默认 standard(免费);premium 需付费档,商业模型按积分计费' },
18
18
  },
19
19
  },
20
+ outputSchema: {
21
+ type: 'object', additionalProperties: true,
22
+ properties: {
23
+ requestId: { type: 'string' },
24
+ text: { type: 'string' },
25
+ duration: { type: 'number' },
26
+ segments: {
27
+ type: 'array',
28
+ items: { type: 'object', properties: { start: { type: 'number' }, end: { type: 'number' }, text: { type: 'string' } } },
29
+ },
30
+ engine: { type: 'string' },
31
+ language: { type: 'string', nullable: true },
32
+ quota: { type: 'object', additionalProperties: true },
33
+ },
34
+ },
20
35
  zodSchema: z.object({
21
36
  audioUrl: z.string().url('audioUrl 必须是 http(s) 公网 URL'),
22
37
  lang: z.string().optional(),
@@ -13,6 +13,15 @@ export const dubbingVoicesTool = {
13
13
  '返回每个音色的 id、性别、语言、单价 creditsPerChar(免费音色为 0)。' +
14
14
  '提交配音前先从这里选音色 id;不计费。',
15
15
  inputSchema: { type: 'object', properties: {} },
16
+ outputSchema: {
17
+ type: 'object', additionalProperties: true,
18
+ properties: {
19
+ requestId: { type: 'string' },
20
+ data: {
21
+ description: '上游音色目录(可能是数组或 {voices:[...]} 对象);每项含 id/voice、gender、language、creditsPerChar(免费音色=0)',
22
+ },
23
+ },
24
+ },
16
25
  zodSchema: z.object({}).optional(),
17
26
  async handler() {
18
27
  return api.dubbingVoices();
@@ -46,6 +55,18 @@ export const dubbingSubmitTool = {
46
55
  },
47
56
  },
48
57
  },
58
+ outputSchema: {
59
+ type: 'object', additionalProperties: true,
60
+ properties: {
61
+ requestId: { type: 'string' },
62
+ taskId: { type: 'string', description: '大任务异步(HTTP 202)返回,用 get_dubbing_task 轮询' },
63
+ status: { type: 'string' },
64
+ audioUrl: { type: 'string', description: '小任务同步完成(HTTP 200)时返回' },
65
+ srtUrl: { type: 'string', description: '字幕 SRT(同步完成时返回)' },
66
+ creditCost: { type: 'number', description: '202=预估冻结;200=实扣' },
67
+ message: { type: 'string' },
68
+ },
69
+ },
49
70
  zodSchema: z.object({
50
71
  segments: z.array(z.object({
51
72
  voice: z.string().min(1, 'voice 必填'),
@@ -69,6 +90,20 @@ export const dubbingGetTool = {
69
90
  required: ['taskId'],
70
91
  properties: { taskId: { type: 'string', description: 'dubbing_submit 异步返回的任务 ID' } },
71
92
  },
93
+ outputSchema: {
94
+ type: 'object', additionalProperties: true,
95
+ properties: {
96
+ requestId: { type: 'string' },
97
+ taskId: { type: 'string' },
98
+ status: { type: 'string', enum: ['queued', 'running', 'succeeded', 'partial', 'failed', 'cancelled', 'canceled'] },
99
+ audioUrl: { type: 'string' },
100
+ srtUrl: { type: 'string' },
101
+ chargedCredits: { type: 'number', description: '终态实扣积分' },
102
+ segments: { type: 'array', items: { type: 'object', additionalProperties: true } },
103
+ error: { type: 'string' },
104
+ message: { type: 'string' },
105
+ },
106
+ },
72
107
  zodSchema: z.object({ taskId: z.string().min(1, 'taskId 必填') }),
73
108
  async handler(args) {
74
109
  return api.dubbingGet(args.taskId);
@@ -86,6 +121,13 @@ export const dubbingCancelTool = {
86
121
  required: ['taskId'],
87
122
  properties: { taskId: { type: 'string', description: 'dubbing_submit 异步返回的任务 ID' } },
88
123
  },
124
+ outputSchema: {
125
+ type: 'object', additionalProperties: true,
126
+ properties: {
127
+ requestId: { type: 'string' },
128
+ data: { description: '上游取消结果(含 cancelled/status 等)' },
129
+ },
130
+ },
89
131
  zodSchema: z.object({ taskId: z.string().min(1, 'taskId 必填') }),
90
132
  async handler(args) {
91
133
  return api.dubbingCancel(args.taskId);
package/src/tools/ocr.js CHANGED
@@ -5,15 +5,38 @@ export const ocrTool = {
5
5
  name: 'ocr_image',
6
6
  title: '图片文字识别',
7
7
  description:
8
- '识别单张图片(png/jpg/webp,≤ 8MB)中的文字,返回 fullText 与分块(含置信度/坐标)。' +
8
+ '识别单张图片(png/jpg/webp,≤ 8MB)中的文字,返回 fullText 与分块(含置信度 conf/坐标 bbox)。' +
9
9
  '计费工具(占 1 次当日 OCR 额度,失败不扣)。imageUrl 必须是公网可访问 URL;' +
10
- '本地文件路径无法使用。mode=full 只出全文,structured 出带坐标分块。',
10
+ '本地文件路径无法使用。mode=full 只出全文(blocks 为空),structured 只出带 conf/bbox 的分块(fullText 为空),auto 两者都出。' +
11
+ '结果取值:读 content[0](纯 JSON)或 structuredContent,不要把多个 content 块拼接。',
11
12
  inputSchema: {
12
13
  type: 'object',
13
14
  required: ['imageUrl'],
14
15
  properties: {
15
16
  imageUrl: { type: 'string', description: '图片公网 URL,≤ 8MB' },
16
- mode: { type: 'string', enum: ['auto', 'full', 'structured'], description: '默认 auto' },
17
+ mode: { type: 'string', enum: ['auto', 'full', 'structured'], description: '默认 auto(两者都出);full 只全文;structured 只分块' },
18
+ },
19
+ },
20
+ outputSchema: {
21
+ type: 'object', additionalProperties: true,
22
+ properties: {
23
+ requestId: { type: 'string' },
24
+ fullText: { type: 'string', description: '整图拼接全文;mode=structured 时为空串' },
25
+ blocks: {
26
+ type: 'array',
27
+ description: '分块结果;mode=full 时为空数组。每块含 text/conf/bbox',
28
+ items: {
29
+ type: 'object',
30
+ properties: {
31
+ text: { type: 'string' },
32
+ conf: { type: 'number', description: '置信度 0–1' },
33
+ bbox: { type: 'array', description: '四点坐标 [[x,y],...]', items: { type: 'array', items: { type: 'number' } } },
34
+ },
35
+ },
36
+ },
37
+ engine: { type: 'string' },
38
+ mode: { type: 'string', enum: ['auto', 'full', 'structured'] },
39
+ quota: { type: 'object', additionalProperties: true },
17
40
  },
18
41
  },
19
42
  zodSchema: z.object({
@@ -21,6 +21,16 @@ export const videoSubmitTool = {
21
21
  url: { type: 'string', description: '视频链接(平台分享短链或完整链接,也可传整段分享文案,服务端自动提取)' },
22
22
  },
23
23
  },
24
+ outputSchema: {
25
+ type: 'object', additionalProperties: true,
26
+ properties: {
27
+ requestId: { type: 'string' },
28
+ taskId: { type: 'string' },
29
+ status: { type: 'string' },
30
+ credits: { type: 'number', description: '提交时冻结的预估积分' },
31
+ message: { type: 'string' },
32
+ },
33
+ },
24
34
  zodSchema: z.object({
25
35
  url: z.string().min(8, 'url 必填').max(600, 'url 过长(如为分享文案请只保留链接所在文案 ≤600 字符)'),
26
36
  }),
@@ -41,6 +51,20 @@ export const videoGetTool = {
41
51
  required: ['taskId'],
42
52
  properties: { taskId: { type: 'string', description: 'submit_video_transcribe 返回的任务 ID' } },
43
53
  },
54
+ outputSchema: {
55
+ type: 'object', additionalProperties: true,
56
+ properties: {
57
+ requestId: { type: 'string' },
58
+ taskId: { type: 'string' },
59
+ status: { type: 'string', enum: ['queued', 'downloading', 'transcribing', 'correcting', 'done', 'failed'] },
60
+ text: { type: 'string', description: 'status=done 返回的转写稿' },
61
+ markdown: { type: 'string', description: 'markdown 分段稿' },
62
+ chars: { type: 'integer', description: '字数' },
63
+ credits: { type: 'number', description: '实扣积分' },
64
+ error: { type: 'string', description: 'status=failed 时返回,冻结已全额解冻' },
65
+ message: { type: 'string' },
66
+ },
67
+ },
44
68
  zodSchema: z.object({ taskId: z.string().min(1, 'taskId 必填') }),
45
69
  async handler(args) {
46
70
  return api.videoGet(args.taskId);