free-api-mcp-server 0.0.0-stage → 0.2.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.
@@ -0,0 +1,26 @@
1
+ import { z } from 'zod';
2
+ import { api } from '../lib/apiClient.js';
3
+
4
+ export const ocrTool = {
5
+ name: 'ocr_image',
6
+ title: '图片文字识别',
7
+ description:
8
+ '识别单张图片(png/jpg/webp,≤ 8MB)中的文字,返回 fullText 与分块(含置信度/坐标)。' +
9
+ '计费工具(占 1 次当日 OCR 额度,失败不扣)。imageUrl 必须是公网可访问 URL;' +
10
+ '本地文件路径无法使用。mode=full 只出全文,structured 出带坐标分块。',
11
+ inputSchema: {
12
+ type: 'object',
13
+ required: ['imageUrl'],
14
+ properties: {
15
+ imageUrl: { type: 'string', description: '图片公网 URL,≤ 8MB' },
16
+ mode: { type: 'string', enum: ['auto', 'full', 'structured'], description: '默认 auto' },
17
+ },
18
+ },
19
+ zodSchema: z.object({
20
+ imageUrl: z.string().url('imageUrl 必须是 http(s) 公网 URL'),
21
+ mode: z.enum(['auto', 'full', 'structured']).optional(),
22
+ }),
23
+ async handler(args) {
24
+ return api.ocr(args);
25
+ },
26
+ };
@@ -0,0 +1,33 @@
1
+ import { z } from 'zod';
2
+ import { api } from '../lib/apiClient.js';
3
+
4
+ export const ttsTool = {
5
+ name: 'text_to_speech',
6
+ title: '文本转语音',
7
+ description:
8
+ '把文本合成为可播放的语音,同步返回 audioUrl(自带 exp/sig 的公网直链,可直接播放,默认 24 小时有效)。' +
9
+ '计费工具(失败不扣)。text ≤ 300 字符(2026-11-09 收敛,付费音色硬限);voice 必须来自 list_voices,不要猜测音色名;' +
10
+ 'format 当前仅支持 wav。engine 可选:默认 standard(免费音色,占日额度,wav 输出);' +
11
+ '"premium"(仅付费档)用商业音色(如 Cherry)按积分计费、不占日额度,音色以充值页商业音色目录为准。',
12
+ inputSchema: {
13
+ type: 'object',
14
+ required: ['text', 'voice'],
15
+ properties: {
16
+ text: { type: 'string', maxLength: 300, description: '待合成文本,≤ 300 字符;超过请分段多次调用' },
17
+ voice: { type: 'string', description: '音色 ID,必须来自 list_voices 的返回(premium 引擎不受此限,可用商业音色)' },
18
+ speed: { type: 'number', minimum: 0.5, maximum: 2.0, description: '语速,0.5–2.0,默认 1.0(仅 standard)' },
19
+ format: { type: 'string', enum: ['wav'], description: '音频格式,当前仅 wav' },
20
+ engine: { type: 'string', enum: ['standard', 'premium'], description: '引擎:默认 standard(免费);premium 需付费档,按积分计费' },
21
+ },
22
+ },
23
+ zodSchema: z.object({
24
+ text: z.string().min(1, 'text 不能为空').max(300, 'text 超过 300 字符上限,请分段多次调用'),
25
+ voice: z.string().min(1, 'voice 必填(用 list_voices 查询)'),
26
+ speed: z.number().min(0.5).max(2.0).optional(),
27
+ format: z.enum(['wav']).optional(),
28
+ engine: z.enum(['standard', 'premium']).optional(),
29
+ }),
30
+ async handler(args) {
31
+ return api.tts(args);
32
+ },
33
+ };
@@ -0,0 +1,48 @@
1
+ import { z } from 'zod';
2
+ import { api } from '../lib/apiClient.js';
3
+
4
+ // ── 视频链接转文字(积分计费 · /v1/video/transcribe,2026-11-06 接入 MCP)──
5
+ // 计费口径:转写稿每 5 字 1 积分;提交后按「时长 × 保守字速」冻结,
6
+ // 按实际字数结算、估少补扣、失败全额解冻(上游 videoBilling 统一执行)。
7
+
8
+ export const videoSubmitTool = {
9
+ name: 'submit_video_transcribe',
10
+ title: '提交视频链接转文字',
11
+ description:
12
+ '把短视频/视频链接转成带时间轴的转写稿。支持抖音(含 v.douyin.com 分享短链、可直接粘整段分享文案)、' +
13
+ 'bilibili/b23.tv、YouTube、快手、小红书、TikTok。立即返回 taskId,用 get_video_transcribe 轮询' +
14
+ '(建议每 10 秒,1~2 分钟短视频通常 1 分钟内完成,不要无限轮询)。' +
15
+ '计费工具:转写稿每 5 字 1 积分,提交时按时长冻结积分(约 2 积分/秒),' +
16
+ '完成按实际字数结算、失败全额解冻;积分不足会在任务中失败并退回冻结。失败不自动重试。',
17
+ inputSchema: {
18
+ type: 'object',
19
+ required: ['url'],
20
+ properties: {
21
+ url: { type: 'string', description: '视频链接(平台分享短链或完整链接,也可传整段分享文案,服务端自动提取)' },
22
+ },
23
+ },
24
+ zodSchema: z.object({
25
+ url: z.string().min(8, 'url 必填').max(600, 'url 过长(如为分享文案请只保留链接所在文案 ≤600 字符)'),
26
+ }),
27
+ async handler(args) {
28
+ return api.videoSubmit(args.url);
29
+ },
30
+ };
31
+
32
+ export const videoGetTool = {
33
+ name: 'get_video_transcribe',
34
+ title: '查询视频转写任务结果',
35
+ description:
36
+ '按 taskId 查询视频转写任务:queued/downloading/transcribing/correcting(进行中)→ ' +
37
+ 'done(返回 text 转写稿、markdown 分段稿、chars 字数、credits 实扣积分)或 failed(error 字段,冻结已全额解冻)。' +
38
+ '不计费、可安全重复轮询。',
39
+ inputSchema: {
40
+ type: 'object',
41
+ required: ['taskId'],
42
+ properties: { taskId: { type: 'string', description: 'submit_video_transcribe 返回的任务 ID' } },
43
+ },
44
+ zodSchema: z.object({ taskId: z.string().min(1, 'taskId 必填') }),
45
+ async handler(args) {
46
+ return api.videoGet(args.taskId);
47
+ },
48
+ };
@@ -0,0 +1,20 @@
1
+ import { z } from 'zod';
2
+ import { api } from '../lib/apiClient.js';
3
+
4
+ export const listVoicesTool = {
5
+ name: 'list_voices',
6
+ title: '列出可用音色',
7
+ description:
8
+ '获取 TTS 可用音色列表(仅免费开源音色,不计额度)。调用 text_to_speech 前必须先从这里拿 voice 参数,' +
9
+ '直接猜测音色名会返回 VOICE_NOT_ALLOWED。',
10
+ inputSchema: {
11
+ type: 'object',
12
+ properties: {
13
+ lang: { type: 'string', description: '按语言筛选,如 zh / en / ja,默认 zh' },
14
+ },
15
+ },
16
+ zodSchema: z.object({ lang: z.string().optional() }),
17
+ async handler(args) {
18
+ return api.listVoices(args?.lang);
19
+ },
20
+ };