Skip to main content
RapidDev - Software Development Agency
mcp-tutorial

How to use the Filesystem MCP server

The Filesystem MCP server lets your AI assistant read, write, search, and manage files on your local machine within directories you explicitly allow. Install it with a single npx command, add a JSON config block to Claude Desktop or Cursor, and your AI can instantly navigate your project files, create new ones, and perform bulk search-and-replace operations — all without leaving the chat.

What you'll learn

  • How to install and configure the Filesystem MCP server
  • How to restrict file access to specific directories for safety
  • How to read, write, search, and manage files through your AI assistant
  • How to set up the server in Claude Desktop, Cursor, and VS Code
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner7 min read10 minutesClaude Desktop, Cursor, Windsurf, VS Code (Copilot)March 2026RapidDev Engineering Team
TL;DR

The Filesystem MCP server lets your AI assistant read, write, search, and manage files on your local machine within directories you explicitly allow. Install it with a single npx command, add a JSON config block to Claude Desktop or Cursor, and your AI can instantly navigate your project files, create new ones, and perform bulk search-and-replace operations — all without leaving the chat.

Give Your AI Assistant Safe Access to Local Files

The @modelcontextprotocol/server-filesystem is one of the most popular MCP servers in the ecosystem. It exposes your local filesystem to AI assistants through a controlled set of tools — read_file, write_file, list_directory, search_files, move_file, and more. Critically, you define exactly which directories the server can access, so your AI cannot wander into sensitive areas like your home directory root or system files. This makes it ideal for letting Claude or Cursor work directly with your project files, configuration, and documentation.

Prerequisites

  • Node.js 18 or later installed on your machine
  • Claude Desktop, Cursor, or another MCP-compatible AI host
  • A project directory you want your AI to access
  • Basic familiarity with JSON configuration files

Step-by-step guide

1

Locate your MCP configuration file

Every MCP host stores its server configuration in a specific JSON file. For Claude Desktop on macOS, open ~/Library/Application Support/Claude/claude_desktop_config.json. For Claude Desktop on Windows, open %APPDATA%\Claude\claude_desktop_config.json. For Cursor, open Settings > Features > MCP Servers, or edit ~/.cursor/mcp.json directly. For VS Code with GitHub Copilot, open your settings.json or .vscode/mcp.json in your workspace. Create the file if it does not exist yet.

typescript
1# macOS Claude Desktop config location:
2~/Library/Application Support/Claude/claude_desktop_config.json
3
4# Cursor config location:
5~/.cursor/mcp.json
6
7# VS Code workspace config:
8.vscode/mcp.json

Expected result: You have identified or created the JSON configuration file for your MCP host.

2

Add the Filesystem server to your configuration

Add a new entry inside the mcpServers object (or servers for VS Code). The command is npx with the -y flag so it auto-confirms installation. The last argument is the directory path you want the AI to access. You can list multiple directories by adding more path arguments. Only the directories you list will be accessible — everything else is blocked by default.

typescript
1{
2 "mcpServers": {
3 "filesystem": {
4 "command": "npx",
5 "args": [
6 "-y",
7 "@modelcontextprotocol/server-filesystem",
8 "/Users/me/Projects"
9 ]
10 }
11 }
12}

Expected result: Your configuration file contains the filesystem server entry with your chosen directory path.

3

Restart your AI host to activate the server

MCP servers are started when your AI host launches. After saving the configuration file, fully quit and reopen Claude Desktop, Cursor, or VS Code. In Claude Desktop, you should see a small hammer icon in the chat input area indicating that MCP tools are available. In Cursor, check Settings > Features > MCP Servers to confirm the filesystem server shows a green status.

Expected result: The filesystem MCP server appears as connected in your AI host, and its tools are listed as available.

4

Test reading a file from your project

Send a prompt asking your AI to read a specific file from your allowed directory. The AI will call the read_file tool behind the scenes and return the contents. This confirms the server is working and has access to the directory you configured.

typescript
1Example prompt:
2"Read the contents of /Users/me/Projects/my-app/package.json and summarize the dependencies."

Expected result: The AI displays the contents of the requested file and provides a summary, confirming the filesystem server is active and authorized.

5

Try writing, searching, and listing files

The Filesystem server exposes several tools beyond read_file. Use write_file to create or overwrite files, search_files to find text patterns across your project, list_directory to see folder contents, create_directory to make new folders, move_file to rename or relocate files, and get_file_info for metadata like size and modification date. Each tool operates only within your allowed directories.

typescript
1Example prompts:
2
3"List all files in /Users/me/Projects/my-app/src"
4
5"Search for all occurrences of TODO in my project directory"
6
7"Create a new file at /Users/me/Projects/my-app/src/utils/helpers.ts with a function that formats dates"

Expected result: The AI successfully performs file operations within your allowed directories and returns the results.

6

Configure VS Code with the servers key format

If you use VS Code with GitHub Copilot, the configuration key is servers instead of mcpServers. Create a .vscode/mcp.json file in your workspace root with the correct format. This gives Copilot access to your project files through the same Filesystem MCP server.

typescript
1{
2 "servers": {
3 "filesystem": {
4 "command": "npx",
5 "args": [
6 "-y",
7 "@modelcontextprotocol/server-filesystem",
8 "/Users/me/Projects/my-app"
9 ]
10 }
11 }
12}

Expected result: VS Code recognizes the MCP server and Copilot can access files in the configured directory.

Complete working example

claude_desktop_config.json
1{
2 "mcpServers": {
3 "filesystem": {
4 "command": "npx",
5 "args": [
6 "-y",
7 "@modelcontextprotocol/server-filesystem",
8 "/Users/me/Projects",
9 "/Users/me/Documents/notes"
10 ]
11 }
12 }
13}
14
15// VS Code variant (.vscode/mcp.json):
16// {
17// "servers": {
18// "filesystem": {
19// "command": "npx",
20// "args": [
21// "-y",
22// "@modelcontextprotocol/server-filesystem",
23// "${workspaceFolder}"
24// ]
25// }
26// }
27// }
28
29// Available tools:
30// - read_file: Read complete file contents
31// - read_multiple_files: Read several files at once
32// - write_file: Create or overwrite a file
33// - edit_file: Make selective edits with pattern matching
34// - list_directory: List files and subdirectories
35// - create_directory: Create new directories
36// - move_file: Move or rename files
37// - search_files: Regex search across files
38// - get_file_info: Get file metadata (size, dates)
39// - list_allowed_directories: Show which paths are accessible

Common mistakes when using the Filesystem MCP server

Why it's a problem: Allowing the home directory root (/ or ~/) as the accessible path

How to avoid: Always scope access to specific project directories. Use paths like /Users/me/Projects/my-app rather than / or /Users/me to follow the principle of least privilege.

Why it's a problem: Forgetting to restart the AI host after changing the config

How to avoid: MCP servers are loaded at startup. You must fully quit and reopen Claude Desktop, Cursor, or VS Code for config changes to take effect.

Why it's a problem: Using a relative path in the args array

How to avoid: Always use absolute paths like /Users/me/Projects. Relative paths like ./Projects will fail because the server does not know the working directory context.

Why it's a problem: Omitting the -y flag from the npx command

How to avoid: Without -y, npx will prompt for confirmation to install the package, which hangs the MCP server startup since there is no interactive terminal.

Best practices

  • Limit allowed directories to only the project folders your AI needs to access
  • Use read-only workflows when possible — ask the AI to show changes before writing
  • Add multiple specific directories rather than one broad parent directory
  • Review file write operations before confirming them in Claude Desktop's approval dialog
  • Use search_files to find patterns across your codebase before making bulk edits
  • Keep your @modelcontextprotocol/server-filesystem package updated for security patches
  • Combine with a Git MCP server so the AI can commit changes it makes to files
  • Test with a sample directory first before pointing at production code

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I want to set up the Filesystem MCP server so my AI coding assistant can read and write files in my project directory. My project is at /Users/me/Projects/my-app and I use Claude Desktop on macOS. Give me the exact config JSON and explain each tool the server provides.

MCP Prompt

Read the file at /Users/me/Projects/my-app/src/App.tsx, then search for all files importing React Router in the src directory, and give me a summary of the routing structure.

Frequently asked questions

Can the Filesystem MCP server access files outside the directories I specify?

No. The server strictly enforces the directory allowlist you configure in the args array. Any attempt to read or write files outside those directories will be rejected with a permission error. This is a core security feature of the server.

Does the Filesystem server work on Windows?

Yes. Use Windows-style paths in the args array, such as C:\\Users\\me\\Projects. The server handles path normalization across operating systems. Make sure to use double backslashes in JSON strings.

How do I allow access to multiple directories?

Add each directory as a separate argument after the package name in the args array. For example: ["-y", "@modelcontextprotocol/server-filesystem", "/path/one", "/path/two", "/path/three"]. Each path gets its own string entry.

Will the AI automatically write files without asking me?

In Claude Desktop, all tool calls require your approval before executing. You will see a confirmation dialog showing what the AI wants to do. In Cursor and other hosts, behavior depends on the host's permission settings — check your host's MCP configuration for auto-approve options.

Can I use this server for production deployments?

The Filesystem MCP server is designed for local development use. For production file operations, consider using dedicated services or APIs. If your project requires AI-managed file operations at scale, RapidDev can help architect a secure server-side solution.

What happens if the file I ask the AI to read is very large?

The server will read the entire file contents. For very large files (over 1MB), this can consume significant context window space. Ask the AI to read specific sections or use search_files to find relevant lines instead of reading the whole file.

Do I need to install the package globally first?

No. The npx -y command downloads and runs the package on demand. It is cached locally after the first run, so subsequent startups are faster. You do not need to run npm install separately.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.