
FileSystem MCP Server
io.github.Oncorporation由 GitHub 账号 Oncorporation 发布v0.1.4更新于 Oct 24, 2026
Secure filesystem access for AI agents with configurable directory and file type restrictions
概览
本地 MCP 服务器,让 AI 助手在限定目录和文件类型范围内读取项目文件,并可选择开启写入功能。
- 可以做什么
- 列出目录与资源,支持进度报告和分批返回
- 读取文本文件,或以 base64 读取二进制文件
- 查看文件或目录的元数据与可用操作
- 通过 init 检查校验已配置目录和配置来源
- 仅在显式开启写入后写入文本或二进制文件
- 适用场景
- 适合在 Visual Studio 2022+ 等本地开发环境中,让助手读取和浏览单个项目目录,而无需多根工作区。也适合需要把文件系统访问严格限制在指定目录和扩展名的场景。
- 运行要求
- 以 Python 包形式通过 stdio 在本机运行(从源码安装需 Python 3.10+)。需要配置允许的目录和允许的文件扩展名,可通过命令行参数或放在 MCP 配置文件旁的 config.json 提供。未声明账号、API 密钥或环境变量。
安装
在 SourceWeft 中
- 打开 控制台中的 FileSystem MCP Server,将其添加到工作区。
- 为需要使用其工具的对话启用该服务。
Desktop only,通过 STDIO。 STDIO 服务会启动本地进程,因此需要 SourceWeft 桌面宿主。
其他 MCP 客户端
参照 仓库 中的启动说明。
README
FileSystem MCP Server
Version: 0.1.4 — Last updated: 2026-10-13
Local MCP server for Visual Studio 2022+ that provides code-workspace functionality by giving AI agents selective access to project folders and files
Table of Contents
- 🎯 Target Environment
- Features
- Installation
- Quick Start
- Configuration Options
- Usage
- Why This Hybrid Approach is Perfect
- Visual Studio 2022+ Debugging
- Visual Studio 2022+ Usage Examples
- Editing Your mcp.json File via GitHub Copilot Chat
- Security
- Error Handling
- Troubleshooting
- Command Line Reference
- Cross-Platform Path Support
- Advanced & Real-World MCP Configuration Examples
🎯 Target Environment
This MCP server is optimized for:
- Visual Studio 2022+ development workflows
- Local development environments without complex workspace setups
- Direct folder access scenarios where you need filesystem operations
- Development environments that don't use
.code-workspacefiles - Individual project directories rather than multi-root workspaces
Features
- Directory Traversal: List contents of allowed directories
- File Reading: Read contents of files with allowed extensions
- File Writing: Write text/binary content to files — opt-in via
--allow-write(disabled by default) - Directory Validation: Check accessibility of configured directories
- Hybrid Configuration: Command-line arguments (MCP) + config.json fallback (debugging)
- Visual Studio 2022+ Debugging: No-argument startup support
- Cross-Platform Path Support: Automatically handles both Windows (
\) and Unix (/) path separators - Security: Access restricted to explicitly specified directories and file types
- Local Development Focus: Perfect for Visual Studio 2022+ and similar environments
Installation
From PyPI (Recommended for Users)
From Source (For Development)
-
Ensure you have Python 3.10+ installed
-
Clone the repository
-
Navigate to the project directory
-
Install dependencies using uv:
Quick Start
- For MCP usage: Add the corrected configuration to your
.mcp.json - For debugging: Just press F5 in Visual Studio 2022+ - uses config.json automatically
- Test your configuration by calling the
init()tool first - If init() returns errors, check your directory paths and permissions
Configuration Options
Option 1: Config.json File (Simplest - Recommended for Beginners)
The easiest way to get started! Create a config.json file:
For MCP server usage:
- Place
config.jsonin the same folder as your.mcp.jsonfile (usuallyC:\Users\YourUsername\)
For debugging from source (Visual Studio 2022+):
- Place
config.jsonin the same directory asapp.py(D:/Projects/filesystem_server/)
Note: Set
"allow_write": trueto enablewrite_fileandwrite_file_binarytools.
MCP Configuration (Installed via pip)
Add this to your .mcp.json file (usually C:\Users\YourUsername\ in VS 2022+):
Note: When installed via pip, the command is just vs-filesystem-mcp-server - no path to app.py needed!
MCP Configuration (Running from Source)
If you're developing and running from source code:
Benefits:
- ✅ No command-line arguments needed
- ✅ Perfect for Visual Studio 2022 debugging (just press F5)
- ✅ Works with MCP clients when placed in correct location
- ✅ Easy to edit and modify
- ✅ Great for testing and development
Usage:
Important Location Notes:
- 🔧 Debugging:
config.jsongoes next toapp.py - 🌐 MCP Server:
config.jsongoes next to.mcp.json - 📁 Different locations for different use cases!
Option 2: Command-Line Arguments (Advanced - For MCP Clients)
Best for production MCP client configurations where you want everything in one place:
When Installed via pip
When Running from Source
MCP Client Configuration (.mcp.json):
Benefits:
- ✅ Self-contained configuration
- ✅ No external config files needed
- ✅ Version control friendly
- ✅ Explicit and visible in MCP setup
Option 3: Hybrid Approach (Best of Both Worlds)
The server automatically uses command-line arguments first, then falls back to config.json if no arguments provided.
How it works:
- MCP clients: Use command-line arguments (Option 2)
- Visual Studio debugging: Automatically uses config.json (Option 1)
- Priority: Command-line args override config.json when present
Benefits:
- ✅ Works for both MCP clients and debugging
- ✅ No conflicts between different usage scenarios
- ✅ Flexible and developer-friendly
- ✅ Choose the best option for each situation
Usage
Command Line Examples
Available Tools
-
init(directory, file_path)- Validates accessibility of configured directories and can optionally list a directory and/or read a filedirectory(optional): Directory path to list contents (can beNone)file_path(optional): File path to read content (can beNone)- Returns
{ "message": "OK", "isError": false, ... }if all directories accessible - Returns error details if any directories are inaccessible
- Shows configuration source (command-line args vs config file)
- Use this to verify your configuration before using other tools
-
list_directory(directory, report_progress=True, batch_size=100)- Lists files and subdirectories in a given directory, with optional progress reportingdirectory: The absolute or relative path to the directory (supports both / and \ separators)report_progress(optional): If True, returns progress information and batch details (default: True)batch_size(optional): Number of items to process before reporting progress (default: 100)- Returns a list of file and directory names if
report_progressis False - Returns a dictionary with contents, progress_info, total_items, and processing_time if
report_progressis True - If an error occurs, returns a dictionary with
"error"and"error_message"keys - No exceptions are raised - all errors are returned as part of the result
-
read_file(file_path)- Reads the content of a specified file as text- Returns the file content as a string (for text files only)
- Not suitable for binary files (images, audio, etc.)
-
read_file_binary(file_path)- Reads the content of a specified file as base64-encoded binary- Returns
{ "content_base64": <base64 string>, "encoding": "base64", "error": False }on success - Returns an error dict if the file is not allowed or not found
- Suitable for images, audio, and other binary files
- Returns
-
list_resources(directory=None, report_progress=True, batch_size=100)- Lists all resources (files and directories) in a directory (or all allowed directories) in MCP resource formatdirectory(optional): Directory to start from (defaults to all allowed_dirs)report_progress(optional): If True, returns progress information and batches (default: True)batch_size(optional): Number of resources per progress batch (default: 100)- Returns a list of resource objects if
report_progressis False - Returns a dictionary with contents, progress_info, total_items, and processing_time if
report_progressis True - Example resource object:
-
get_resource(path)- Gets metadata and actions for a specific file or directorypath: Absolute or relative path to the resource- Returns a resource object (id, type, name, path, metadata, actions) or an error dict
- For files, includes size and modified time; for directories, includes type and actions
- Does not return file content
-
write_file(file_path, content)- Writes text content to a specified file (requires--allow-write)file_path: Path to write to (must be within allowed dirs)content: Text string to write- Raises
ValueErrorif write access is disabled, path not allowed, extension not allowed, or IO error - Overwrites existing file
- Disabled by default — enable with
--allow-writeflag or"allow_write": truein config.json
-
write_file_binary(file_path, content_base64)- Writes binary content from base64 to file (requires--allow-write)file_path: Path to write to (must be within allowed dirs)content_base64: Base64-encoded binary data- Returns
{"success": true, "bytes_written": int, "error": false}or error dict - Overwrites existing file, suitable for images/binaries
- Disabled by default — enable with
--allow-writeflag or"allow_write": truein config.json
Why This Hybrid Approach is Perfect
- ✅ MCP clients: Use efficient command-line arguments
- ✅ Visual Studio 2022: Zero-friction debugging with config.json fallback
- ✅ No conflicts: Priority system handles both scenarios gracefully
- ✅ Developer-friendly: Works however you want to run it
- ✅ Best of both worlds: MCP efficiency + debugging convenience
Visual Studio 2022+ Debugging
Perfect debugging experience:
- ✅ No command-line arguments needed
- ✅ Just press F5 to start debugging
- ✅ Automatically uses config.json
- ✅ Set breakpoints and debug normally
- ✅ Full IntelliSense and debugging support
Debugging setup:
- Open the project in Visual Studio 2022
- Ensure
config.jsonexists (already created for you) - Press F5 or Debug > Start Debugging
- Server starts with your configured directories
Visual Studio 2022+ Usage Examples
Below are step-by-step examples showing how to call the FileSystem MCP Server from within Visual Studio 2022. These screenshots demonstrate the process using the alias "fss" for the server, which is simply a shorter name for "filesystem-server". You can customize this alias in your .mcp.json file—the actual name is up to you.
Note: All images are located in the
images/subfolder.
Step 1: Calling the Server Tool
[Step 1: Example of calling the tool in Visual Studio 2022]
In this example, the MCP client is configured to use "fss" as the server name. This is just an alias for convenience.
Step 2: Viewing the Server Response
[Step 2: Example of viewing the server response in Visual Studio 2022]
The server responds with the results of your request, such as the output from the read_file() tool.
Note:
- The
"fss"alias is used here for brevity. You can use any name you prefer in your.mcp.jsonconfiguration.- To change the server name, simply update the key in your
.mcp.jsonfile from"filesystem-server"to any other name you like.
For more details on configuring your MCP client, see the Configuration Options section above.
Editing Your mcp.json File via GitHub Copilot Chat
You can easily edit your mcp.json configuration file directly from Visual Studio using the GitHub Copilot Chat interface. Follow these steps:
- Click the Tools icon on the right side of Visual Studio, while in Agent mode.
- Click the arrow next to any MCP server in the list.
- Choose Edit – the
mcp.jsonfile will open for editing.
[How to edit mcp.json using GitHub Copilot Chat]
This allows you to quickly update your MCP server configuration without leaving the IDE.
Security
- Only directories specified in
--allowed-dirsor config.json can be accessed - Only files with extensions in
--allowed-extensionsor config.json can be read or written - Write access disabled by default:
write_fileandwrite_file_binaryrequire--allow-writeflag or"allow_write": truein config.json - All paths are validated before access
- The server runs with the permissions of the user account
- Perfect for local development: Secure access to your project directories
Error Handling
The server provides detailed error messages for:
- Unauthorized directory access
- Invalid file paths
- Unsupported file extensions
- Missing configuration (shows helpful guidance for both MCP and debugging scenarios)
- Directory accessibility issues (via
init()tool)
New Error Handling for list_directory():
- The
list_directory()function now returns errors as part of the result list instead of raising exceptions - Error format:
["error", "detailed_error_message"] - This makes it easier for MCP clients to handle errors gracefully without exception handling
- Successful calls return the normal list of directory contents
Troubleshooting
MCP Configuration Issues
Your original config had a missing comma after "D:/Webs". The corrected version above fixes this.
Visual Studio 2022+ Debugging
- Ensure config.json exists (already created for your directories)
- Start with the
init()tool to validate your configuration - Set breakpoints and debug normally
- Check output window for configuration source confirmation
Common Issues
- Missing configuration: The server shows helpful messages for both MCP and debugging scenarios
- Path access errors: Verify your directories exist and are accessible
- Permission issues: Check directory permissions on your configured paths
- MCP client issues: Use the corrected configuration above
Command Line Reference
Cross-Platform Path Support
The filesystem server automatically normalizes paths to handle different operating system conventions:
✅ Windows Users - Both Formats Work
✅ Automatic Path Normalization
- Input:
"F:\sd\wipes"(Windows natural format) - Normalized:
"F:/sd/wipes"(Python-friendly format) - Result: ✅ Works seamlessly, no errors!
✅ MCP Tool Examples
Why This Matters
- 🪟 Windows users can naturally type
F:\sd\wipes - 🐧 Unix users can use traditional
F:/sd/wipes - 🔧 No more path format errors - everything just works
- 🛡️ Security checks work correctly regardless of separator style
Advanced & Real-World MCP Configuration Examples
For more advanced, platform-specific, or legacy MCP client configuration examples (including both "servers" and "mcpServers" formats), see the mcp_configuration_examples.json file in this repository.
This file includes:
- Additional real-world setups for Windows, Linux, and macOS
- Minimal web development configurations
- Multiple directory and file type examples
- Migration tips for moving from config.json to command-line arguments
- Legacy MCP client support using the
"mcpServers"format
Refer to it if you need more flexibility or are working with a non-standard MCP client.
来源:README.md,提交 721a03d
工具
0版本历史
2- v0.1.4最新Oct 13, 2026
- v0.1.3Sep 16, 2026
评分
已满足适用检查项的 50%
该评分衡量此收录条目的完整程度,依据注册中心条目、端点与公开来源计算得出。它不是对服务器本身的评价,也不表示服务器安全或当前可用:可连通性是带日期的检查结果,评分也不包含安装量或用户评价。
- 近 30 天内可连通25 分
请保持端点能够响应 MCP 握手;SourceWeft 每 30 天探测一次。
- 已声明认证方式10 分
请在注册中心条目中声明凭据请求头,或保持端点能够响应探测,以便判定其认证方式。
- 已列出工具15 分
请让服务器在无凭据时响应 tools/list,或发布可在沙箱中无凭据启动的软件包。
- 描述必需15 分
- 图标10 分
- 文档15 分
- 许可证10 分