MCPcopy
hub / github.com/modelcontextprotocol/servers / readFileAsBase64Stream

Function readFileAsBase64Stream

src/filesystem/index.ts:173–186  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

171// the result to a Base64 string. This is a memory-efficient way to handle
172// binary data from a stream before the final encoding.
173async function readFileAsBase64Stream(filePath: string): Promise<string> {
174 return new Promise((resolve, reject) => {
175 const stream = createReadStream(filePath);
176 const chunks: Buffer[] = [];
177 stream.on('data', (chunk) => {
178 chunks.push(chunk as Buffer);
179 });
180 stream.on('end', () => {
181 const finalBuffer = Buffer.concat(chunks);
182 resolve(finalBuffer.toString('base64'));
183 });
184 stream.on('error', (err) => reject(err));
185 });
186}
187
188// Tool registrations
189

Callers 1

index.tsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected