Skip to content

Commit 1668951

Browse files
committed
fix(pdf-server): add debug logging for rejected files, ignore .jsonl logs
1 parent 1881c57 commit 1668951

3 files changed

Lines changed: 8 additions & 3 deletions

File tree

examples/pdf-server/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
dist/
2+
*.jsonl

examples/pdf-server/.mcpbignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ src/
77
# Tests
88
*.test.*
99

10+
# Debug logs
11+
*.jsonl
12+
1013
# Development assets
1114
screenshot.png
1215
grid-cell.png

examples/pdf-server/server.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,7 @@ export function normalizeArxivUrl(url: string): string {
8282

8383
export function fileUrlToPath(fileUrl: string): string {
8484
// Support both file:// and computer:// (used by some clients for local files)
85-
return decodeURIComponent(
86-
fileUrl.replace(/^(?:file|computer):\/\//, ""),
87-
);
85+
return decodeURIComponent(fileUrl.replace(/^(?:file|computer):\/\//, ""));
8886
}
8987

9088
export function pathToFileUrl(filePath: string): string {
@@ -118,6 +116,9 @@ export function validateUrl(url: string): { valid: boolean; error?: string } {
118116
);
119117

120118
if (!exactMatch && !dirMatch) {
119+
console.error(
120+
`[pdf-server] validateUrl REJECTED: url=${url}\n filePath=${filePath}\n resolved=${resolved}\n allowedDirs=${JSON.stringify([...allowedLocalDirs])}\n dirChecks=${JSON.stringify([...allowedLocalDirs].map((d) => ({ dir: d, rel: path.relative(d, resolved), match: isAncestorDir(d, resolved) })))}`,
121+
);
121122
return {
122123
valid: false,
123124
error: `Local file not in allowed list: \n${resolved}\nAllowed files: ${[...allowedLocalFiles].join(", ")}\nAllowed directories:\n${[...allowedLocalDirs].join("\n")}`,

0 commit comments

Comments
 (0)