# MCP Filesystem Server for Local Coding Agents

> Give Claude Desktop or any MCP client safe, scoped access to a project directory so an agent can read, edit, and run tests without you copy-pasting.

**Platform:** MCP  
**Category:** mcp-servers  
**Difficulty:** Intermediate  
**Tags:** mcp, claude, coding, agents  
**Updated:** 2025-05-28  
**Source:** https://promptfoo.tech/workflows/mcp-filesystem-server-for-coding

## Overview
Model Context Protocol (MCP) lets local AI clients call tools. The official filesystem server is the fastest way to give an assistant real read/write access to a repo, without exposing the rest of your machine. This guide covers installation, safe scoping, and a review-first workflow.

## How it works
1. Install the MCP filesystem server via npm or a prebuilt binary.
2. Configure your MCP client with a list of allowed directories.
3. The client (Claude Desktop, Cursor, etc.) sees new tools: read_file, write_file, list_directory, search_files.
4. You approve tool calls per session or per call, depending on client policy.

## Benefits
- No more paste-the-file-then-paste-the-diff dance.
- Scoped by directory — the model can only touch what you allow.
- Works across any MCP-compatible client, not just one vendor.

## Use cases
- Refactoring a module with an assistant that can actually see it.
- Generating tests from source files without copy-paste.
- Automated code review of a diff before you commit.

## Step-by-step
### Step 1: Install the server
Run: npx -y @modelcontextprotocol/server-filesystem <allowed-dir>. Verify it starts and prints tool schemas.

### Step 2: Configure Claude Desktop
Edit claude_desktop_config.json and add the server under mcpServers with the args array pointing at your project.

### Step 3: Scope tightly
Never point the server at your home directory. Use one project root, ideally a git worktree so you can diff its output.

### Step 4: Set an approval policy
Start with per-call approval. Once you trust the workflow, move to per-session for read tools only; keep write tools per-call.

### Step 5: Add a review gate
After any write batch, ask the assistant to summarize changes and run git diff before you commit.

## FAQs
**Is this safe to run against my whole machine?**

No. Always scope to a specific project directory. The server enforces the allow-list but you set it.

**Does it work in a browser client?**

MCP is designed for local clients. Browser assistants generally need a hosted equivalent or a bridge.

**Can I add my own tools?**

Yes — write your own MCP server. The filesystem server is one of many reference implementations.

---
Licensed under CC-BY-4.0. Attribution: PromptFoo.tech