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

Function toolFileKind

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

Source from the content-addressed store, hash-verified

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

Callers 1

toolFileContentFunction · 0.85

Calls 1

normalizedMimeTypeFunction · 0.85

Tested by

no test coverage detected