MCPcopy Create free account
hub / github.com/UsefulSoftwareCo/executor / toolFileKind

Function toolFileKind

packages/hosts/mcp/src/tool-server.ts:340–358  ·  view source on GitHub ↗
(file: ToolFileValue)

Source from the content-addressed store, hash-verified

338 file.mimeType.split(";")[0]?.trim().toLowerCase() ?? "";
339
340const toolFileKind = (file: ToolFileValue): "image" | "audio" | "text" | "resource" => {
341 const mimeType = normalizedMimeType(file);
342 if (mimeType.startsWith("image/")) return "image";
343 if (mimeType.startsWith("audio/")) return "audio";
344 if (
345 mimeType.startsWith("text/") ||
346 mimeType === "application/json" ||
347 mimeType.endsWith("+json") ||
348 mimeType === "application/xml" ||
349 mimeType.endsWith("+xml") ||
350 mimeType === "application/javascript" ||
351 mimeType === "application/x-javascript" ||
352 mimeType === "application/yaml" ||
353 mimeType === "application/x-yaml"
354 ) {
355 return "text";
356 }
357 return "resource";
358};
359
360const bytesFromBase64 = (base64: string): Uint8Array => {
361 const binary = atob(base64);

Callers 1

toolFileContentFunction · 0.85

Calls 1

normalizedMimeTypeFunction · 0.85

Tested by

no test coverage detected