MCPcopy
hub / github.com/zcaceres/markdownify-mcp / assertPathAllowed

Function assertPathAllowed

src/utils.ts:46–57  ·  view source on GitHub ↗
(filePath: string)

Source from the content-addressed store, hash-verified

44}
45
46export function assertPathAllowed(filePath: string): void {
47 const allowed = getAllowedPaths();
48 if (!allowed) return;
49 const resolved = path.normalize(path.resolve(expandHome(filePath)));
50 if (!allowed.some((dir) => isWithinDirectory(resolved, dir))) {
51 throw new Error(
52 `Path "${filePath}" is outside the allowed directories. ` +
53 `Set MD_ALLOWED_PATHS to a ${path.delimiter}-separated list that includes a parent directory ` +
54 `(currently allowed: ${allowed.join(path.delimiter)}).`,
55 );
56 }
57}
58
59export function validateUrl(url: string): void {
60 const parsed = new URL(url);

Callers 3

utils.test.tsFile · 0.90
toMarkdownMethod · 0.85
getMethod · 0.85

Calls 3

getAllowedPathsFunction · 0.85
expandHomeFunction · 0.85
isWithinDirectoryFunction · 0.85

Tested by

no test coverage detected