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

Function toolFileKind

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

Source from the content-addressed store, hash-verified

581 file.mimeType.split(";")[0]?.trim().toLowerCase() ?? "";
582
583const toolFileKind = (file: ToolFileValue): "image" | "audio" | "text" | "resource" => {
584 const mimeType = normalizedMimeType(file);
585 if (mimeType.startsWith("image/")) return "image";
586 if (mimeType.startsWith("audio/")) return "audio";
587 if (
588 mimeType.startsWith("text/") ||
589 mimeType === "application/json" ||
590 mimeType.endsWith("+json") ||
591 mimeType === "application/xml" ||
592 mimeType.endsWith("+xml") ||
593 mimeType === "application/javascript" ||
594 mimeType === "application/x-javascript" ||
595 mimeType === "application/yaml" ||
596 mimeType === "application/x-yaml"
597 ) {
598 return "text";
599 }
600 return "resource";
601};
602
603const bytesFromBase64 = (base64: string): Uint8Array => {
604 const binary = atob(base64);

Callers 1

toolFileContentFunction · 0.85

Calls 1

normalizedMimeTypeFunction · 0.85

Tested by

no test coverage detected