MCPcopy
hub / github.com/ChromeDevTools/chrome-devtools-mcp / saveFile

Method saveFile

src/McpContext.ts:788–806  ·  view source on GitHub ↗
(
    data: Uint8Array<ArrayBufferLike>,
    clientProvidedFilePath: string,
    extension: SupportedExtensions,
  )

Source from the content-addressed store, hash-verified

786 }
787
788 async saveFile(
789 data: Uint8Array<ArrayBufferLike>,
790 clientProvidedFilePath: string,
791 extension: SupportedExtensions,
792 ): Promise<{filename: string}> {
793 await this.validatePath(clientProvidedFilePath);
794 try {
795 const filePath = ensureExtension(
796 path.resolve(clientProvidedFilePath),
797 extension,
798 );
799 await fs.mkdir(path.dirname(filePath), {recursive: true});
800 await fs.writeFile(filePath, data);
801 return {filename: filePath};
802 } catch (err) {
803 this.logger?.(err);
804 throw new Error('Could not save a file', {cause: err});
805 }
806 }
807
808 storeTraceRecording(result: TraceResult): void {
809 // Clear the trace results because we only consume the latest trace currently.

Callers 6

handleMethod · 0.80
lighthouse.tsFile · 0.80
screenshot.tsFile · 0.80
performEvaluationFunction · 0.80
#loadDetailedDataMethod · 0.80

Calls 2

validatePathMethod · 0.95
ensureExtensionFunction · 0.85

Tested by

no test coverage detected