MCP Local File Reader
Enables comprehensive local file system operations including searching and reading content from various formats like PDF, Office documents, CSV, and text files. It features automatic character encoding detection and secure path validation for directory access.
README
MCP Local File Reader
A Model Context Protocol (MCP) server that provides comprehensive file system operations with support for multiple document formats. Works with Claude Desktop and other MCP-compatible AI tools.
Features
- 📁 File System Operations: List directories, read files, get file metadata
- 🔍 Search Capabilities: Grep-like content search and file name pattern matching
- 📄 Multi-Format Support:
- PDF text extraction
- Excel (.xlsx, .xls) with sheet listing and per-sheet reading
- Word documents (.docx)
- PowerPoint presentations (.pptx)
- CSV files
- Text files with automatic encoding detection (Shift-JIS/UTF-8)
- 🌐 Character Encoding: Automatic detection and conversion of Shift-JIS and UTF-8
- 🔒 Security: Path validation to prevent access outside designated root directory
Installation
Using npx (Recommended)
No installation needed! Just configure Claude Desktop to use npx:
{
"mcpServers": {
"localfile-reader": {
"command": "npx",
"args": [
"-y",
"github:yryuu/mcp-localfile-all-read"
],
"env": {
"MCP_ROOT_PATH": "/path/to/your/directory"
}
}
}
}
Local Installation
npx github:yryuu/mcp-localfile-all-read
Configuration
Claude Desktop
Edit your Claude Desktop configuration file:
macOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
Add the server configuration:
{
"mcpServers": {
"localfile-reader": {
"command": "npx",
"args": ["-y", "github:yryuu/mcp-localfile-all-read"],
"env": {
"MCP_ROOT_PATH": "/Users/yourname/Documents"
}
}
}
}
Or if installed globally:
{
"mcpServers": {
"localfile-reader": {
"command": "mcp-localfile-reader",
"env": {
"MCP_ROOT_PATH": "/Users/yourname/Documents"
}
}
}
}
Environment Variables
MCP_ROOT_PATH: Root directory for file access (defaults to current working directory)
Windows Example:
{
"env": {
"MCP_ROOT_PATH": "C:\\Users\\YourName\\Documents"
}
}
macOS/Linux Example:
{
"env": {
"MCP_ROOT_PATH": "/Users/yourname/Documents"
}
}
Note: On Windows, use double backslashes (
\\) or forward slashes (/) in paths. See WINDOWS.md for detailed Windows compatibility information.
Available Tools
list_directory
List contents of a directory.
Parameters:
path(string): Relative path from root directory. Use "." for root.
Example:
List the contents of the current directory
read_file
Read file content with automatic format detection.
Parameters:
path(string): Relative path to the file.
Supported formats:
- Text files (.txt, .md, .json, .xml, etc.)
- PDF (.pdf)
- Excel (.xlsx, .xls)
- Word (.docx)
- PowerPoint (.pptx)
- CSV (.csv)
Example:
Read the contents of report.pdf
get_file_info
Get metadata about a file or directory.
Parameters:
path(string): Relative path to the file or directory.
Example:
Get information about data.xlsx
search_content
Search for text patterns in files. Returns a list of file paths that contain the pattern.
Parameters:
path(string): Relative path to search in.pattern(string): Text pattern or regex to search for.max_results(number): Optional. Maximum number of files to return (default: 1000).file_pattern(string, optional): Filter files by name pattern.case_sensitive(boolean, optional): Case sensitive search. Default: false.
Example:
Search for "TODO" in all JavaScript files
find_files
Find files by name pattern.
Parameters:
path(string): Relative path to search in.name_pattern(string): File name pattern or regex.case_sensitive(boolean, optional): Case sensitive search. Default: false.
Example:
Find all PDF files in the current directory
list_excel_sheets
List all sheet names in an Excel file.
Parameters:
path(string): Relative path to the Excel file.
Example:
List all sheets in budget.xlsx
read_excel_sheet
Read a specific sheet from an Excel file.
Parameters:
path(string): Relative path to the Excel file.sheet_name(string): Name of the sheet to read.
Example:
Read the "Sales" sheet from budget.xlsx
Development
Setup
git clone https://github.com/yryuu/mcp-localfile-all-read.git
cd mcp-localfile-all-read
npm install
Build
npm run build
Testing Locally
Use the MCP Inspector to test the server:
npx @modelcontextprotocol/inspector node dist/index.js
Or set the root path:
MCP_ROOT_PATH=/path/to/test/directory npx @modelcontextprotocol/inspector node dist/index.js
Usage Examples
With Claude Desktop
After configuration, you can ask Claude:
- "List all files in the current directory"
- "Read the contents of report.pdf"
- "Search for 'error' in all log files"
- "Find all Excel files"
- "List the sheets in budget.xlsx and read the Sales sheet"
- "Read the Word document proposal.docx"
Programmatic Usage
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
// The server runs on stdio transport
// See src/index.ts for implementation details
File Format Support Details
- Extracts all text content from PDF files
- Handles multi-page documents
- Uses
pdf-parselibrary
Excel
- Supports .xlsx and .xls formats
- List all sheet names
- Read specific sheets or all sheets
- Returns data as JSON arrays
Word
- Supports .docx format
- Extracts plain text content
- Uses
mammothlibrary
PowerPoint
- Supports .pptx format
- Extracts text from all slides
- Returns slide-by-slide content
CSV
- Automatic delimiter detection
- Character encoding detection (Shift-JIS/UTF-8)
- Returns structured JSON data
Text Files
- Automatic character encoding detection
- Supports Shift-JIS and UTF-8
- Handles various text-based formats
Security
- Path validation prevents access outside the configured root directory
- All paths are resolved and validated before file operations
- Error handling for permission issues and invalid paths
License
MIT
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Author
yryuu
Repository
https://github.com/yryuu/mcp-localfile-all-read
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。