INNER CODE UNIT · TypeScript
validateProjectDir
google/clasp · src/mcp/server.ts:40
function validateProjectDir(projectDir: string): string | null {
const resolved = path.resolve(projectDir);
const allowedBases = [os.homedir(), process.cwd()];
const isAllowed = allowedBases.some(base => resolved === base || isInside(base, resolved));
if (!isAllowed) {
return (
`Security Error: projectDir must be within the user home directory or ` +
`current working directory. Resolved path "${resolved}" is not permitted.`
);
}
return null;
}
/**
* Builds and configures an MCP (Model Context Protocol) server with tools
* for interacting with Google Apps Script projects via clasp functionalities.
*
* The server exposes tools such as: