modelcontextprotocol/servers · critical · Error

Server cannot operate: No allowed directories available. Ser

Error message

Server cannot operate: No allowed directories available. Server was started without command-line directories and client either does not support MCP roots protocol or provided empty roots. Please either: 1) Start server with directory arguments, or 2) Use a client that supports MCP roots protocol and provides valid root directories.

What it means

Thrown during the filesystem server's post-initialization (`oninitialized`) hook when the client does not advertise the MCP roots capability AND no allowed directories were supplied on the command line. With neither source of allowed directories, the server cannot safely perform any file operation, so it hard-fails. This is a fatal startup error.

Source

Thrown at src/filesystem/index.ts:767

server.server.oninitialized = async () => {
  const clientCapabilities = server.server.getClientCapabilities();

  if (clientCapabilities?.roots) {
    try {
      const response = await server.server.listRoots();
      if (response && 'roots' in response) {
        await updateAllowedDirectoriesFromRoots(response.roots);
      } else {
        console.error("Client returned no roots set, keeping current settings");
      }
    } catch (error) {
      console.error("Failed to request initial roots from client:", error instanceof Error ? error.message : String(error));
    }
  } else {
    if (allowedDirectories.length > 0) {
      console.error("Client does not support MCP Roots, using allowed directories set from server args:", allowedDirectories);
    }else{
      throw new Error(`Server cannot operate: No allowed directories available. Server was started without command-line directories and client either does not support MCP roots protocol or provided empty roots. Please either: 1) Start server with directory arguments, or 2) Use a client that supports MCP roots protocol and provides valid root directories.`);
    }
  }
};

// Start server
async function runServer() {
  const transport = new StdioServerTransport();
  await server.connect(transport);
  console.error("Secure MCP Filesystem Server running on stdio");
  if (allowedDirectories.length === 0) {
    console.error("Started without allowed directories - waiting for client to provide roots via MCP protocol");
  }
}

runServer().catch((error) => {
  console.error("Fatal error running server:", error);
  process.exit(1);
});

View on GitHub (pinned to 76d64c822f)

Solutions

  1. Start the server with explicit allowed directories: `npx @modelcontextprotocol/server-filesystem /path/a /path/b`.
  2. Use a client that advertises `capabilities.roots` and returns valid roots in response to listRoots.
  3. If you intend to rely on roots only, ensure the client actually returns at least one root (non-empty).

Example fix

# before
npx @modelcontextprotocol/server-filesystem
# after
npx @modelcontextprotocol/server-filesystem /home/me/projects /home/me/docs
Defensive patterns

Strategy: validation

Validate before calling

// pre-flight: ensure allowed directories come from somewhere
const hasDirs = process.argv.slice(2).length > 0; // CLI dirs
if (!hasDirs) {
  console.error('Pass allowed directories as CLI args, or use a roots-capable client');
}

Prevention

When it happens

Trigger: Starting the filesystem server with no directory arguments (`npx server-filesystem` with no paths) and connecting a client that does not set `capabilities.roots` in its initialize request — or sets roots to empty.

Common situations: Forgetting to pass allowed directories on the command line, using a minimal client/host that doesn't implement the roots protocol, or a client that returns an empty roots list. The server logs differ: with args present it logs a warning; with neither args nor roots it throws.

Related errors


AI-assisted analysis of modelcontextprotocol/servers@76d64c822f (2026-08-12). Data as JSON: /api/errors/3f81ca4c07ae6ccb. Report an issue: GitHub.