{"record":{"id":"3f81ca4c07ae6ccb","repo":"modelcontextprotocol/servers","slug":"server-cannot-operate-no-allowed-directories-avai","errorCode":null,"errorMessage":"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.","messagePattern":"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\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"critical","filePath":"src/filesystem/index.ts","lineNumber":767,"sourceCode":"server.server.oninitialized = async () => {\n  const clientCapabilities = server.server.getClientCapabilities();\n\n  if (clientCapabilities?.roots) {\n    try {\n      const response = await server.server.listRoots();\n      if (response && 'roots' in response) {\n        await updateAllowedDirectoriesFromRoots(response.roots);\n      } else {\n        console.error(\"Client returned no roots set, keeping current settings\");\n      }\n    } catch (error) {\n      console.error(\"Failed to request initial roots from client:\", error instanceof Error ? error.message : String(error));\n    }\n  } else {\n    if (allowedDirectories.length > 0) {\n      console.error(\"Client does not support MCP Roots, using allowed directories set from server args:\", allowedDirectories);\n    }else{\n      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.`);\n    }\n  }\n};\n\n// Start server\nasync function runServer() {\n  const transport = new StdioServerTransport();\n  await server.connect(transport);\n  console.error(\"Secure MCP Filesystem Server running on stdio\");\n  if (allowedDirectories.length === 0) {\n    console.error(\"Started without allowed directories - waiting for client to provide roots via MCP protocol\");\n  }\n}\n\nrunServer().catch((error) => {\n  console.error(\"Fatal error running server:\", error);\n  process.exit(1);\n});","sourceCodeStart":749,"sourceCodeEnd":785,"githubUrl":"https://github.com/modelcontextprotocol/servers/blob/76d64c822f5125032f89eb71dbdb94e42b434821/src/filesystem/index.ts#L749-L785","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Start the server with explicit allowed directories: `npx @modelcontextprotocol/server-filesystem /path/a /path/b`.","Use a client that advertises `capabilities.roots` and returns valid roots in response to listRoots.","If you intend to rely on roots only, ensure the client actually returns at least one root (non-empty)."],"exampleFix":"# before\nnpx @modelcontextprotocol/server-filesystem\n# after\nnpx @modelcontextprotocol/server-filesystem /home/me/projects /home/me/docs","handlingStrategy":"validation","validationCode":"// pre-flight: ensure allowed directories come from somewhere\nconst hasDirs = process.argv.slice(2).length > 0; // CLI dirs\nif (!hasDirs) {\n  console.error('Pass allowed directories as CLI args, or use a roots-capable client');\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass at least one directory as a CLI argument.","Use a client that advertises capabilities.roots and returns non-empty roots.","Treat absence of both sources as a misconfiguration, not a soft warning."],"tags":["mcp","typescript","filesystem-server","startup","roots","configuration","security"],"backgroundTag":null,"analyzedSha":"76d64c822f5125032f89eb71dbdb94e42b434821","analyzedAt":"2026-08-12T10:02:41.718Z","schemaVersion":2},"datasetVersion":"2026-08-12T13:17:24.610Z"}