@speakai/mcp-server 1.41.3 → 1.42.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 +17 -6
- package/dist/index.js +203 -29
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -256,7 +256,7 @@ For questions about data handling, see [speakai.co/privacy](https://speakai.co/p
|
|
|
256
256
|
|
|
257
257
|
## What you can do once installed
|
|
258
258
|
|
|
259
|
-
Speak AI ships
|
|
259
|
+
Speak AI ships tools for media, transcripts, AI chat, automations, voice agents and more that your AI assistant can call. You don't need to memorize them; your AI assistant picks the right ones based on what you ask. Examples by category:
|
|
260
260
|
|
|
261
261
|
| Ask | Tools used (auto) |
|
|
262
262
|
|---|---|
|
|
@@ -286,7 +286,7 @@ Get a Speak AI API key at [app.speakai.co/developers/apikeys](https://app.speaka
|
|
|
286
286
|
|
|
287
287
|
The `@speakai/mcp-server` npm package provides:
|
|
288
288
|
|
|
289
|
-
- A CLI (`speakai-mcp`) for scripting and pipelines
|
|
289
|
+
- A CLI (`speakai-mcp`) for scripting and pipelines.
|
|
290
290
|
- A stdio-mode MCP server for clients that don't support remote HTTP transport.
|
|
291
291
|
- An auto-setup wizard that detects installed MCP clients and configures them.
|
|
292
292
|
|
|
@@ -408,7 +408,7 @@ SPEAK_API_KEY=your-key npx @speakai/mcp-server
|
|
|
408
408
|
| `SPEAK_ACCESS_TOKEN` | No | Auto-managed | JWT access token (auto-fetched and refreshed) |
|
|
409
409
|
| `SPEAK_BASE_URL` | No | `https://api.speakai.co` | API base URL |
|
|
410
410
|
|
|
411
|
-
### MCP Tools
|
|
411
|
+
### MCP Tools
|
|
412
412
|
|
|
413
413
|
<details>
|
|
414
414
|
<summary>Media (19 tools)</summary>
|
|
@@ -749,7 +749,16 @@ A test run sends each enabled scenario's scripted user messages to the agent as
|
|
|
749
749
|
|
|
750
750
|
</details>
|
|
751
751
|
|
|
752
|
-
|
|
752
|
+
<details>
|
|
753
|
+
<summary>Billing (1 tool)</summary>
|
|
754
|
+
|
|
755
|
+
| Tool | Description |
|
|
756
|
+
|---|---|
|
|
757
|
+
| `get_billing_status` | Plan, remaining credits, renewal or trial end, pending payment, and upgrade or top-up checkout links (checkout links only for people who can manage billing) |
|
|
758
|
+
|
|
759
|
+
</details>
|
|
760
|
+
|
|
761
|
+
### MCP Resources
|
|
753
762
|
|
|
754
763
|
Resources provide direct data access without tool calls. Clients can read these URIs directly.
|
|
755
764
|
|
|
@@ -761,7 +770,7 @@ Resources provide direct data access without tool calls. Clients can read these
|
|
|
761
770
|
| Transcript | `speakai://media/{mediaId}/transcript` | Full transcript for a specific media file |
|
|
762
771
|
| Insights | `speakai://media/{mediaId}/insights` | AI-generated insights for a specific media file |
|
|
763
772
|
|
|
764
|
-
### MCP Prompts
|
|
773
|
+
### MCP Prompts
|
|
765
774
|
|
|
766
775
|
Pre-built workflow prompts that agents can invoke to run multi-step tasks.
|
|
767
776
|
|
|
@@ -795,7 +804,7 @@ Parameters: days (optional, default: 7), folder (optional)
|
|
|
795
804
|
|
|
796
805
|
**Example:** "Use the meeting-brief prompt with days=14 to cover the last two weeks"
|
|
797
806
|
|
|
798
|
-
### CLI
|
|
807
|
+
### CLI
|
|
799
808
|
|
|
800
809
|
Install globally and configure once:
|
|
801
810
|
|
|
@@ -1032,6 +1041,8 @@ All tool errors follow this structure:
|
|
|
1032
1041
|
| `404` | Resource not found |
|
|
1033
1042
|
| `429` | Rate limit exceeded |
|
|
1034
1043
|
|
|
1044
|
+
When the account cannot pay for the work, the tool error leads with the API's `userMessage`, followed by a `Continue here: <checkoutUrl>` line when there is one. `structuredContent.data` carries the full reply: `reason` (`OUT_OF_CREDITS`, `TRIAL_ENDED`, `PAYMENT_METHOD_REQUIRED`, `PLAN_FEATURE` or `PENDING_PAYMENT`; left out for public visitors), `billing` (`plan`: `free_trial`, `pay_as_you_go`, `pro` or `custom`; `creditsRemaining`, `creditsNeeded`, `trialEndsAt`, `canManageBilling`), `options` (`pro` carries only `id`, `recommended` and `url`, with no price; `top_up` carries `id`, `recommended`, `amount`, `currency`, `credits`, `autoReload` and `url`) and `agentNotes`. `checkoutUrl` is left out when the person cannot manage billing. Show the message to the user and retry only after they confirm. Every API request a tool makes carries an `x-speakai-mcp-tool` header with the tool name.
|
|
1045
|
+
|
|
1035
1046
|
### Development
|
|
1036
1047
|
|
|
1037
1048
|
```sh
|
package/dist/index.js
CHANGED
|
@@ -34,10 +34,71 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
34
34
|
// src/client.ts
|
|
35
35
|
var client_exports = {};
|
|
36
36
|
__export(client_exports, {
|
|
37
|
+
TOOL_NAME_HEADER: () => TOOL_NAME_HEADER,
|
|
37
38
|
createSpeakClient: () => createSpeakClient,
|
|
38
39
|
formatAxiosError: () => formatAxiosError,
|
|
40
|
+
formatRefusal: () => formatRefusal,
|
|
41
|
+
getApiRefusal: () => getApiRefusal,
|
|
42
|
+
instrumentSpeakClient: () => instrumentSpeakClient,
|
|
43
|
+
isFailedBody: () => isFailedBody,
|
|
44
|
+
runToolCall: () => runToolCall,
|
|
39
45
|
speakClient: () => speakClient
|
|
40
46
|
});
|
|
47
|
+
function runToolCall(toolName, fn) {
|
|
48
|
+
const context = { toolName };
|
|
49
|
+
return toolCallContext.run(context, () => fn(context));
|
|
50
|
+
}
|
|
51
|
+
function isRecord(value) {
|
|
52
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
53
|
+
}
|
|
54
|
+
function isFailedBody(value) {
|
|
55
|
+
return isRecord(value) && value.status === "failed";
|
|
56
|
+
}
|
|
57
|
+
function getApiRefusal(value) {
|
|
58
|
+
const fromError = import_axios.default.isAxiosError(value);
|
|
59
|
+
const body = fromError ? value.response?.data : value;
|
|
60
|
+
if (!isRecord(body)) return void 0;
|
|
61
|
+
const hasUserMessage = typeof body.userMessage === "string";
|
|
62
|
+
if (body.status === "failed" && hasUserMessage) return body;
|
|
63
|
+
const httpStatus = fromError ? value.response?.status : void 0;
|
|
64
|
+
const isClientError = httpStatus !== void 0 && httpStatus >= 400 && httpStatus < 500;
|
|
65
|
+
if (isClientError && (hasUserMessage || typeof body.reason === "string")) return body;
|
|
66
|
+
return void 0;
|
|
67
|
+
}
|
|
68
|
+
function formatRefusal(refusal) {
|
|
69
|
+
const lead = typeof refusal.userMessage === "string" && refusal.userMessage || typeof refusal.message === "string" && refusal.message || "The request was declined.";
|
|
70
|
+
return typeof refusal.checkoutUrl === "string" && refusal.checkoutUrl ? `${lead}
|
|
71
|
+
Continue here: ${refusal.checkoutUrl}` : lead;
|
|
72
|
+
}
|
|
73
|
+
function instrumentSpeakClient(client) {
|
|
74
|
+
if (!client?.interceptors || instrumentedClients.has(client)) return client;
|
|
75
|
+
instrumentedClients.add(client);
|
|
76
|
+
client.interceptors.request.use((config) => {
|
|
77
|
+
const toolName = toolCallContext.getStore()?.toolName;
|
|
78
|
+
if (toolName) config.headers.set(TOOL_NAME_HEADER, toolName);
|
|
79
|
+
return config;
|
|
80
|
+
});
|
|
81
|
+
const keepRefusal = (value) => {
|
|
82
|
+
const context = toolCallContext.getStore();
|
|
83
|
+
const refusal = getApiRefusal(value);
|
|
84
|
+
if (context && refusal) context.refusal = refusal;
|
|
85
|
+
};
|
|
86
|
+
client.interceptors.response.use(
|
|
87
|
+
(response) => {
|
|
88
|
+
if (!isFailedBody(response.data)) return response;
|
|
89
|
+
keepRefusal(response.data);
|
|
90
|
+
const message = getApiRefusal(response.data) ? formatRefusal(response.data) : String(response.data.message ?? "The API reported that the request failed.");
|
|
91
|
+
return Promise.reject(
|
|
92
|
+
new import_axios.default.AxiosError(message, "ERR_BAD_RESPONSE", response.config, response.request, response)
|
|
93
|
+
);
|
|
94
|
+
},
|
|
95
|
+
(error) => {
|
|
96
|
+
keepRefusal(error);
|
|
97
|
+
return Promise.reject(error);
|
|
98
|
+
}
|
|
99
|
+
);
|
|
100
|
+
return client;
|
|
101
|
+
}
|
|
41
102
|
function getBaseUrl() {
|
|
42
103
|
return process.env.SPEAK_BASE_URL ?? "https://api.speakai.co";
|
|
43
104
|
}
|
|
@@ -109,15 +170,17 @@ async function ensureAuthenticated() {
|
|
|
109
170
|
}
|
|
110
171
|
}
|
|
111
172
|
function createSpeakClient(options) {
|
|
112
|
-
return
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
173
|
+
return instrumentSpeakClient(
|
|
174
|
+
import_axios.default.create({
|
|
175
|
+
baseURL: options.baseUrl,
|
|
176
|
+
headers: {
|
|
177
|
+
"Content-Type": "application/json",
|
|
178
|
+
"x-speakai-key": options.apiKey,
|
|
179
|
+
"x-access-token": options.accessToken
|
|
180
|
+
},
|
|
181
|
+
timeout: 6e4
|
|
182
|
+
})
|
|
183
|
+
);
|
|
121
184
|
}
|
|
122
185
|
function redactValue(value, depth = 0) {
|
|
123
186
|
if (depth > 4) return "[truncated]";
|
|
@@ -137,6 +200,8 @@ function redactValue(value, depth = 0) {
|
|
|
137
200
|
return value;
|
|
138
201
|
}
|
|
139
202
|
function formatAxiosError(error) {
|
|
203
|
+
const refusal = getApiRefusal(error);
|
|
204
|
+
if (refusal) return formatRefusal(refusal);
|
|
140
205
|
if (import_axios.default.isAxiosError(error)) {
|
|
141
206
|
const status = error.response?.status;
|
|
142
207
|
const data = error.response?.data;
|
|
@@ -147,11 +212,15 @@ function formatAxiosError(error) {
|
|
|
147
212
|
if (error instanceof Error) return error.message;
|
|
148
213
|
return String(error);
|
|
149
214
|
}
|
|
150
|
-
var import_axios, accessToken, refreshToken, tokenExpiresAt, speakClient, SENSITIVE_KEY_PATTERN, MAX_STRING_LEN;
|
|
215
|
+
var import_node_async_hooks, import_axios, TOOL_NAME_HEADER, toolCallContext, instrumentedClients, accessToken, refreshToken, tokenExpiresAt, speakClient, SENSITIVE_KEY_PATTERN, MAX_STRING_LEN;
|
|
151
216
|
var init_client = __esm({
|
|
152
217
|
"src/client.ts"() {
|
|
153
218
|
"use strict";
|
|
219
|
+
import_node_async_hooks = require("async_hooks");
|
|
154
220
|
import_axios = __toESM(require("axios"));
|
|
221
|
+
TOOL_NAME_HEADER = "x-speakai-mcp-tool";
|
|
222
|
+
toolCallContext = new import_node_async_hooks.AsyncLocalStorage();
|
|
223
|
+
instrumentedClients = /* @__PURE__ */ new WeakSet();
|
|
155
224
|
accessToken = process.env.SPEAK_ACCESS_TOKEN ?? "";
|
|
156
225
|
refreshToken = "";
|
|
157
226
|
tokenExpiresAt = 0;
|
|
@@ -197,19 +266,39 @@ var init_client = __esm({
|
|
|
197
266
|
return Promise.reject(error);
|
|
198
267
|
}
|
|
199
268
|
);
|
|
269
|
+
instrumentSpeakClient(speakClient);
|
|
200
270
|
SENSITIVE_KEY_PATTERN = /(token|secret|password|cookie|authorization|jwt|apikey|api[_-]?key|bearer|signature)/i;
|
|
201
271
|
MAX_STRING_LEN = 500;
|
|
202
272
|
}
|
|
203
273
|
});
|
|
204
274
|
|
|
205
275
|
// src/tools/_helpers.ts
|
|
206
|
-
function
|
|
276
|
+
function refusalResult(refusal) {
|
|
277
|
+
return {
|
|
278
|
+
content: [{ type: "text", text: formatRefusal(refusal) }],
|
|
279
|
+
structuredContent: { data: refusal },
|
|
280
|
+
isError: true
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
function failedBodyResult(data) {
|
|
284
|
+
const refusal = getApiRefusal(data);
|
|
285
|
+
if (refusal) return refusalResult(refusal);
|
|
286
|
+
if (!isFailedBody(data)) return void 0;
|
|
207
287
|
return {
|
|
288
|
+
content: [{ type: "text", text: `Error: ${JSON.stringify(data, null, 2)}` }],
|
|
289
|
+
structuredContent: { data },
|
|
290
|
+
isError: true
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
function ok(data) {
|
|
294
|
+
return failedBodyResult(data) ?? {
|
|
208
295
|
content: [{ type: "text", text: JSON.stringify(data, null, 2) }],
|
|
209
296
|
structuredContent: { data }
|
|
210
297
|
};
|
|
211
298
|
}
|
|
212
299
|
function err(error) {
|
|
300
|
+
const refusal = getApiRefusal(error);
|
|
301
|
+
if (refusal) return refusalResult(refusal);
|
|
213
302
|
return {
|
|
214
303
|
content: [{ type: "text", text: `Error: ${formatAxiosError(error)}` }],
|
|
215
304
|
isError: true
|
|
@@ -226,8 +315,11 @@ function registerSpeakTool(server, name, description, inputSchema, annotations,
|
|
|
226
315
|
outputSchema: passthroughOutputSchema,
|
|
227
316
|
annotations
|
|
228
317
|
},
|
|
229
|
-
async (args2, extra) => {
|
|
318
|
+
async (args2, extra) => runToolCall(name, async (context) => {
|
|
230
319
|
const result = await handler(args2, extra);
|
|
320
|
+
if (result.isError && context.refusal) {
|
|
321
|
+
return refusalResult(context.refusal);
|
|
322
|
+
}
|
|
231
323
|
if (result.isError || result.structuredContent) {
|
|
232
324
|
return result;
|
|
233
325
|
}
|
|
@@ -237,12 +329,16 @@ function registerSpeakTool(server, name, description, inputSchema, annotations,
|
|
|
237
329
|
if (!textContent) {
|
|
238
330
|
return { ...result, structuredContent: { data: null } };
|
|
239
331
|
}
|
|
332
|
+
let data;
|
|
240
333
|
try {
|
|
241
|
-
|
|
334
|
+
data = JSON.parse(textContent.text);
|
|
242
335
|
} catch {
|
|
243
336
|
return { ...result, structuredContent: { data: textContent.text } };
|
|
244
337
|
}
|
|
245
|
-
|
|
338
|
+
const refusal = getApiRefusal(data);
|
|
339
|
+
if (refusal) return refusalResult(refusal);
|
|
340
|
+
return { ...result, structuredContent: { data } };
|
|
341
|
+
})
|
|
246
342
|
);
|
|
247
343
|
}
|
|
248
344
|
var import_zod, passthroughOutputSchema, fieldIdSchema, SHARED_DASHBOARD_CACHE_NOTE;
|
|
@@ -6785,7 +6881,7 @@ function register7(server, client, options = {}) {
|
|
|
6785
6881
|
const api = client ?? speakClient;
|
|
6786
6882
|
const askAiChatDescription = [
|
|
6787
6883
|
"Ask an AI-powered question about your media using Speak AI's AI Chat.",
|
|
6788
|
-
"Supports querying a single file, multiple files, entire folders, or your whole
|
|
6884
|
+
"Supports querying a single file, multiple files, entire folders, or your whole account.",
|
|
6789
6885
|
"Pass mediaIds for specific files, folderIds for entire folders, or omit both to search across all media.",
|
|
6790
6886
|
"Use assistantType to get specialized responses (e.g., 'researcher' for academic analysis, 'sales' for deal insights).",
|
|
6791
6887
|
"To continue a conversation, pass the promptId from a previous response.",
|
|
@@ -6889,7 +6985,7 @@ function register7(server, client, options = {}) {
|
|
|
6889
6985
|
if (options.aiChat) registerSpeakTool(
|
|
6890
6986
|
server,
|
|
6891
6987
|
"get_analysis_quote",
|
|
6892
|
-
"Check whether a media file can be analysed as audio or video, and what it will cost, before running ask_ai_chat with analysisInput. Returns { eligible, credits, seconds } and, when not eligible, a plain-English reason \u2014 an unavailable file is a normal result here, not an error. This is the only check that accounts for both the account's premium opt-in and the server-wide switch, so call it before committing to an expensive run.",
|
|
6988
|
+
"Check whether a media file can be analysed as audio or video, and what it will cost, before running ask_ai_chat with analysisInput. Returns { eligible, credits, seconds } and, when not eligible, a plain-English reason \u2014 an unavailable file is a normal result here, not an error. This is the only check that accounts for both the account's premium opt-in and the server-wide switch, so call it before committing to an expensive run. Compare credits with the remaining balance from get_billing_status to warn the user before a run would use up their credits.",
|
|
6893
6989
|
{
|
|
6894
6990
|
mediaId: import_zod8.z.string().min(1).describe("Media file to price"),
|
|
6895
6991
|
analysisInput: import_zod8.z.enum(["audio", "video"]).describe(
|
|
@@ -10416,6 +10512,8 @@ Likely cause: this server rejects filter rules on webhook payload fields (${data
|
|
|
10416
10512
|
const mediaId = uploadRes.data?.data?.mediaId;
|
|
10417
10513
|
const state = uploadRes.data?.data?.state ?? "pending";
|
|
10418
10514
|
if (!mediaId) {
|
|
10515
|
+
const refusal = getApiRefusal(uploadRes.data);
|
|
10516
|
+
if (refusal) return refusalResult(refusal);
|
|
10419
10517
|
return {
|
|
10420
10518
|
content: [{ type: "text", text: `Error: Upload succeeded but no mediaId returned.
|
|
10421
10519
|
${JSON.stringify(uploadRes.data, null, 2)}` }],
|
|
@@ -10474,6 +10572,7 @@ ${JSON.stringify(uploadRes.data, null, 2)}` }],
|
|
|
10474
10572
|
if (params.tags) shared.tags = params.tags;
|
|
10475
10573
|
const uploaded = [];
|
|
10476
10574
|
const failed = [];
|
|
10575
|
+
let refusal;
|
|
10477
10576
|
let cursor = 0;
|
|
10478
10577
|
const workerCount = Math.min(params.concurrency ?? MAX_BATCH_CONCURRENCY, urls.length);
|
|
10479
10578
|
const send = (url) => api.post("/v1/media/upload", {
|
|
@@ -10482,7 +10581,7 @@ ${JSON.stringify(uploadRes.data, null, 2)}` }],
|
|
|
10482
10581
|
url
|
|
10483
10582
|
});
|
|
10484
10583
|
const worker = async () => {
|
|
10485
|
-
for (let i = cursor++; i < urls.length; i = cursor++) {
|
|
10584
|
+
for (let i = cursor++; i < urls.length && !refusal; i = cursor++) {
|
|
10486
10585
|
const url = urls[i];
|
|
10487
10586
|
try {
|
|
10488
10587
|
let res;
|
|
@@ -10495,21 +10594,34 @@ ${JSON.stringify(uploadRes.data, null, 2)}` }],
|
|
|
10495
10594
|
res = await send(url);
|
|
10496
10595
|
}
|
|
10497
10596
|
const mediaId = res.data?.data?.mediaId;
|
|
10498
|
-
if (mediaId)
|
|
10499
|
-
|
|
10597
|
+
if (mediaId) {
|
|
10598
|
+
uploaded.push({ url, mediaId, state: res.data?.data?.state ?? "pending" });
|
|
10599
|
+
continue;
|
|
10600
|
+
}
|
|
10601
|
+
refusal ?? (refusal = getApiRefusal(res.data));
|
|
10602
|
+
failed.push({ url, error: refusal ? formatRefusal(refusal) : "Upload accepted but no mediaId was returned." });
|
|
10500
10603
|
} catch (err2) {
|
|
10604
|
+
refusal ?? (refusal = getApiRefusal(err2));
|
|
10501
10605
|
failed.push({ url, error: formatAxiosError(err2) });
|
|
10502
10606
|
}
|
|
10503
10607
|
}
|
|
10504
10608
|
};
|
|
10505
10609
|
await Promise.all(Array.from({ length: workerCount }, worker));
|
|
10610
|
+
if (refusal && uploaded.length === 0) return refusalResult(refusal);
|
|
10611
|
+
const attempted = new Set([...uploaded, ...failed].map((entry) => entry.url));
|
|
10612
|
+
const notSent = urls.filter((url) => !attempted.has(url));
|
|
10506
10613
|
const result = {
|
|
10507
10614
|
requested: urls.length,
|
|
10508
10615
|
uploaded: uploaded.length,
|
|
10509
10616
|
failed: failed.length,
|
|
10510
10617
|
media: uploaded,
|
|
10511
10618
|
errors: failed,
|
|
10512
|
-
|
|
10619
|
+
...refusal ? { notSent, refusal } : {},
|
|
10620
|
+
nextSteps: refusal ? [
|
|
10621
|
+
`1. Stopped after ${uploaded.length} upload(s): ${formatRefusal(refusal)}`,
|
|
10622
|
+
`2. Show that message to the user. ${notSent.length + failed.length} URL(s) were not imported; send them again only after the user confirms.`,
|
|
10623
|
+
`3. Poll get_media_status for each uploaded mediaId every 10-30 seconds.`
|
|
10624
|
+
] : uploaded.length ? [
|
|
10513
10625
|
`1. Poll get_media_status for each of the ${uploaded.length} mediaId values every 10-30 seconds, or call list_media on the folder to see them together.`,
|
|
10514
10626
|
`2. When one reads "processed", call get_media_insights and get_transcript for it.`,
|
|
10515
10627
|
failed.length ? `3. ${failed.length} URL(s) did not upload \u2014 report the reasons above rather than silently retrying.` : `3. Nothing failed in this batch.`
|
|
@@ -10571,8 +10683,8 @@ ${JSON.stringify(signedRes.data, null, 2)}` }],
|
|
|
10571
10683
|
};
|
|
10572
10684
|
}
|
|
10573
10685
|
const fileBuffer = fs.readFileSync(filePath);
|
|
10574
|
-
const
|
|
10575
|
-
await
|
|
10686
|
+
const axios3 = (await import("axios")).default;
|
|
10687
|
+
await axios3.put(uploadUrl, fileBuffer, {
|
|
10576
10688
|
headers: {
|
|
10577
10689
|
"Content-Type": mimeType
|
|
10578
10690
|
},
|
|
@@ -12928,12 +13040,63 @@ var init_voice_intelligence = __esm({
|
|
|
12928
13040
|
}
|
|
12929
13041
|
});
|
|
12930
13042
|
|
|
13043
|
+
// src/tools/billing.ts
|
|
13044
|
+
var billing_exports = {};
|
|
13045
|
+
__export(billing_exports, {
|
|
13046
|
+
register: () => register23
|
|
13047
|
+
});
|
|
13048
|
+
function register23(server, client) {
|
|
13049
|
+
const api = client ?? speakClient;
|
|
13050
|
+
registerSpeakTool(
|
|
13051
|
+
server,
|
|
13052
|
+
"get_billing_status",
|
|
13053
|
+
"Show the account's billing status: plan (free_trial, pay_as_you_go, pro or custom), creditsRemaining, renewsAt, trialEndsAt, pendingPayment, canManageBilling and manageUrl, plus options: 'pro' has only id, recommended and a checkout url (no price), and 'top_up' has id, recommended, amount, currency, credits, autoReload and a checkout url. checkoutUrl links to the recommended option and is left out when the current user cannot manage billing; then ask them to contact whoever manages billing on the account. Read-only and free to call. Use it to warn the user before an upload, analysis or chat would run past the remaining credits, or after a tool reports that the account is out of credits. Share the links with the user and let them decide; never complete a purchase for them.",
|
|
13054
|
+
{},
|
|
13055
|
+
{
|
|
13056
|
+
title: "Get Billing Status",
|
|
13057
|
+
readOnlyHint: true,
|
|
13058
|
+
destructiveHint: false,
|
|
13059
|
+
idempotentHint: true,
|
|
13060
|
+
openWorldHint: false
|
|
13061
|
+
},
|
|
13062
|
+
async () => {
|
|
13063
|
+
try {
|
|
13064
|
+
const result = await api.get("/v1/subscription/billing-status");
|
|
13065
|
+
return ok(result.data);
|
|
13066
|
+
} catch (error) {
|
|
13067
|
+
if (import_axios2.default.isAxiosError(error) && error.response?.status === 404) {
|
|
13068
|
+
return {
|
|
13069
|
+
content: [
|
|
13070
|
+
{
|
|
13071
|
+
type: "text",
|
|
13072
|
+
text: "Error: Billing status is not available from this Speak AI server yet (HTTP 404). Ask the user to check their plan and credits in the Speak AI app."
|
|
13073
|
+
}
|
|
13074
|
+
],
|
|
13075
|
+
isError: true
|
|
13076
|
+
};
|
|
13077
|
+
}
|
|
13078
|
+
return err(error);
|
|
13079
|
+
}
|
|
13080
|
+
}
|
|
13081
|
+
);
|
|
13082
|
+
}
|
|
13083
|
+
var import_axios2;
|
|
13084
|
+
var init_billing3 = __esm({
|
|
13085
|
+
"src/tools/billing.ts"() {
|
|
13086
|
+
"use strict";
|
|
13087
|
+
import_axios2 = __toESM(require("axios"));
|
|
13088
|
+
init_helpers();
|
|
13089
|
+
init_client();
|
|
13090
|
+
}
|
|
13091
|
+
});
|
|
13092
|
+
|
|
12931
13093
|
// src/tools/index.ts
|
|
12932
13094
|
var tools_exports = {};
|
|
12933
13095
|
__export(tools_exports, {
|
|
12934
13096
|
registerAllTools: () => registerAllTools
|
|
12935
13097
|
});
|
|
12936
13098
|
function registerAllTools(server, client, options = {}) {
|
|
13099
|
+
if (client) instrumentSpeakClient(client);
|
|
12937
13100
|
for (const mod of modules) {
|
|
12938
13101
|
mod.register(server, client, options);
|
|
12939
13102
|
}
|
|
@@ -12964,6 +13127,8 @@ var init_tools = __esm({
|
|
|
12964
13127
|
init_voice_testing();
|
|
12965
13128
|
init_voice_questions();
|
|
12966
13129
|
init_voice_intelligence();
|
|
13130
|
+
init_billing3();
|
|
13131
|
+
init_client();
|
|
12967
13132
|
modules = [
|
|
12968
13133
|
media_exports,
|
|
12969
13134
|
text_exports,
|
|
@@ -12986,7 +13151,8 @@ var init_tools = __esm({
|
|
|
12986
13151
|
voice_exports,
|
|
12987
13152
|
voice_testing_exports,
|
|
12988
13153
|
voice_questions_exports,
|
|
12989
|
-
voice_intelligence_exports
|
|
13154
|
+
voice_intelligence_exports,
|
|
13155
|
+
billing_exports
|
|
12990
13156
|
];
|
|
12991
13157
|
}
|
|
12992
13158
|
});
|
|
@@ -13379,6 +13545,7 @@ var init_tool_names = __esm({
|
|
|
13379
13545
|
"upload_local_file",
|
|
13380
13546
|
// users / team management
|
|
13381
13547
|
"list_users",
|
|
13548
|
+
"get_billing_status",
|
|
13382
13549
|
"list_user_groups",
|
|
13383
13550
|
"create_user_group",
|
|
13384
13551
|
"update_user_group",
|
|
@@ -13627,9 +13794,9 @@ function createCli() {
|
|
|
13627
13794
|
process.exit(1);
|
|
13628
13795
|
}
|
|
13629
13796
|
try {
|
|
13630
|
-
const
|
|
13797
|
+
const axios3 = (await import("axios")).default;
|
|
13631
13798
|
const baseUrl = process.env.SPEAK_BASE_URL ?? "https://api.speakai.co";
|
|
13632
|
-
const res = await
|
|
13799
|
+
const res = await axios3.post(
|
|
13633
13800
|
`${baseUrl}/v1/auth/accessToken`,
|
|
13634
13801
|
{},
|
|
13635
13802
|
{ headers: { "Content-Type": "application/json", "x-speakai-key": key } }
|
|
@@ -13672,9 +13839,9 @@ function createCli() {
|
|
|
13672
13839
|
}
|
|
13673
13840
|
process.stdout.write(" Validating...");
|
|
13674
13841
|
try {
|
|
13675
|
-
const
|
|
13842
|
+
const axios3 = (await import("axios")).default;
|
|
13676
13843
|
const baseUrl = process.env.SPEAK_BASE_URL ?? "https://api.speakai.co";
|
|
13677
|
-
const res = await
|
|
13844
|
+
const res = await axios3.post(
|
|
13678
13845
|
`${baseUrl}/v1/auth/accessToken`,
|
|
13679
13846
|
{},
|
|
13680
13847
|
{ headers: { "Content-Type": "application/json", "x-speakai-key": key } }
|
|
@@ -13900,8 +14067,8 @@ function createCli() {
|
|
|
13900
14067
|
}
|
|
13901
14068
|
process.stdout.write("Uploading...");
|
|
13902
14069
|
const fileBuffer = fs3.readFileSync(source);
|
|
13903
|
-
const
|
|
13904
|
-
await
|
|
14070
|
+
const axios3 = (await import("axios")).default;
|
|
14071
|
+
await axios3.put(uploadUrl, fileBuffer, {
|
|
13905
14072
|
headers: { "Content-Type": mimeType },
|
|
13906
14073
|
maxBodyLength: Infinity,
|
|
13907
14074
|
maxContentLength: Infinity
|
|
@@ -14888,6 +15055,13 @@ var SPEAK_MCP_TOOL_CATEGORIES = [
|
|
|
14888
15055
|
"analyze_voice_instruction_gaps",
|
|
14889
15056
|
"apply_voice_instruction_gap"
|
|
14890
15057
|
]
|
|
15058
|
+
},
|
|
15059
|
+
{
|
|
15060
|
+
id: "billing",
|
|
15061
|
+
name: "Billing",
|
|
15062
|
+
tools: [
|
|
15063
|
+
"get_billing_status"
|
|
15064
|
+
]
|
|
14891
15065
|
}
|
|
14892
15066
|
];
|
|
14893
15067
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@speakai/mcp-server",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.42.0",
|
|
4
4
|
"mcpName": "io.github.speakai/mcp-server",
|
|
5
5
|
"description": "Official Speak AI MCP Server — capture meetings, search thousands of recordings, run async voice and video surveys, create clips, and automate workflows from your AI assistant.",
|
|
6
6
|
"homepage": "https://docs.speakai.co/mcp",
|