@gabrielmaialva33/mcp-filesystem
Version:
MCP server for secure filesystem access
49 lines • 1.49 kB
JavaScript
export class FileSystemError extends Error {
code;
path;
metadata;
constructor(message, code, path, metadata) {
super(message);
this.code = code;
this.path = path;
this.metadata = metadata;
this.name = 'FileSystemError';
}
toJSON() {
return {
name: this.name,
code: this.code,
message: this.message,
path: this.path,
...this.metadata,
};
}
}
export class AccessDeniedError extends FileSystemError {
constructor(path, message) {
super(message || `Access denied - path outside allowed directories: ${path}`, 'ACCESS_DENIED', path);
this.name = 'AccessDeniedError';
}
}
export class PathNotFoundError extends FileSystemError {
constructor(path) {
super(`Path not found: ${path}`, 'PATH_NOT_FOUND', path);
this.name = 'PathNotFoundError';
}
}
export class InvalidArgumentsError extends FileSystemError {
constructor(toolName, details) {
super(`Invalid arguments for ${toolName}`, 'INVALID_ARGS', undefined, { details });
this.name = 'InvalidArgumentsError';
}
}
export class FileSizeError extends FileSystemError {
constructor(path, size, maxSize) {
super(`File size exceeds limit: ${size} > ${maxSize} bytes`, 'FILE_SIZE_EXCEEDED', path, {
size,
maxSize,
});
this.name = 'FileSizeError';
}
}
//# sourceMappingURL=index.js.map