@quiki/mcp 0.3.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.
- package/README.md +45 -0
- package/dist/apiClient.d.ts +5 -0
- package/dist/apiClient.js +74 -0
- package/dist/errorResponse.d.ts +26 -0
- package/dist/errorResponse.js +57 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +140 -0
- package/dist/tools/bulkImport.d.ts +34 -0
- package/dist/tools/bulkImport.js +44 -0
- package/dist/tools/bulkImportEstimate.d.ts +34 -0
- package/dist/tools/bulkImportEstimate.js +43 -0
- package/dist/tools/getBulkImportStatus.d.ts +19 -0
- package/dist/tools/getBulkImportStatus.js +27 -0
- package/dist/tools/getScan.d.ts +19 -0
- package/dist/tools/getScan.js +19 -0
- package/dist/tools/getVideo.d.ts +19 -0
- package/dist/tools/getVideo.js +24 -0
- package/dist/tools/listRecentVideos.d.ts +22 -0
- package/dist/tools/listRecentVideos.js +34 -0
- package/dist/tools/scanUrl.d.ts +37 -0
- package/dist/tools/scanUrl.js +44 -0
- package/dist/tools/whoami.d.ts +10 -0
- package/dist/tools/whoami.js +16 -0
- package/dist/types.d.ts +154 -0
- package/dist/types.js +3 -0
- package/package.json +40 -0
package/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# @quiki/mcp
|
|
2
|
+
|
|
3
|
+
MCP stdio server for [Quiki.io](https://quiki.io). Exposes the full Quiki toolkit to Claude Desktop / Claude Code / ChatGPT / Gemini / any MCP-capable agent:
|
|
4
|
+
|
|
5
|
+
- `whoami` — verify the token and check subscription tier
|
|
6
|
+
- `scan_url` — submit a TikTok, YouTube, or Instagram URL for scanning
|
|
7
|
+
- `get_scan` — poll a previously submitted scan
|
|
8
|
+
- `list_recent_videos` — list the most recently scanned videos in your library
|
|
9
|
+
- `get_video` — fetch the full record (metadata, transcript, AI analysis) for one video
|
|
10
|
+
- `bulk_import` — import a TikTok, YouTube, or Instagram data export
|
|
11
|
+
- `bulk_import_estimate` — preview the credit cost of a bulk import before committing
|
|
12
|
+
- `get_bulk_import_status` — poll a running bulk import
|
|
13
|
+
|
|
14
|
+
Requires a Quiki API token from a **PRO (credit)** plan or higher. Generate one in your account under **Account > API keys**.
|
|
15
|
+
|
|
16
|
+
## Claude Desktop / Claude Code configuration
|
|
17
|
+
|
|
18
|
+
Add the following to your `mcpServers` config (e.g. `~/Library/Application Support/Claude/claude_desktop_config.json`):
|
|
19
|
+
|
|
20
|
+
```json
|
|
21
|
+
{
|
|
22
|
+
"mcpServers": {
|
|
23
|
+
"quiki": {
|
|
24
|
+
"command": "npx",
|
|
25
|
+
"args": ["-y", "@quiki/mcp"],
|
|
26
|
+
"env": { "QUIKI_API_TOKEN": "qk_live_..." }
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Environment variables
|
|
33
|
+
|
|
34
|
+
| Variable | Default | Description |
|
|
35
|
+
|----------|---------|-------------|
|
|
36
|
+
| `QUIKI_API_TOKEN` | — | **Required.** Raw PAT (`qk_live_...`). |
|
|
37
|
+
| `QUIKI_API_BASE_URL` | `https://api.quiki.io/api/v1` | Override for staging / local dev (e.g. `http://localhost:3000/api/v1`). |
|
|
38
|
+
|
|
39
|
+
## Development
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
npm install # from repo root
|
|
43
|
+
npm run build # from packages/mcp
|
|
44
|
+
npm test # from packages/mcp
|
|
45
|
+
```
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Thin Axios wrapper for the Quiki API. Reads QUIKI_API_TOKEN and
|
|
3
|
+
// QUIKI_API_BASE_URL from env at call time (not import time) so tests can
|
|
4
|
+
// set env vars before invoking tool handlers.
|
|
5
|
+
//
|
|
6
|
+
// Non-2xx responses throw an Error whose message includes the HTTP status
|
|
7
|
+
// and RFC 7807 `detail` field when present, so MCP tool responses surface
|
|
8
|
+
// a readable failure mode to the agent.
|
|
9
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
10
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
exports.getApiClient = getApiClient;
|
|
14
|
+
const axios_1 = __importDefault(require("axios"));
|
|
15
|
+
const DEFAULT_BASE_URL = 'https://api.quiki.io/api/v1';
|
|
16
|
+
function getApiClient() {
|
|
17
|
+
const token = process.env.QUIKI_API_TOKEN;
|
|
18
|
+
if (!token) {
|
|
19
|
+
throw new Error('QUIKI_API_TOKEN is not set. Generate a token in your Quiki account under Account > API keys (requires a PRO credit plan) and export it before starting the MCP server.');
|
|
20
|
+
}
|
|
21
|
+
const baseURL = process.env.QUIKI_API_BASE_URL ?? DEFAULT_BASE_URL;
|
|
22
|
+
const instance = axios_1.default.create({
|
|
23
|
+
baseURL,
|
|
24
|
+
timeout: 120_000,
|
|
25
|
+
headers: {
|
|
26
|
+
Authorization: `Bearer ${token}`,
|
|
27
|
+
'Content-Type': 'application/json',
|
|
28
|
+
Accept: 'application/json',
|
|
29
|
+
},
|
|
30
|
+
// We handle non-2xx manually so we can extract RFC 7807 detail.
|
|
31
|
+
validateStatus: () => true,
|
|
32
|
+
});
|
|
33
|
+
const unwrap = (path, method, status, data) => {
|
|
34
|
+
if (status >= 200 && status < 300) {
|
|
35
|
+
return data;
|
|
36
|
+
}
|
|
37
|
+
const problem = (data ?? {});
|
|
38
|
+
const detail = problem.detail ?? problem.title ?? `HTTP ${status}`;
|
|
39
|
+
const err = new Error(`Quiki API ${method} ${path} failed (${status}): ${detail}`);
|
|
40
|
+
err.status = status;
|
|
41
|
+
err.problem = data;
|
|
42
|
+
throw err;
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
async get(path, params) {
|
|
46
|
+
try {
|
|
47
|
+
const res = await instance.get(path, { params });
|
|
48
|
+
return unwrap(path, 'GET', res.status, res.data);
|
|
49
|
+
}
|
|
50
|
+
catch (e) {
|
|
51
|
+
if (axios_1.default.isAxiosError(e))
|
|
52
|
+
throw wrapAxiosError(e, 'GET', path);
|
|
53
|
+
throw e;
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
async post(path, body, params) {
|
|
57
|
+
try {
|
|
58
|
+
const res = await instance.post(path, body, { params });
|
|
59
|
+
return unwrap(path, 'POST', res.status, res.data);
|
|
60
|
+
}
|
|
61
|
+
catch (e) {
|
|
62
|
+
if (axios_1.default.isAxiosError(e))
|
|
63
|
+
throw wrapAxiosError(e, 'POST', path);
|
|
64
|
+
throw e;
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function wrapAxiosError(e, method, path) {
|
|
70
|
+
const msg = e.code === 'ECONNABORTED'
|
|
71
|
+
? `timed out after ${e.config?.timeout ?? '?'}ms`
|
|
72
|
+
: e.message;
|
|
73
|
+
return new Error(`Quiki API ${method} ${path} network error: ${msg}`);
|
|
74
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface ToolResult {
|
|
2
|
+
isError: boolean;
|
|
3
|
+
content: Array<{
|
|
4
|
+
type: 'text';
|
|
5
|
+
text: string;
|
|
6
|
+
}>;
|
|
7
|
+
[x: string]: unknown;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Convert a thrown Error into an MCP CallToolResult that surfaces the
|
|
11
|
+
* structured RFC 7807 Problem body to the agent. Falls back to the
|
|
12
|
+
* Error message when no `problem` payload is attached (e.g. network
|
|
13
|
+
* errors).
|
|
14
|
+
*
|
|
15
|
+
* When `err.problem` is present:
|
|
16
|
+
* - content[0].text = the human-readable error message (e.g. "Quiki API POST
|
|
17
|
+
* /bulk-imports failed (422): Insufficient credits")
|
|
18
|
+
* - content[1].text = JSON.stringify(err.problem) — the full RFC 7807 body
|
|
19
|
+
* so the agent can extract shortfall/balance/required/code/etc.
|
|
20
|
+
*
|
|
21
|
+
* When `err.problem` is absent (network error, timeout, etc.):
|
|
22
|
+
* - content[0].text = err.message
|
|
23
|
+
*
|
|
24
|
+
* For non-Error throws: content[0].text = String(thrown).
|
|
25
|
+
*/
|
|
26
|
+
export declare function toolErrorResponse(err: unknown): ToolResult;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// toolErrorResponse — converts a thrown value into an MCP CallToolResult
|
|
3
|
+
// that surfaces the RFC 7807 Problem body to the agent when one is present.
|
|
4
|
+
//
|
|
5
|
+
// The Quiki apiClient.unwrap() attaches `.status` and `.problem` properties to
|
|
6
|
+
// every Error it throws for non-2xx responses. Without this helper each
|
|
7
|
+
// registerTool handler would only forward err.message, dropping the structured
|
|
8
|
+
// JSON payload the agent needs to recover (e.g. shortfall/balance/required
|
|
9
|
+
// from 422 INSUFFICIENT_CREDITS).
|
|
10
|
+
//
|
|
11
|
+
// Usage (in index.ts registerTool blocks):
|
|
12
|
+
// } catch (err) {
|
|
13
|
+
// return toolErrorResponse(err);
|
|
14
|
+
// }
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.toolErrorResponse = toolErrorResponse;
|
|
17
|
+
/**
|
|
18
|
+
* Convert a thrown Error into an MCP CallToolResult that surfaces the
|
|
19
|
+
* structured RFC 7807 Problem body to the agent. Falls back to the
|
|
20
|
+
* Error message when no `problem` payload is attached (e.g. network
|
|
21
|
+
* errors).
|
|
22
|
+
*
|
|
23
|
+
* When `err.problem` is present:
|
|
24
|
+
* - content[0].text = the human-readable error message (e.g. "Quiki API POST
|
|
25
|
+
* /bulk-imports failed (422): Insufficient credits")
|
|
26
|
+
* - content[1].text = JSON.stringify(err.problem) — the full RFC 7807 body
|
|
27
|
+
* so the agent can extract shortfall/balance/required/code/etc.
|
|
28
|
+
*
|
|
29
|
+
* When `err.problem` is absent (network error, timeout, etc.):
|
|
30
|
+
* - content[0].text = err.message
|
|
31
|
+
*
|
|
32
|
+
* For non-Error throws: content[0].text = String(thrown).
|
|
33
|
+
*/
|
|
34
|
+
function toolErrorResponse(err) {
|
|
35
|
+
if (err instanceof Error) {
|
|
36
|
+
const e = err;
|
|
37
|
+
if (e.problem !== undefined) {
|
|
38
|
+
// Structured Problem from apiClient.unwrap — give the agent the full
|
|
39
|
+
// body so it can extract shortfall/balance/etc. from the second block.
|
|
40
|
+
return {
|
|
41
|
+
isError: true,
|
|
42
|
+
content: [
|
|
43
|
+
{ type: 'text', text: e.message },
|
|
44
|
+
{ type: 'text', text: JSON.stringify(e.problem, null, 2) },
|
|
45
|
+
],
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
return {
|
|
49
|
+
isError: true,
|
|
50
|
+
content: [{ type: 'text', text: e.message }],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
isError: true,
|
|
55
|
+
content: [{ type: 'text', text: String(err) }],
|
|
56
|
+
};
|
|
57
|
+
}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
// @quiki/mcp stdio entry point. Registers whoami, scan_url, get_scan,
|
|
4
|
+
// list_recent_videos, get_video, bulk_import, bulk_import_estimate, and
|
|
5
|
+
// get_bulk_import_status against an McpServer and connects a
|
|
6
|
+
// StdioServerTransport. Each tool's handler runs through getApiClient() so
|
|
7
|
+
// env vars are read at call time, surfacing token/config errors to the agent
|
|
8
|
+
// rather than crashing the process on startup.
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.buildServer = buildServer;
|
|
11
|
+
exports.main = main;
|
|
12
|
+
const mcp_js_1 = require("@modelcontextprotocol/sdk/server/mcp.js");
|
|
13
|
+
const stdio_js_1 = require("@modelcontextprotocol/sdk/server/stdio.js");
|
|
14
|
+
const apiClient_1 = require("./apiClient");
|
|
15
|
+
const errorResponse_1 = require("./errorResponse");
|
|
16
|
+
const whoami_1 = require("./tools/whoami");
|
|
17
|
+
const scanUrl_1 = require("./tools/scanUrl");
|
|
18
|
+
const getScan_1 = require("./tools/getScan");
|
|
19
|
+
const getVideo_1 = require("./tools/getVideo");
|
|
20
|
+
const listRecentVideos_1 = require("./tools/listRecentVideos");
|
|
21
|
+
const bulkImport_1 = require("./tools/bulkImport");
|
|
22
|
+
const bulkImportEstimate_1 = require("./tools/bulkImportEstimate");
|
|
23
|
+
const getBulkImportStatus_1 = require("./tools/getBulkImportStatus");
|
|
24
|
+
function buildServer() {
|
|
25
|
+
const server = new mcp_js_1.McpServer({
|
|
26
|
+
name: '@quiki/mcp',
|
|
27
|
+
version: '0.3.0',
|
|
28
|
+
});
|
|
29
|
+
server.registerTool(whoami_1.whoamiTool.name, {
|
|
30
|
+
description: whoami_1.whoamiTool.description,
|
|
31
|
+
inputSchema: {},
|
|
32
|
+
}, async () => {
|
|
33
|
+
try {
|
|
34
|
+
const result = await whoami_1.whoamiTool.handler((0, apiClient_1.getApiClient)(), {});
|
|
35
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
36
|
+
}
|
|
37
|
+
catch (err) {
|
|
38
|
+
return (0, errorResponse_1.toolErrorResponse)(err);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
server.registerTool(scanUrl_1.scanUrlTool.name, {
|
|
42
|
+
description: scanUrl_1.scanUrlTool.description,
|
|
43
|
+
inputSchema: scanUrl_1.scanUrlInputShape,
|
|
44
|
+
}, async (args) => {
|
|
45
|
+
try {
|
|
46
|
+
const result = await scanUrl_1.scanUrlTool.handler((0, apiClient_1.getApiClient)(), args);
|
|
47
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
return (0, errorResponse_1.toolErrorResponse)(err);
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
server.registerTool(getScan_1.getScanTool.name, {
|
|
54
|
+
description: getScan_1.getScanTool.description,
|
|
55
|
+
inputSchema: getScan_1.getScanInputShape,
|
|
56
|
+
}, async (args) => {
|
|
57
|
+
try {
|
|
58
|
+
const result = await getScan_1.getScanTool.handler((0, apiClient_1.getApiClient)(), args);
|
|
59
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
60
|
+
}
|
|
61
|
+
catch (err) {
|
|
62
|
+
return (0, errorResponse_1.toolErrorResponse)(err);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
server.registerTool(listRecentVideos_1.listRecentVideosTool.name, {
|
|
66
|
+
description: listRecentVideos_1.listRecentVideosTool.description,
|
|
67
|
+
inputSchema: listRecentVideos_1.listRecentVideosInputShape,
|
|
68
|
+
}, async (args) => {
|
|
69
|
+
try {
|
|
70
|
+
const result = await listRecentVideos_1.listRecentVideosTool.handler((0, apiClient_1.getApiClient)(), args);
|
|
71
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
72
|
+
}
|
|
73
|
+
catch (err) {
|
|
74
|
+
return (0, errorResponse_1.toolErrorResponse)(err);
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
server.registerTool(getVideo_1.getVideoTool.name, {
|
|
78
|
+
description: getVideo_1.getVideoTool.description,
|
|
79
|
+
inputSchema: getVideo_1.getVideoInputShape,
|
|
80
|
+
}, async (args) => {
|
|
81
|
+
try {
|
|
82
|
+
const result = await getVideo_1.getVideoTool.handler((0, apiClient_1.getApiClient)(), args);
|
|
83
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
return (0, errorResponse_1.toolErrorResponse)(err);
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
server.registerTool(bulkImport_1.bulkImportTool.name, {
|
|
90
|
+
description: bulkImport_1.bulkImportTool.description,
|
|
91
|
+
inputSchema: bulkImport_1.bulkImportInputShape,
|
|
92
|
+
}, async (args) => {
|
|
93
|
+
try {
|
|
94
|
+
const result = await bulkImport_1.bulkImportTool.handler((0, apiClient_1.getApiClient)(), args);
|
|
95
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
96
|
+
}
|
|
97
|
+
catch (err) {
|
|
98
|
+
return (0, errorResponse_1.toolErrorResponse)(err);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
server.registerTool(bulkImportEstimate_1.bulkImportEstimateTool.name, {
|
|
102
|
+
description: bulkImportEstimate_1.bulkImportEstimateTool.description,
|
|
103
|
+
inputSchema: bulkImportEstimate_1.bulkImportEstimateInputShape,
|
|
104
|
+
}, async (args) => {
|
|
105
|
+
try {
|
|
106
|
+
const result = await bulkImportEstimate_1.bulkImportEstimateTool.handler((0, apiClient_1.getApiClient)(), args);
|
|
107
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
108
|
+
}
|
|
109
|
+
catch (err) {
|
|
110
|
+
return (0, errorResponse_1.toolErrorResponse)(err);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
server.registerTool(getBulkImportStatus_1.getBulkImportStatusTool.name, {
|
|
114
|
+
description: getBulkImportStatus_1.getBulkImportStatusTool.description,
|
|
115
|
+
inputSchema: getBulkImportStatus_1.getBulkImportStatusInputShape,
|
|
116
|
+
}, async (args) => {
|
|
117
|
+
try {
|
|
118
|
+
const result = await getBulkImportStatus_1.getBulkImportStatusTool.handler((0, apiClient_1.getApiClient)(), args);
|
|
119
|
+
return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }] };
|
|
120
|
+
}
|
|
121
|
+
catch (err) {
|
|
122
|
+
return (0, errorResponse_1.toolErrorResponse)(err);
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
return server;
|
|
126
|
+
}
|
|
127
|
+
async function main() {
|
|
128
|
+
const server = buildServer();
|
|
129
|
+
const transport = new stdio_js_1.StdioServerTransport();
|
|
130
|
+
await server.connect(transport);
|
|
131
|
+
}
|
|
132
|
+
if (require.main === module) {
|
|
133
|
+
main().catch((err) => {
|
|
134
|
+
// Surface startup failures to stderr (stdout is reserved for the MCP
|
|
135
|
+
// transport's JSON-RPC stream).
|
|
136
|
+
// eslint-disable-next-line no-console
|
|
137
|
+
console.error('[@quiki/mcp] fatal:', err);
|
|
138
|
+
process.exit(1);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ApiClient } from '../apiClient';
|
|
3
|
+
import type { BulkImportSubmitResponse } from '../types';
|
|
4
|
+
export declare const bulkImportInputShape: {
|
|
5
|
+
urls: z.ZodArray<z.ZodString>;
|
|
6
|
+
platform: z.ZodOptional<z.ZodEnum<{
|
|
7
|
+
tiktok: "tiktok";
|
|
8
|
+
youtube: "youtube";
|
|
9
|
+
instagram: "instagram";
|
|
10
|
+
}>>;
|
|
11
|
+
};
|
|
12
|
+
declare const InputSchema: z.ZodObject<{
|
|
13
|
+
urls: z.ZodArray<z.ZodString>;
|
|
14
|
+
platform: z.ZodOptional<z.ZodEnum<{
|
|
15
|
+
tiktok: "tiktok";
|
|
16
|
+
youtube: "youtube";
|
|
17
|
+
instagram: "instagram";
|
|
18
|
+
}>>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
type Input = z.infer<typeof InputSchema>;
|
|
21
|
+
export declare const bulkImportTool: {
|
|
22
|
+
name: string;
|
|
23
|
+
description: string;
|
|
24
|
+
inputShape: z.ZodObject<{
|
|
25
|
+
urls: z.ZodArray<z.ZodString>;
|
|
26
|
+
platform: z.ZodOptional<z.ZodEnum<{
|
|
27
|
+
tiktok: "tiktok";
|
|
28
|
+
youtube: "youtube";
|
|
29
|
+
instagram: "instagram";
|
|
30
|
+
}>>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
handler(client: ApiClient, args: Input): Promise<BulkImportSubmitResponse>;
|
|
33
|
+
};
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// bulk_import -- wraps POST /api/v1/bulk-imports. Atomic single-shot
|
|
3
|
+
// submission. Write scope.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.bulkImportTool = exports.bulkImportInputShape = void 0;
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
exports.bulkImportInputShape = {
|
|
8
|
+
urls: zod_1.z
|
|
9
|
+
.array(zod_1.z.string())
|
|
10
|
+
.min(1)
|
|
11
|
+
.max(500)
|
|
12
|
+
.describe('List of video URLs to import. Hard cap of 500 per call. Same platform unless `platform` is supplied.'),
|
|
13
|
+
platform: zod_1.z
|
|
14
|
+
.enum(['tiktok', 'youtube', 'instagram'])
|
|
15
|
+
.optional()
|
|
16
|
+
.describe('Override platform detection. Required if URLs span multiple platforms.'),
|
|
17
|
+
};
|
|
18
|
+
const InputSchema = zod_1.z.object(exports.bulkImportInputShape);
|
|
19
|
+
exports.bulkImportTool = {
|
|
20
|
+
name: 'bulk_import',
|
|
21
|
+
description: [
|
|
22
|
+
'Submits a list of video URLs for bulk scanning. Returns a `bulkImportId` you can pass to `get_bulk_import_status` to poll progress.',
|
|
23
|
+
'',
|
|
24
|
+
'Atomic single-shot: dedup + credit pre-check + start happen in one request. If your balance is too low you will get a 422 INSUFFICIENT_CREDITS error including `shortfall` so you can trim the list and retry. To plan without committing, use `bulk_import_estimate` first.',
|
|
25
|
+
'',
|
|
26
|
+
'Hard cap: 500 URLs per call -- split larger imports into multiple calls. Mixed platforms must pass an explicit `platform`. Re-submitting the same URLs creates a new BulkImport (no idempotency); duplicate URLs already scanned are deduped server-side and do not count toward credit cost.',
|
|
27
|
+
'',
|
|
28
|
+
'Credits are debited per-job at worker completion (not up front). `fileName` is stamped as `API Bulk Import` so the dashboard distinguishes agent imports from file uploads.',
|
|
29
|
+
'',
|
|
30
|
+
'Write scope required.',
|
|
31
|
+
'',
|
|
32
|
+
'When `bulk_import` fails with 422 INSUFFICIENT_CREDITS, the structured error payload is returned as a second content block -- parse it as JSON to extract `shortfall`, `balance`, `required` and trim your list to `balance` URLs (or call `bulk_import_estimate` for a clean dry-run). The numbers are guaranteed to be in the second content block, not in the human-readable first block.',
|
|
33
|
+
].join('\n'),
|
|
34
|
+
inputShape: InputSchema,
|
|
35
|
+
async handler(client, args) {
|
|
36
|
+
const parsed = InputSchema.parse(args);
|
|
37
|
+
const body = {
|
|
38
|
+
urls: parsed.urls,
|
|
39
|
+
};
|
|
40
|
+
if (parsed.platform)
|
|
41
|
+
body.platform = parsed.platform;
|
|
42
|
+
return client.post('/bulk-imports', body);
|
|
43
|
+
},
|
|
44
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ApiClient } from '../apiClient';
|
|
3
|
+
import type { BulkImportEstimateResponse } from '../types';
|
|
4
|
+
export declare const bulkImportEstimateInputShape: {
|
|
5
|
+
urls: z.ZodArray<z.ZodString>;
|
|
6
|
+
platform: z.ZodOptional<z.ZodEnum<{
|
|
7
|
+
tiktok: "tiktok";
|
|
8
|
+
youtube: "youtube";
|
|
9
|
+
instagram: "instagram";
|
|
10
|
+
}>>;
|
|
11
|
+
};
|
|
12
|
+
declare const InputSchema: z.ZodObject<{
|
|
13
|
+
urls: z.ZodArray<z.ZodString>;
|
|
14
|
+
platform: z.ZodOptional<z.ZodEnum<{
|
|
15
|
+
tiktok: "tiktok";
|
|
16
|
+
youtube: "youtube";
|
|
17
|
+
instagram: "instagram";
|
|
18
|
+
}>>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
type Input = z.infer<typeof InputSchema>;
|
|
21
|
+
export declare const bulkImportEstimateTool: {
|
|
22
|
+
name: string;
|
|
23
|
+
description: string;
|
|
24
|
+
inputShape: z.ZodObject<{
|
|
25
|
+
urls: z.ZodArray<z.ZodString>;
|
|
26
|
+
platform: z.ZodOptional<z.ZodEnum<{
|
|
27
|
+
tiktok: "tiktok";
|
|
28
|
+
youtube: "youtube";
|
|
29
|
+
instagram: "instagram";
|
|
30
|
+
}>>;
|
|
31
|
+
}, z.core.$strip>;
|
|
32
|
+
handler(client: ApiClient, args: Input): Promise<BulkImportEstimateResponse>;
|
|
33
|
+
};
|
|
34
|
+
export {};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// bulk_import_estimate — wraps POST /api/v1/bulk-imports/estimate.
|
|
3
|
+
// Stateless dry-run: returns dedup + credit math without starting an
|
|
4
|
+
// import. read scope.
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.bulkImportEstimateTool = exports.bulkImportEstimateInputShape = void 0;
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
exports.bulkImportEstimateInputShape = {
|
|
9
|
+
urls: zod_1.z
|
|
10
|
+
.array(zod_1.z.string())
|
|
11
|
+
.min(1)
|
|
12
|
+
.max(500)
|
|
13
|
+
.describe('List of video URLs to estimate. 1-500 entries. Same platform unless `platform` is supplied.'),
|
|
14
|
+
platform: zod_1.z
|
|
15
|
+
.enum(['tiktok', 'youtube', 'instagram'])
|
|
16
|
+
.optional()
|
|
17
|
+
.describe('Override platform detection. Required if URLs span multiple platforms.'),
|
|
18
|
+
};
|
|
19
|
+
const InputSchema = zod_1.z.object(exports.bulkImportEstimateInputShape);
|
|
20
|
+
exports.bulkImportEstimateTool = {
|
|
21
|
+
name: 'bulk_import_estimate',
|
|
22
|
+
description: [
|
|
23
|
+
'Returns the dedup + credit math for a URL list without starting an import. Use this to plan a bulk submission before committing -- `fits: true` means `bulk_import` would succeed; `fits: false` returns `shortfall: N` so you can trim the list.',
|
|
24
|
+
'',
|
|
25
|
+
'Hard cap: 500 URLs per call. Mixed platforms must pass an explicit `platform`.',
|
|
26
|
+
'',
|
|
27
|
+
'Read scope (read-only token works).',
|
|
28
|
+
'',
|
|
29
|
+
'The two count fields measure different things: `estimatedCost` is what your CURRENT URL list would cost if submitted as-is (always = `newEntryCount x effectiveCostPerVideo`); `scannableCount` is the maximum number of URLs that would fit your CURRENT balance (= `min(newEntryCount, floor(balance / effectiveCostPerVideo))`). When `fits: false`, trim your list to `scannableCount` and resubmit.',
|
|
30
|
+
'',
|
|
31
|
+
'URL validity is NOT checked at estimate time -- `scannableCount` is bounded by your credit balance, not by whether each URL resolves. A 200 estimate does not promise the URLs are real videos.',
|
|
32
|
+
].join('\n'),
|
|
33
|
+
inputShape: InputSchema,
|
|
34
|
+
async handler(client, args) {
|
|
35
|
+
const parsed = InputSchema.parse(args);
|
|
36
|
+
const body = {
|
|
37
|
+
urls: parsed.urls,
|
|
38
|
+
};
|
|
39
|
+
if (parsed.platform)
|
|
40
|
+
body.platform = parsed.platform;
|
|
41
|
+
return client.post('/bulk-imports/estimate', body);
|
|
42
|
+
},
|
|
43
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ApiClient } from '../apiClient';
|
|
3
|
+
import type { BulkImportStatusResponse } from '../types';
|
|
4
|
+
export declare const getBulkImportStatusInputShape: {
|
|
5
|
+
id: z.ZodString;
|
|
6
|
+
};
|
|
7
|
+
declare const InputSchema: z.ZodObject<{
|
|
8
|
+
id: z.ZodString;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
type Input = z.infer<typeof InputSchema>;
|
|
11
|
+
export declare const getBulkImportStatusTool: {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
inputShape: z.ZodObject<{
|
|
15
|
+
id: z.ZodString;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
handler(client: ApiClient, args: Input): Promise<BulkImportStatusResponse>;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// get_bulk_import_status -- wraps GET /api/v1/bulk-imports/:id.
|
|
3
|
+
// Returns the BulkImport row + jobStats. Read scope.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.getBulkImportStatusTool = exports.getBulkImportStatusInputShape = void 0;
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
exports.getBulkImportStatusInputShape = {
|
|
8
|
+
id: zod_1.z.string().min(1).describe('The bulkImportId returned by `bulk_import`.'),
|
|
9
|
+
};
|
|
10
|
+
const InputSchema = zod_1.z.object(exports.getBulkImportStatusInputShape);
|
|
11
|
+
exports.getBulkImportStatusTool = {
|
|
12
|
+
name: 'get_bulk_import_status',
|
|
13
|
+
description: [
|
|
14
|
+
'Returns the current state of a bulk import. Poll this after `bulk_import` until `status` is one of `COMPLETED`, `FAILED`, or `CANCELLED`.',
|
|
15
|
+
'',
|
|
16
|
+
'Suggested cadence: every 5 s for the first 30 s, then every 10 s. The `jobStats` object tells you how many jobs are pending/processing/completed/failed/skipped right now. `skippedAsDuplicate` reports URLs that were dropped because the user already has them in their library -- these never count toward credit cost.',
|
|
17
|
+
'',
|
|
18
|
+
'The `updatedAt` field on the response only ticks when a worker writes to the row -- it does NOT update on polls, on status-reads, or while jobs are queued. Use `jobStats` (specifically the `processing` count and the sum of `pending + processing`) to detect work-in-progress; treat `updatedAt` as a "last meaningful write" timestamp, not a heartbeat.',
|
|
19
|
+
'',
|
|
20
|
+
'Read scope. 404 if the id does not exist or is not owned by the authenticated user.',
|
|
21
|
+
].join('\n'),
|
|
22
|
+
inputShape: InputSchema,
|
|
23
|
+
async handler(client, args) {
|
|
24
|
+
const parsed = InputSchema.parse(args);
|
|
25
|
+
return client.get(`/bulk-imports/${encodeURIComponent(parsed.id)}`);
|
|
26
|
+
},
|
|
27
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ApiClient } from '../apiClient';
|
|
3
|
+
import type { ScanResponse } from '../types';
|
|
4
|
+
export declare const getScanInputShape: {
|
|
5
|
+
id: z.ZodString;
|
|
6
|
+
};
|
|
7
|
+
declare const InputSchema: z.ZodObject<{
|
|
8
|
+
id: z.ZodString;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
type Input = z.infer<typeof InputSchema>;
|
|
11
|
+
export declare const getScanTool: {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
inputShape: z.ZodObject<{
|
|
15
|
+
id: z.ZodString;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
handler(client: ApiClient, args: Input): Promise<ScanResponse>;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// get_scan — wraps GET /api/v1/scans/:id. Description copied verbatim
|
|
3
|
+
// from spec §7.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.getScanTool = exports.getScanInputShape = void 0;
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
exports.getScanInputShape = {
|
|
8
|
+
id: zod_1.z.string().describe('The scan ID returned by scan_url.'),
|
|
9
|
+
};
|
|
10
|
+
const InputSchema = zod_1.z.object(exports.getScanInputShape);
|
|
11
|
+
exports.getScanTool = {
|
|
12
|
+
name: 'get_scan',
|
|
13
|
+
description: 'Retrieves the current status and result of a previously submitted scan. Poll this after `scan_url` returns a scan ID. The scan is done when `status` is `"completed"` or `"failed"`.',
|
|
14
|
+
inputShape: InputSchema,
|
|
15
|
+
async handler(client, args) {
|
|
16
|
+
const parsed = InputSchema.parse(args);
|
|
17
|
+
return client.get(`/scans/${encodeURIComponent(parsed.id)}`);
|
|
18
|
+
},
|
|
19
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ApiClient } from '../apiClient';
|
|
3
|
+
import type { VideoResponse } from '../types';
|
|
4
|
+
export declare const getVideoInputShape: {
|
|
5
|
+
id: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
6
|
+
};
|
|
7
|
+
declare const InputSchema: z.ZodObject<{
|
|
8
|
+
id: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
type Input = z.infer<typeof InputSchema>;
|
|
11
|
+
export declare const getVideoTool: {
|
|
12
|
+
name: string;
|
|
13
|
+
description: string;
|
|
14
|
+
inputShape: z.ZodObject<{
|
|
15
|
+
id: z.ZodUnion<readonly [z.ZodNumber, z.ZodString]>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
handler(client: ApiClient, args: Input): Promise<VideoResponse>;
|
|
18
|
+
};
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// get_video — wraps GET /api/v1/videos/:id. Description copied verbatim from spec §7.
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.getVideoTool = exports.getVideoInputShape = void 0;
|
|
5
|
+
const zod_1 = require("zod");
|
|
6
|
+
exports.getVideoInputShape = {
|
|
7
|
+
id: zod_1.z
|
|
8
|
+
.union([zod_1.z.number().int().positive(), zod_1.z.string().regex(/^\d+$/)])
|
|
9
|
+
.describe('The video ID (integer). Returned by `list_recent_videos` or as `video_id` on a completed `scan_url` response.'),
|
|
10
|
+
};
|
|
11
|
+
const InputSchema = zod_1.z.object(exports.getVideoInputShape);
|
|
12
|
+
exports.getVideoTool = {
|
|
13
|
+
name: 'get_video',
|
|
14
|
+
description: "Fetches the full record for one previously-scanned video: metadata, transcript (for videos), AI analysis (for deep scans), and image URLs (for TikTok photo carousels). The `id` comes from `list_recent_videos` or from the `video_id` field on a completed `scan_url` response. Check `media_type` to branch — for `'photo'`, `transcript` is absent and `images` is present.",
|
|
15
|
+
inputShape: InputSchema,
|
|
16
|
+
async handler(client, args) {
|
|
17
|
+
const parsed = InputSchema.parse(args);
|
|
18
|
+
// Normalise to string for URL construction — encodeURIComponent on a
|
|
19
|
+
// numeric string is a no-op, but String() handles both number and string
|
|
20
|
+
// inputs from the union schema.
|
|
21
|
+
const idStr = String(parsed.id);
|
|
22
|
+
return client.get(`/videos/${encodeURIComponent(idStr)}`);
|
|
23
|
+
},
|
|
24
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ApiClient } from '../apiClient';
|
|
3
|
+
import type { RecentVideosResponse } from '../types';
|
|
4
|
+
export declare const listRecentVideosInputShape: {
|
|
5
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
6
|
+
include_failed: z.ZodOptional<z.ZodBoolean>;
|
|
7
|
+
};
|
|
8
|
+
declare const InputSchema: z.ZodObject<{
|
|
9
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
10
|
+
include_failed: z.ZodOptional<z.ZodBoolean>;
|
|
11
|
+
}, z.core.$strip>;
|
|
12
|
+
type Input = z.infer<typeof InputSchema>;
|
|
13
|
+
export declare const listRecentVideosTool: {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
inputShape: z.ZodObject<{
|
|
17
|
+
limit: z.ZodOptional<z.ZodNumber>;
|
|
18
|
+
include_failed: z.ZodOptional<z.ZodBoolean>;
|
|
19
|
+
}, z.core.$strip>;
|
|
20
|
+
handler(client: ApiClient, args: Input): Promise<RecentVideosResponse>;
|
|
21
|
+
};
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// list_recent_videos — wraps GET /api/v1/videos?recent=N[&include=failed].
|
|
3
|
+
// Description copied verbatim from spec §7.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.listRecentVideosTool = exports.listRecentVideosInputShape = void 0;
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
exports.listRecentVideosInputShape = {
|
|
8
|
+
limit: zod_1.z
|
|
9
|
+
.number()
|
|
10
|
+
.int()
|
|
11
|
+
.min(1)
|
|
12
|
+
.max(100)
|
|
13
|
+
.optional()
|
|
14
|
+
.describe('Max number of videos to return. Default 20, max 100.'),
|
|
15
|
+
include_failed: zod_1.z
|
|
16
|
+
.boolean()
|
|
17
|
+
.optional()
|
|
18
|
+
.describe('When true, include failed scans with status + error fields. Default false.'),
|
|
19
|
+
};
|
|
20
|
+
const InputSchema = zod_1.z.object(exports.listRecentVideosInputShape);
|
|
21
|
+
exports.listRecentVideosTool = {
|
|
22
|
+
name: 'list_recent_videos',
|
|
23
|
+
description: "Lists the most recently scanned videos in the authenticated user's library, newest first (by last scan time). Returns a trimmed shape — title, author, platform, URL, timestamps — without transcripts or AI analysis, so the agent can skim many entries and pick one to dig into. Call `get_video(id)` for the full body. Photo posts (TikTok carousels) are marked with `media_type: 'photo'` and do not have transcripts — they have `images` instead (fetch full via `get_video`).",
|
|
24
|
+
inputShape: InputSchema,
|
|
25
|
+
async handler(client, args) {
|
|
26
|
+
const parsed = InputSchema.parse(args);
|
|
27
|
+
const params = {};
|
|
28
|
+
if (parsed.limit !== undefined)
|
|
29
|
+
params.recent = parsed.limit;
|
|
30
|
+
if (parsed.include_failed)
|
|
31
|
+
params.include = 'failed';
|
|
32
|
+
return client.get('/videos', params);
|
|
33
|
+
},
|
|
34
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ApiClient } from '../apiClient';
|
|
3
|
+
import type { ScanResponse } from '../types';
|
|
4
|
+
export declare const scanUrlInputShape: {
|
|
5
|
+
url: z.ZodString;
|
|
6
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
7
|
+
fast: "fast";
|
|
8
|
+
deep: "deep";
|
|
9
|
+
transcript_only: "transcript_only";
|
|
10
|
+
}>>;
|
|
11
|
+
wait: z.ZodOptional<z.ZodBoolean>;
|
|
12
|
+
};
|
|
13
|
+
declare const InputSchema: z.ZodObject<{
|
|
14
|
+
url: z.ZodString;
|
|
15
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
16
|
+
fast: "fast";
|
|
17
|
+
deep: "deep";
|
|
18
|
+
transcript_only: "transcript_only";
|
|
19
|
+
}>>;
|
|
20
|
+
wait: z.ZodOptional<z.ZodBoolean>;
|
|
21
|
+
}, z.core.$strip>;
|
|
22
|
+
type Input = z.infer<typeof InputSchema>;
|
|
23
|
+
export declare const scanUrlTool: {
|
|
24
|
+
name: string;
|
|
25
|
+
description: string;
|
|
26
|
+
inputShape: z.ZodObject<{
|
|
27
|
+
url: z.ZodString;
|
|
28
|
+
mode: z.ZodOptional<z.ZodEnum<{
|
|
29
|
+
fast: "fast";
|
|
30
|
+
deep: "deep";
|
|
31
|
+
transcript_only: "transcript_only";
|
|
32
|
+
}>>;
|
|
33
|
+
wait: z.ZodOptional<z.ZodBoolean>;
|
|
34
|
+
}, z.core.$strip>;
|
|
35
|
+
handler(client: ApiClient, args: Input): Promise<ScanResponse>;
|
|
36
|
+
};
|
|
37
|
+
export {};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// scan_url — wraps POST /api/v1/scans. Description copied verbatim from
|
|
3
|
+
// spec §7 so the mode-selection guidance reaches the agent.
|
|
4
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
+
exports.scanUrlTool = exports.scanUrlInputShape = void 0;
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const modeSchema = zod_1.z.enum(['fast', 'deep', 'transcript_only']);
|
|
8
|
+
exports.scanUrlInputShape = {
|
|
9
|
+
url: zod_1.z.string().describe('The video URL to scan (TikTok, YouTube, or Instagram).'),
|
|
10
|
+
mode: modeSchema
|
|
11
|
+
.optional()
|
|
12
|
+
.describe('"fast" | "deep" | "transcript_only". Optional; defaults per platform.'),
|
|
13
|
+
wait: zod_1.z
|
|
14
|
+
.boolean()
|
|
15
|
+
.optional()
|
|
16
|
+
.describe('If true, holds the connection up to 90 s and returns the completed result.'),
|
|
17
|
+
};
|
|
18
|
+
const InputSchema = zod_1.z.object(exports.scanUrlInputShape);
|
|
19
|
+
exports.scanUrlTool = {
|
|
20
|
+
name: 'scan_url',
|
|
21
|
+
description: [
|
|
22
|
+
'Submits a TikTok, YouTube, or Instagram URL for scanning. Returns scan metadata immediately (async) or waits up to 90 seconds for the result (sync-ish).',
|
|
23
|
+
'',
|
|
24
|
+
'Choosing `mode`:',
|
|
25
|
+
'- TikTok: omit `mode` for metadata-only (`fast`); pass `"deep"` to get transcript + AI analysis.',
|
|
26
|
+
'- YouTube: omit `mode` for metadata-only (`fast`); pass `"transcript_only"` to get the transcript without AI analysis.',
|
|
27
|
+
'- Instagram: `mode` is always `"deep"` — metadata + transcript + AI analysis. You may omit it; the server applies the default.',
|
|
28
|
+
'- `"deep"` on YouTube is not yet supported and will return an error.',
|
|
29
|
+
'- `"transcript_only"` on TikTok is not supported; use `"deep"` instead.',
|
|
30
|
+
'',
|
|
31
|
+
'Set `wait=true` to hold the connection up to 90 s and receive the completed result in one call. Useful for short videos. For long videos or when latency matters, omit `wait` and poll with `get_scan`.',
|
|
32
|
+
'',
|
|
33
|
+
'When the scan completes (either via `wait=true` or by polling with `get_scan`), the response includes a `video_id` field. You can pass that to `get_video(id)` later to retrieve the same scan from the library without re-scanning.',
|
|
34
|
+
].join('\n'),
|
|
35
|
+
inputShape: InputSchema,
|
|
36
|
+
async handler(client, args) {
|
|
37
|
+
const parsed = InputSchema.parse(args);
|
|
38
|
+
const body = { url: parsed.url };
|
|
39
|
+
if (parsed.mode)
|
|
40
|
+
body.mode = parsed.mode;
|
|
41
|
+
const params = parsed.wait === true ? { wait: 'true' } : undefined;
|
|
42
|
+
return client.post('/scans', body, params);
|
|
43
|
+
},
|
|
44
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import type { ApiClient } from '../apiClient';
|
|
3
|
+
import type { WhoamiResponse } from '../types';
|
|
4
|
+
export declare const whoamiTool: {
|
|
5
|
+
name: string;
|
|
6
|
+
description: string;
|
|
7
|
+
inputSchema: {};
|
|
8
|
+
inputShape: z.ZodObject<{}, z.core.$strip>;
|
|
9
|
+
handler(client: ApiClient, _args: Record<string, never>): Promise<WhoamiResponse>;
|
|
10
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// whoami — wraps GET /api/v1/me. Descriptions are copied verbatim from
|
|
3
|
+
// Milestone A spec §7 so the wording exposed to the agent matches the
|
|
4
|
+
// design.
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.whoamiTool = void 0;
|
|
7
|
+
const zod_1 = require("zod");
|
|
8
|
+
exports.whoamiTool = {
|
|
9
|
+
name: 'whoami',
|
|
10
|
+
description: 'Returns the identity and subscription tier of the authenticated Quiki account. Use this to verify the token is valid and to check whether the account has API scan access (tier must be `pro` or `admin` to use `scan_url`).',
|
|
11
|
+
inputSchema: {},
|
|
12
|
+
inputShape: zod_1.z.object({}),
|
|
13
|
+
async handler(client, _args) {
|
|
14
|
+
return client.get('/me');
|
|
15
|
+
},
|
|
16
|
+
};
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
export type Tier = 'free' | 'play' | 'pro' | 'admin';
|
|
2
|
+
export type Platform = 'tiktok' | 'youtube' | 'instagram';
|
|
3
|
+
export type Mode = 'fast' | 'deep' | 'transcript_only';
|
|
4
|
+
export type ScanStatus = 'queued' | 'running' | 'completed' | 'failed';
|
|
5
|
+
export interface WhoamiResponse {
|
|
6
|
+
id: string;
|
|
7
|
+
email: string;
|
|
8
|
+
tier: Tier;
|
|
9
|
+
}
|
|
10
|
+
export interface ScanMetadata {
|
|
11
|
+
title: string | null;
|
|
12
|
+
author: string | null;
|
|
13
|
+
duration_s: number | null;
|
|
14
|
+
posted_at: string | null;
|
|
15
|
+
thumbnail_url: string | null;
|
|
16
|
+
[k: string]: unknown;
|
|
17
|
+
}
|
|
18
|
+
export interface ScanResult {
|
|
19
|
+
platform: Platform;
|
|
20
|
+
mode: Mode;
|
|
21
|
+
metadata: ScanMetadata;
|
|
22
|
+
transcript: string | null;
|
|
23
|
+
ai_analysis?: Record<string, unknown>;
|
|
24
|
+
scanned_at: string;
|
|
25
|
+
}
|
|
26
|
+
export interface ScanResponse {
|
|
27
|
+
id: string;
|
|
28
|
+
status: ScanStatus;
|
|
29
|
+
platform: Platform;
|
|
30
|
+
mode: Mode;
|
|
31
|
+
created_at: string;
|
|
32
|
+
completed_at?: string;
|
|
33
|
+
video_id?: number;
|
|
34
|
+
result?: ScanResult;
|
|
35
|
+
error?: {
|
|
36
|
+
code: string;
|
|
37
|
+
detail: string;
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
export type MediaType = 'video' | 'photo';
|
|
41
|
+
export type SourceTag = 'ui' | 'api' | 'bulk_import';
|
|
42
|
+
export interface VideoMetadataVideo {
|
|
43
|
+
title: string | null;
|
|
44
|
+
author: string | null;
|
|
45
|
+
duration_s: number | null;
|
|
46
|
+
posted_at: string | null;
|
|
47
|
+
thumbnail_url: string | null;
|
|
48
|
+
[extra: string]: unknown;
|
|
49
|
+
}
|
|
50
|
+
export interface VideoMetadataPhoto {
|
|
51
|
+
title: string | null;
|
|
52
|
+
author: string | null;
|
|
53
|
+
posted_at: string | null;
|
|
54
|
+
[extra: string]: unknown;
|
|
55
|
+
}
|
|
56
|
+
interface VideoCore {
|
|
57
|
+
id: number;
|
|
58
|
+
url: string;
|
|
59
|
+
platform_video_id: string;
|
|
60
|
+
platform: Platform;
|
|
61
|
+
mode: Mode;
|
|
62
|
+
source: SourceTag;
|
|
63
|
+
first_scanned_at: string;
|
|
64
|
+
scanned_at: string;
|
|
65
|
+
}
|
|
66
|
+
export type VideoResponse = (VideoCore & {
|
|
67
|
+
media_type: 'video';
|
|
68
|
+
metadata: VideoMetadataVideo;
|
|
69
|
+
transcript: string | null;
|
|
70
|
+
ai_analysis?: Record<string, unknown>;
|
|
71
|
+
}) | (VideoCore & {
|
|
72
|
+
media_type: 'photo';
|
|
73
|
+
metadata: VideoMetadataPhoto;
|
|
74
|
+
images: string[];
|
|
75
|
+
ai_analysis?: Record<string, unknown>;
|
|
76
|
+
});
|
|
77
|
+
export type VideoSummary = (VideoCore & {
|
|
78
|
+
media_type: 'video';
|
|
79
|
+
metadata: VideoMetadataVideo;
|
|
80
|
+
}) | (VideoCore & {
|
|
81
|
+
media_type: 'photo';
|
|
82
|
+
metadata: VideoMetadataPhoto;
|
|
83
|
+
});
|
|
84
|
+
export type VideoSummaryWithStatus = VideoSummary & {
|
|
85
|
+
status: 'completed' | 'failed';
|
|
86
|
+
error?: {
|
|
87
|
+
code: string;
|
|
88
|
+
detail: string;
|
|
89
|
+
};
|
|
90
|
+
};
|
|
91
|
+
export interface RecentVideosResponse {
|
|
92
|
+
videos: Array<VideoSummary | VideoSummaryWithStatus>;
|
|
93
|
+
}
|
|
94
|
+
export interface BulkImportSubmitResponse {
|
|
95
|
+
bulkImportId: string;
|
|
96
|
+
platform: 'tiktok' | 'youtube' | 'instagram';
|
|
97
|
+
totals: {
|
|
98
|
+
totalEntries: number;
|
|
99
|
+
duplicateCount: number;
|
|
100
|
+
newEntryCount: number;
|
|
101
|
+
};
|
|
102
|
+
scannableCount: number;
|
|
103
|
+
/**
|
|
104
|
+
* The effective per-video cost as a scalar (same as `effectiveCostPerVideo`).
|
|
105
|
+
* Exposed for agent ergonomics; NOT the `{fast, deep}` object from the
|
|
106
|
+
* service layer's `PreCheckResult.costPerVideo`.
|
|
107
|
+
*/
|
|
108
|
+
costPerVideo: number;
|
|
109
|
+
effectiveCostPerVideo: number;
|
|
110
|
+
estimatedCost: number;
|
|
111
|
+
currentBalance: number;
|
|
112
|
+
createdAt: string;
|
|
113
|
+
}
|
|
114
|
+
export interface BulkImportEstimateResponse {
|
|
115
|
+
platform: 'tiktok' | 'youtube' | 'instagram';
|
|
116
|
+
totals: {
|
|
117
|
+
totalEntries: number;
|
|
118
|
+
duplicateCount: number;
|
|
119
|
+
newEntryCount: number;
|
|
120
|
+
};
|
|
121
|
+
scannableCount: number;
|
|
122
|
+
/**
|
|
123
|
+
* The effective per-video cost as a scalar (same as `effectiveCostPerVideo`).
|
|
124
|
+
* Exposed for agent ergonomics; NOT the `{fast, deep}` object from the
|
|
125
|
+
* service layer's `PreCheckResult.costPerVideo`.
|
|
126
|
+
*/
|
|
127
|
+
costPerVideo: number;
|
|
128
|
+
effectiveCostPerVideo: number;
|
|
129
|
+
estimatedCost: number;
|
|
130
|
+
currentBalance: number;
|
|
131
|
+
shortfall: number;
|
|
132
|
+
fits: boolean;
|
|
133
|
+
userTier: string;
|
|
134
|
+
}
|
|
135
|
+
export interface BulkImportStatusResponse {
|
|
136
|
+
id: string;
|
|
137
|
+
fileName: string;
|
|
138
|
+
status: string;
|
|
139
|
+
totalVideos: number;
|
|
140
|
+
processedVideos: number;
|
|
141
|
+
failedVideos: number;
|
|
142
|
+
skippedAsDuplicate: number;
|
|
143
|
+
createdAt: string;
|
|
144
|
+
updatedAt: string;
|
|
145
|
+
completedAt: string | null;
|
|
146
|
+
jobStats: {
|
|
147
|
+
pending: number;
|
|
148
|
+
processing: number;
|
|
149
|
+
completed: number;
|
|
150
|
+
failed: number;
|
|
151
|
+
skipped: number;
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
export {};
|
package/dist/types.js
ADDED
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@quiki/mcp",
|
|
3
|
+
"version": "0.3.0",
|
|
4
|
+
"description": "Quiki.io MCP server — whoami, scan_url, get_scan, list_recent_videos, get_video, bulk_import, bulk_import_estimate, get_bulk_import_status over stdio.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "commonjs",
|
|
7
|
+
"bin": {
|
|
8
|
+
"quiki-mcp": "./dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"files": [
|
|
12
|
+
"dist",
|
|
13
|
+
"README.md"
|
|
14
|
+
],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"start": "node dist/index.js",
|
|
18
|
+
"dev": "ts-node src/index.ts",
|
|
19
|
+
"test": "jest"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {
|
|
22
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
23
|
+
"axios": "^1.7.9",
|
|
24
|
+
"zod": "^4.0.14"
|
|
25
|
+
},
|
|
26
|
+
"devDependencies": {
|
|
27
|
+
"@types/jest": "^29.5.12",
|
|
28
|
+
"@types/node": "^22.10.10",
|
|
29
|
+
"jest": "^29.7.0",
|
|
30
|
+
"ts-jest": "^29.4.6",
|
|
31
|
+
"ts-node": "^10.9.2",
|
|
32
|
+
"typescript": "^5.5.4"
|
|
33
|
+
},
|
|
34
|
+
"engines": {
|
|
35
|
+
"node": ">=20.0.0"
|
|
36
|
+
},
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public"
|
|
39
|
+
}
|
|
40
|
+
}
|