New Tool Radar

AI Concepts

How to Limit an MCP Filesystem Server to One Folder

Restrict an MCP filesystem server to a single folder before connecting it, so the model cannot reach other files.

Schematic illustration of limit an mcp filesystem server to one folder: step one pick the one folder, step two set the allowed root, step three test outside the folder.

An MCP server should only reach the files its task needs. For a filesystem server, that means setting its allowed roots: the folders it may operate in. Set the root to one folder before connecting, and test that a file outside it is refused, so a mistake or a bad instruction cannot reach the rest of the disk.

Prerequisites

  • An MCP filesystem server and its documentation for setting allowed roots.
  • One folder the task needs, and one file outside it for the test.
  • An MCP client or the MCP Inspector.

Steps

Step 1: Pick the one folder

Choose the single folder the task needs, such as a recipe-notes folder. Do not include a parent folder that holds other material.

Step 2: Set the allowed root

Start the server with that folder as its only allowed root, following the server’s own documentation. Save the exact command so the same restriction applies every time the server starts.

Step 3: Test outside the folder

Ask the model to read the test file outside the folder. The expected result is a refusal or an error, not the file’s contents. If the file is read, the root is not applied; stop and fix the configuration.

Worked example: Maple Corner recipe notes

The fictional Maple Corner bakery limits its filesystem server to the recipe-notes folder. The test file is the bakery’s accounts file, outside that folder.

Request Location Expected Result
Read sourdough.txt Inside recipe-notes Contents returned Returned
Read accounts.txt Outside recipe-notes Refused Refused
List parent folder Outside recipe-notes Refused Refused

The file inside the folder is read, and both requests outside it are refused, so the root restriction holds.

Expected result. Files inside the allowed folder are readable and files outside it are refused, with the restriction recorded in the server’s start command. UNTESTED: this guide was not run against a live model or API. The worked example below is fictional practice material, and its result is the expected result, not a measured one.

Limits

  • The exact option for setting roots differs by server; follow that server’s documentation.
  • A root restriction is a server setting, not a guarantee about what the client or model does with files inside the folder.
  • This guide does not cover operating-system file permissions, which are a separate layer.

Sources

See all