@cencori/mcp 0.5.0 → 0.6.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 CHANGED
@@ -60,7 +60,7 @@ Docs + `how_to_*` guidance tools work with **no API key**. Add `CENCORI_API_KEY`
60
60
 
61
61
  ### Write — requires `CENCORI_MCP_WRITE=1`
62
62
 
63
- - **Inference:** `generate_text`, `generate_rag`, `create_embeddings`, `moderate_content`, `generate_image`, `describe_image`, `ocr_image`, `classify_image`, `extract_document`, `summarize_document`, `query_document`.
63
+ - **Inference:** `generate_text`, `generate_rag`, `create_embeddings`, `moderate_content`, `generate_image`, `describe_image`, `ocr_image`, `classify_image`, `extract_document`, `summarize_document`, `query_document`, `text_to_speech`, `transcribe_audio`.
64
64
  - **Memory:** `remember_memory`, `write_memory`, `create_namespace`.
65
65
  - **Agents:** `create_agent`, `update_agent`.
66
66
  - **Sessions:** `create_session`, `add_session_turn`.
package/dist/index.js CHANGED
@@ -148,6 +148,37 @@ var PlatformClient = class {
148
148
  del(path) {
149
149
  return this.request("DELETE", path);
150
150
  }
151
+ /** POST JSON and read a BINARY response (e.g. TTS audio). Returns base64 + mime. */
152
+ async postBinary(path, body) {
153
+ const url = new URL(`/api${path}`, this.baseUrl);
154
+ const response = await fetch(url, {
155
+ method: "POST",
156
+ headers: { Authorization: `Bearer ${this.apiKey}`, "Content-Type": "application/json" },
157
+ body: JSON.stringify(body),
158
+ signal: fetchSignal()
159
+ });
160
+ if (!response.ok) {
161
+ throw new Error(`Cencori API error: ${await readHttpErrorMessage(response)}`);
162
+ }
163
+ const mimeType = response.headers.get("content-type")?.split(";")[0]?.trim() || "application/octet-stream";
164
+ const buf = Buffer.from(await response.arrayBuffer());
165
+ return { base64: buf.toString("base64"), mimeType };
166
+ }
167
+ /** POST multipart/form-data (e.g. STT audio upload). Let fetch set the boundary. */
168
+ async postForm(path, form) {
169
+ const url = new URL(`/api${path}`, this.baseUrl);
170
+ const response = await fetch(url, {
171
+ method: "POST",
172
+ headers: { Authorization: `Bearer ${this.apiKey}` },
173
+ body: form,
174
+ signal: fetchSignal()
175
+ });
176
+ if (!response.ok) {
177
+ throw new Error(`Cencori API error: ${await readHttpErrorMessage(response)}`);
178
+ }
179
+ const text = await response.text();
180
+ return text ? JSON.parse(text) : void 0;
181
+ }
151
182
  listModels() {
152
183
  return this.get("/v1/models");
153
184
  }
@@ -1079,11 +1110,77 @@ function registerMultimodalTools(server, client) {
1079
1110
  );
1080
1111
  }
1081
1112
 
1082
- // src/tools/guidance.ts
1113
+ // src/tools/audio.ts
1083
1114
  var import_zod8 = require("zod");
1115
+ function registerAudioTools(server, client) {
1116
+ server.registerTool(
1117
+ "text_to_speech",
1118
+ {
1119
+ title: "Text to speech",
1120
+ description: "Synthesize speech from text. Returns audio. Incurs usage/cost.",
1121
+ inputSchema: {
1122
+ input: import_zod8.z.string().min(1).describe("The text to speak."),
1123
+ model: import_zod8.z.string().optional().describe("TTS model. Defaults to tts-1."),
1124
+ voice: import_zod8.z.string().optional().describe("Voice id/name (provider-specific)."),
1125
+ response_format: import_zod8.z.string().optional().describe("Audio format, e.g. mp3, wav, opus."),
1126
+ provider: import_zod8.z.string().optional().describe("Override the TTS provider.")
1127
+ },
1128
+ annotations: WRITE_ANNOTATIONS
1129
+ },
1130
+ async ({ input, model, voice, response_format, provider }) => {
1131
+ const { base64, mimeType } = await client.postBinary("/ai/audio/speech", {
1132
+ input,
1133
+ model,
1134
+ voice,
1135
+ response_format,
1136
+ provider
1137
+ });
1138
+ return {
1139
+ content: [
1140
+ { type: "audio", data: base64, mimeType },
1141
+ { type: "text", text: `Synthesized ${input.length} chars \u2192 ${mimeType} (${base64.length} b64 bytes).` }
1142
+ ]
1143
+ };
1144
+ }
1145
+ );
1146
+ server.registerTool(
1147
+ "transcribe_audio",
1148
+ {
1149
+ title: "Transcribe audio (speech to text)",
1150
+ description: "Transcribe base64-encoded audio to text. Incurs usage/cost.",
1151
+ inputSchema: {
1152
+ audio_base64: import_zod8.z.string().min(1).describe("Base64-encoded audio bytes."),
1153
+ mime_type: import_zod8.z.string().optional().describe("Audio MIME type, e.g. audio/mpeg, audio/wav."),
1154
+ filename: import_zod8.z.string().optional().describe("Original filename (helps format detection)."),
1155
+ model: import_zod8.z.string().optional().describe("STT model. Defaults to whisper-1."),
1156
+ language: import_zod8.z.string().optional().describe("ISO language code, e.g. en."),
1157
+ prompt: import_zod8.z.string().optional().describe("Optional prompt to guide transcription."),
1158
+ response_format: import_zod8.z.enum(["json", "text", "srt", "verbose_json", "vtt"]).optional().describe("Transcript format. verbose_json adds segments/words."),
1159
+ temperature: import_zod8.z.number().min(0).max(1).optional(),
1160
+ provider: import_zod8.z.string().optional().describe("Override the STT provider.")
1161
+ },
1162
+ annotations: WRITE_ANNOTATIONS
1163
+ },
1164
+ async ({ audio_base64, mime_type, filename, model, language, prompt, response_format, temperature, provider }) => {
1165
+ const bytes = Buffer.from(audio_base64, "base64");
1166
+ const form = new FormData();
1167
+ form.append("file", new Blob([bytes], { type: mime_type || "application/octet-stream" }), filename || "audio");
1168
+ if (model) form.append("model", model);
1169
+ if (language) form.append("language", language);
1170
+ if (prompt) form.append("prompt", prompt);
1171
+ if (response_format) form.append("response_format", response_format);
1172
+ if (temperature !== void 0) form.append("temperature", String(temperature));
1173
+ if (provider) form.append("provider", provider);
1174
+ return jsonResult(await client.postForm("/ai/audio/transcriptions", form));
1175
+ }
1176
+ );
1177
+ }
1178
+
1179
+ // src/tools/guidance.ts
1180
+ var import_zod9 = require("zod");
1084
1181
  var orgProjectShape = {
1085
- org_slug: import_zod8.z.string().min(1).optional().describe("Your organization slug, to build an exact dashboard link."),
1086
- project_slug: import_zod8.z.string().min(1).optional().describe("Your project slug, to build an exact dashboard link.")
1182
+ org_slug: import_zod9.z.string().min(1).optional().describe("Your organization slug, to build an exact dashboard link."),
1183
+ project_slug: import_zod9.z.string().min(1).optional().describe("Your project slug, to build an exact dashboard link.")
1087
1184
  };
1088
1185
  function registerGuide(server, name, title, description, buildPath, steps, baseUrl) {
1089
1186
  server.registerTool(
@@ -1214,7 +1311,7 @@ function registerGuidanceTools(server, baseUrl) {
1214
1311
 
1215
1312
  // src/server.ts
1216
1313
  var SERVER_NAME = "cencori";
1217
- var SERVER_VERSION = "0.5.0";
1314
+ var SERVER_VERSION = "0.6.0";
1218
1315
  function createServer(config) {
1219
1316
  const server = new import_mcp.McpServer(
1220
1317
  {
@@ -1245,6 +1342,7 @@ function createServer(config) {
1245
1342
  if (features.governance) registerGovernanceTools(server, client, capabilities);
1246
1343
  if (features.multimodal && capabilities.write) {
1247
1344
  registerMultimodalTools(server, client);
1345
+ registerAudioTools(server, client);
1248
1346
  }
1249
1347
  }
1250
1348
  return server;