Back to MCP directory
publicPublicdnsLocal runtime

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

Runtime guide

cloud

Hosted runtime

Hosted servers run from a provider-managed environment. You usually connect the MCP client to the hosted endpoint or follow the provider's authorization flow, without keeping a local process alive

  1. Open provider connection page
  2. Authorize or copy endpoint
  3. Connect from your MCP client
terminal

Local runtime / other methods

Local servers run on your own machine or infrastructure. You normally copy the server_config into your MCP client, install the required package, and provide env variables from env_schema when needed

  1. Copy server_config
  2. Install required package
  3. Fill env variables and restart client