MCPcopy
hub / github.com/codeaashu/claude-code / extensionForMimeType

Function extensionForMimeType

src/utils/mcpOutputStorage.ts:66–118  ·  view source on GitHub ↗
(mimeType: string | undefined)

Source from the content-addressed store, hash-verified

64 * the Read tool dispatches on it (PDFs, images, etc. need the right ext).
65 */
66export function extensionForMimeType(mimeType: string | undefined): string {
67 if (!mimeType) return 'bin'
68 // Strip any charset/boundary parameter
69 const mt = (mimeType.split(';')[0] ?? '').trim().toLowerCase()
70 switch (mt) {
71 case 'application/pdf':
72 return 'pdf'
73 case 'application/json':
74 return 'json'
75 case 'text/csv':
76 return 'csv'
77 case 'text/plain':
78 return 'txt'
79 case 'text/html':
80 return 'html'
81 case 'text/markdown':
82 return 'md'
83 case 'application/zip':
84 return 'zip'
85 case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
86 return 'docx'
87 case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
88 return 'xlsx'
89 case 'application/vnd.openxmlformats-officedocument.presentationml.presentation':
90 return 'pptx'
91 case 'application/msword':
92 return 'doc'
93 case 'application/vnd.ms-excel':
94 return 'xls'
95 case 'audio/mpeg':
96 return 'mp3'
97 case 'audio/wav':
98 return 'wav'
99 case 'audio/ogg':
100 return 'ogg'
101 case 'video/mp4':
102 return 'mp4'
103 case 'video/webm':
104 return 'webm'
105 case 'image/png':
106 return 'png'
107 case 'image/jpeg':
108 return 'jpg'
109 case 'image/gif':
110 return 'gif'
111 case 'image/webp':
112 return 'webp'
113 case 'image/svg+xml':
114 return 'svg'
115 default:
116 return 'bin'
117 }
118}
119
120/**
121 * Heuristic for whether a content-type header indicates binary content that

Callers 1

persistBinaryContentFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected