LocalFilesMCP is an MCP server for file system operations, built with C# and the ModelContextProtocol SDK. It allows an Agent to interact with the file system in a secure, sandboxed manner via the MCP protocol.
- Added
FindandFRegtools for glob-based file search and regex content search. - Removed
ChangeDirandListFiles. All tools are now stateless — use thedirectoryparameter onFind,FReg, andListFoldersinstead. (Breaking) - Fixed
GetVolumeDescriptionnow reads the file specified by--vol-desc(was unimplemented). - Fixed
ListFoldersandFRegnow return paths relative to the volume root.
See the full CHANGELIST for details.
-
--stdioRuns the server using standard input/output (stdio) transport. This is required for integration with tools like LM Studio or VS Code. -
--root-path <path>Sets the root directory for all file operations. All file and directory access will be confined to this path. Example:dotnet run -- --stdio --root-path "C:\My\Sandbox"
--portListener port for the server (only used if--stdiois NOT specified).
dotnet run -- --port 5000 --root-path "/home/user/sandbox"
If --root-path is not specified, the current working directory is used as the root.
If --port is not specified, the server will listen on port 5000.
If --stdio is not specified, the server will use HTTP/SSE transport.
- Build the project
Run
dotnet publish -c Release -r win-x64 --self-contained -p:PublishSingleFile=trueto produce a standalone executable. - Locate the executable
The output will be in
bin/Release/net10.0/<your-platform>/publish/. - Configure LM Studio
Create or edit the
mcp.jsonfile in your LM Studio workspace directory. - Add the server configuration
Use the following example, updating the
commandpath to your published executable and the--root-pathas needed.
{
"mcpServers": {
"LocalFilesMCP": {
"command": "C:\\Path\\To\\LocalFilesMCP.exe",
"args": [
"--stdio",
"--root-path=C:\\Path\\To\\Your\\Sandbox"
]
}
}
}
{
"inputs": [],
"servers": {
"LocalFilesMCP": {
"command": "C:\\Path\\To\\LocalFilesMCP.exe",
"args": [
"--stdio",
"--root-path=C:\\Path\\To\\Your\\Sandbox"
],
"env": {}
},
"OtherLocalFilesMCP": {
"command": "C:\\Path\\To\\LocalFilesMCP.exe",
"args": [
"--stdio",
"--root-path=C:\\Path\\To\\Your\\Other\\Sandbox"
],
"env": {}
}
}
}
The Volume Description file is used to inform agents about the contents and purpose of the filesystem volume exposed via MCP. This helps agents like CoPilot and Cursor understand how to interact with the files and directories within the volume and not override the solution files context. The description should be clear and concise, providing essential information without overwhelming detail.
Must be in markdown format. Must start with a # Volume Description header. You may include any user comments in this header, they will not be returned to the agent. You may include additional sections as needed for your specific LLM agent.
Recommended to use a filename that starts with a "." to infer it is hidden.
Recommended to include the following sections:
- ## Purpose: A brief explanation of what the volume contains and how agents should interpret it.
- ## Notes: Any important details or caveats about the volume, such as:
- Paths are relative to the volume root.
- This volume may or may not contain project files.
- This volume is read-only.
# Volume Description
This is a read-only filesystem volume exposed via MCP.
## Purpose
This volume contains files and directories that the agent can read and analyze to assist with queries about FooBar projects.
## Notes
- Paths are relative to the volume root.
- This volume may contain code files for example only but will not contain any project files.
- This volume is read-only.The following tools are available in the LocalFilesMCP project:
-
GetVolumeDescription: Retrieves the volume description.
- Description: Returns a markdown string describing the contents and purpose of the filesystem volume.
- Parameters: None.
-
ListFolders: Lists folders in the specified directory.
- Description: Lists all folders in the given directory. Defaults to the current directory if no directory is specified.
- Parameters:
directory(optional): The directory to list.
-
Find: Searches for files matching a glob pattern.
- Description: Searches for files matching a glob pattern (e.g.,
**/*.cs,src/**/*.txt) within the volume. - Parameters:
pattern: Glob pattern to match files.directory(optional): Directory to search from. Defaults to the current directory.
- Description: Searches for files matching a glob pattern (e.g.,
-
FReg: Searches file contents for a regex pattern.
- Description: Searches file contents by regex pattern with configurable output modes and optional context lines.
- Parameters:
pattern: Regex pattern to search for in file contents.directory(optional): Directory to search in. Defaults to the current directory.fileGlob(optional): Glob pattern to filter which files are searched (e.g.,*.cs). Defaults to all files.outputMode(optional):filesreturns only matching file paths,contentreturns file paths with matching lines and line numbers. Defaults tocontent.contextLines(optional): Number of context lines to include before and after each match. Defaults to 0.
-
ReadFileText: Reads the text contents of a file.
- Description: Reads and returns the text content of the specified file.
- Parameters:
path: The path to the file to read.
-
ReadBinaryFile: Reads the binary contents of a file.
- Description: Reads and returns the binary content of the specified file.
- Parameters:
path: The path to the file to read.
This project is licensed under the Apache License 2.0 with the Commons Clause.
What this means:
- Free for Personal Use: You can download, modify, and use this freely.
- Free for Internal Business Use: You can use this inside your company (e.g., game studios, enterprise workflows).
- No Commercial Resale: You cannot sell this software, offer it as a paid service, or wrap it in a commercial product for third parties.
See LICENSE.txt for the full legal text.