MCPcopy
hub / github.com/coder/mux / read

Method read

src/node/utils/sessionFile.ts:46–59  ·  view source on GitHub ↗

* Read JSON file from workspace session directory. * Returns null if file doesn't exist (not an error).

(workspaceId: string)

Source from the content-addressed store, hash-verified

44 * Returns null if file doesn't exist (not an error).
45 */
46 async read(workspaceId: string): Promise<T | null> {
47 try {
48 const filePath = this.getFilePath(workspaceId);
49 const data = await fs.readFile(filePath, "utf-8");
50 return JSON.parse(data) as T;
51 } catch (error) {
52 if (error && typeof error === "object" && "code" in error && error.code === "ENOENT") {
53 return null; // File doesn't exist
54 }
55 // Log other errors but don't fail
56 log.error(`Error reading ${this.fileName}:`, error);
57 return null;
58 }
59 }
60
61 /**
62 * Write JSON file to workspace session directory with file locking.

Callers 15

MemoryFileEditorFunction · 0.45
collectStreamFunction · 0.45
readPersistedMethod · 0.45
replayMethod · 0.45
readStreamToBufferFunction · 0.45
readStreamToBufferFunction · 0.45
readFileFunction · 0.45
streamToStringFunction · 0.45
readStdoutFunction · 0.45
readStderrFunction · 0.45
startFunction · 0.45

Calls 3

getFilePathMethod · 0.95
readFileMethod · 0.65
parseMethod · 0.45

Tested by 3

collectStreamFunction · 0.36
readStreamAsStringFunction · 0.36
readAllFunction · 0.36