让 Claude 直接读写本地文件,用于代码分析、文档编辑和数据处理。

适用场景

Developers and analysts who want Claude to work directly with local files without copy-pasting.

前提条件

Node.js 18+, Claude Desktop or Claude API access, MCP server package

工作流图

用 MCP 连接 Claude 到本地文件系统

Install MCP File Server
Configure Claude Desktop
Test File Access
Practical: Codebase Analysis
Practical: Batch Document Processing

分步指南

  1. 1

    Install MCP File Server

    Run: npx @modelcontextprotocol/server-filesystem /path/to/allowed/directory. This creates an MCP server that only has access to the specified directory. Never grant access to your entire home directory.

  2. 2

    Configure Claude Desktop

    Edit Claude Desktop config file (claude_desktop_config.json). Add a new MCP server entry with the command and allowed directories. Restart Claude Desktop to load the new server.

  3. 3

    Test File Access

    In Claude, ask: 'List all files in the project directory.' Claude should use the MCP server to list files. Then try: 'Read the main.py file and explain its architecture.' Verify Claude can read but cannot write outside allowed paths.

  4. 4

    Practical: Codebase Analysis

    Ask Claude to: 'Analyze the entire codebase, identify all API endpoints, and generate documentation.' Claude will read multiple files, understand the architecture, and produce comprehensive docs. This saves 2-4 hours of manual work.

  5. 5

    Practical: Batch Document Processing

    Place 10-20 documents in the allowed directory. Ask Claude to: 'Read all documents, extract key metrics into a CSV, and identify common themes.' Claude processes all files through MCP and returns structured output.

标签

#mcp#claude#file-system#code-analysis