MCPcopy Create free account
hub / github.com/modelcontextprotocol/ext-apps / isWritablePath

Function isWritablePath

examples/pdf-server/server.ts:138–149  ·  view source on GitHub ↗
(resolved: string)

Source from the content-addressed store, hash-verified

136 * With no directory roots and no CLI files, nothing is writable.
137 */
138export function isWritablePath(resolved: string): boolean {
139 if (cliLocalFiles.has(resolved)) return true;
140 // MCP file root → always read-only, regardless of ancestry
141 if (allowedLocalFiles.has(resolved)) return false;
142 return [...allowedLocalDirs].some((dir) => {
143 if (!isAncestorDir(dir, resolved)) return false;
144 if (!writeFlags.allowUploadsRoot && path.basename(dir) === "uploads") {
145 return false;
146 }
147 return true;
148 });
149}
150
151// Works both from source (server.ts) and compiled (dist/server.js)
152const DIST_DIR = import.meta.filename.endsWith(".ts")

Callers 3

server.test.tsFile · 0.90
createServerFunction · 0.85
processInteractCommandFunction · 0.85

Calls 1

isAncestorDirFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…