返回 MCP 目录
public公开dns本地运行

mcp-local-file-server

一个基于Node.js的本地文件服务器,提供文件管理和操作功能

article

README

🚀 MCP本地文件服务器

MCP本地文件服务器允许用户借助MCP(管理控制面板)对本地文件进行访问与操作,为文件管理提供便利。

🚀 快速开始

本服务器的使用步骤如下:

  1. 克隆仓库:
git clone https://github.com/fmorus/mcp-local-file-server.git
cd mcp-local-file-server
  1. 安装依赖项:
npm install
  1. 启动服务器:
npm start

服务器将在 http://localhost:3000 运行。

📚 详细文档

📄 API 接口

列出文件

  • GET /files?dir={directory}
  • 列出指定目录中的所有文件
  • 参数 dir 是可选的(默认:当前目录)

读取文件

  • GET /file?path={file_path}
  • 读取文件内容

文件上传

  • POST /file
  • 上传文件
  • 使用 multipart/form-data 格式,字段名为 file

更新文件

  • PUT /file
  • 更新文件内容
  • 请求体:{ "path": "file_path", "content": "new_content" }

删除文件

  • DELETE /file?path={file_path}
  • 删除文件或目录

💻 使用示例

基础用法

// 列出文件
fetch('http://localhost:3000/files')
  .then(response => response.json())
  .then(files => console.log(files));

// 读取文件
fetch('http://localhost:3000/file?path=/caminho/do/arquivo.txt')
  .then(response => response.json())
  .then(data => console.log(data.content));

// 文件上传
const formData = new FormData();
formData.append('file', arquivoParaUpload);
fetch('http://localhost:3000/file', {
  method: 'POST',
  body: formData
});

// 更新文件
fetch('http://localhost:3000/file', {
  method: 'PUT',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({
    path: '/caminho/do/arquivo.txt',
    content: 'Novo conteúdo'
  })
});

// 删除文件
fetch('http://localhost:3000/file?path=/caminho/do/arquivo.txt', {
  method: 'DELETE'
});

⚠️ 重要提示

⚠️ 重要提示

此服务器对系统文件有完全访问权限。请仅在安全可靠的环境中使用。

help

运行方式说明

cloud

托管运行

托管运行通常表示这个 MCP Server 由服务方环境承载,用户一般按页面提供的连接方式或授权流程接入,不需要在本地长期启动一个 MCP 进程

  1. 打开服务方连接页
  2. 完成授权或复制端点
  3. 在 MCP 客户端中连接
terminal

本地运行 / 其它方式

本地运行通常需要用户在自己的电脑或服务器上安装依赖,把 server_config 复制到 MCP 客户端,并按 env_schema 补齐环境变量、密钥或其它配置

  1. 复制 server_config
  2. 安装所需依赖
  3. 补齐环境变量后重启客户端