Skip to content

Commit 3002141

Browse files
committed
refactor: inline useClientRoots per transport branch
Remove the intermediate effectiveUseClientRoots variable — just pass `true` in the stdio branch and the flag value in the HTTP branch. https://claude.ai/code/session_014ohk5NMEPe8TBKpqp4ZRSw
1 parent 8a55c2b commit 3002141

1 file changed

Lines changed: 4 additions & 12 deletions

File tree

examples/pdf-server/main.ts

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import {
2222
allowedLocalFiles,
2323
DEFAULT_PDF,
2424
allowedLocalDirs,
25-
type CreateServerOptions,
2625
} from "./server.js";
2726

2827
/**
@@ -152,19 +151,12 @@ async function main() {
152151

153152
console.error(`[pdf-server] Ready (${urls.length} URL(s) configured)`);
154153

155-
// For stdio the client is typically local (e.g. Claude Desktop on the
156-
// same machine), so honouring client roots is safe by default.
157-
// For HTTP the client is remote — roots would expose the server's
158-
// filesystem. Only honour them with an explicit opt-in.
159-
const effectiveUseClientRoots = useClientRoots || stdio;
160-
const serverOpts: CreateServerOptions = {
161-
useClientRoots: effectiveUseClientRoots,
162-
};
163-
164154
if (stdio) {
165-
await startStdioServer(() => createServer(serverOpts));
155+
// stdio → client is local (e.g. Claude Desktop), roots are safe
156+
await startStdioServer(() => createServer({ useClientRoots: true }));
166157
} else {
167-
await startStreamableHTTPServer(() => createServer(serverOpts));
158+
// HTTP → client is remote, only honour roots with explicit opt-in
159+
await startStreamableHTTPServer(() => createServer({ useClientRoots }));
168160
}
169161
}
170162

0 commit comments

Comments
 (0)