MCP ConfigsMar 29, 2026·2 min read

Filesystem MCP Server — File Operations for AI

Official MCP server for safe filesystem operations. Read, write, search, and manage files and directories with configurable access controls. Essential for any AI coding workflow.

TL;DR
Filesystem MCP gives AI agents controlled read/write access to files and directories through the Model Context Protocol.
§01

What it is

Filesystem MCP Server is the official Model Context Protocol server for file system operations. It gives AI agents the ability to read, write, search, and manage files and directories. Access is controlled by specifying allowed directories in the configuration, preventing the agent from accessing files outside designated paths.

This server is essential for any AI coding workflow where the agent needs to interact with project files. It provides a structured, safe interface for file operations rather than unrestricted shell access.

§02

How it saves time or tokens

Without the Filesystem MCP server, agents rely on shell commands for file operations, which lack access controls and structured error handling. This server provides typed tool calls for reading, writing, searching, and listing files, with built-in path validation. The workflow gives you the MCP configuration JSON ready to paste.

§03

How to use

  1. Add the Filesystem MCP server to your .mcp.json:
{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/path/to/allowed/dir"
      ]
    }
  }
}
  1. Restart your MCP-compatible client.
  1. The agent can now perform file operations within the allowed directory:
'Read the contents of src/index.ts'
'Create a new file at src/utils/helpers.ts'
'Search for all files containing TODO'
'List the directory structure of src/'
§04

Example

{
  "mcpServers": {
    "filesystem": {
      "command": "npx",
      "args": [
        "-y",
        "@modelcontextprotocol/server-filesystem",
        "/Users/dev/projects/my-app",
        "/Users/dev/projects/shared-libs"
      ]
    }
  }
}

Multiple directories can be specified as separate arguments. The agent can access files in any of the listed directories but nowhere else.

§05

Related on TokRepo

§06

Common pitfalls

  • Forgetting to include a directory in the args list means the agent cannot access it, even if it is a subdirectory of an allowed path. List all needed directories explicitly.
  • The server validates paths on every operation. Symlinks that point outside allowed directories are blocked.
  • File write operations overwrite existing content by default. The agent should read a file before writing to avoid data loss.

Frequently Asked Questions

What operations does the Filesystem MCP server support?+

It supports reading files, writing files, creating directories, listing directory contents, moving/renaming files, searching file contents by pattern, and getting file metadata (size, modification time, permissions).

How does access control work?+

You specify allowed directories as command-line arguments when configuring the server. The server validates every file path against these directories and rejects operations that target files outside the allowed paths.

Can I give the agent read-only access?+

The server does not have a built-in read-only mode. To restrict write access, you can use operating system file permissions on the allowed directories. The server respects OS-level permissions.

Does this work with any AI agent?+

It works with any MCP-compatible client including Claude Code, Cursor, and other tools that implement the Model Context Protocol standard.

Can I allow access to my entire home directory?+

Technically yes, but it is not recommended. Restricting access to specific project directories limits the blast radius of any unintended file operations. Grant access only to directories the agent needs.

Citations (3)
🙏

Source & Thanks

Created by Anthropic. Licensed under MIT. modelcontextprotocol/servers — Official MCP reference servers.

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.