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

Function toolFileKind

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

Source from the content-addressed store, hash-verified

299 file.mimeType.split(";")[0]?.trim().toLowerCase() ?? "";
300
301const toolFileKind = (file: ToolFileValue): "image" | "audio" | "text" | "resource" => {
302 const mimeType = normalizedMimeType(file);
303 if (mimeType.startsWith("image/")) return "image";
304 if (mimeType.startsWith("audio/")) return "audio";
305 if (
306 mimeType.startsWith("text/") ||
307 mimeType === "application/json" ||
308 mimeType.endsWith("+json") ||
309 mimeType === "application/xml" ||
310 mimeType.endsWith("+xml") ||
311 mimeType === "application/javascript" ||
312 mimeType === "application/x-javascript" ||
313 mimeType === "application/yaml" ||
314 mimeType === "application/x-yaml"
315 ) {
316 return "text";
317 }
318 return "resource";
319};
320
321const bytesFromBase64 = (base64: string): Uint8Array => {
322 const binary = atob(base64);

Callers 1

toolFileContentFunction · 0.85

Calls 1

normalizedMimeTypeFunction · 0.85

Tested by

no test coverage detected