Skip to main content
Glama
zql78

mcp-linux-ops

by zql78

Linux 操作 MCP 服务器

这是一个 Model Context Protocol (MCP) 服务器,允许大模型在 Linux 机器上执行各种操作,包括执行命令、文件操作等。

功能特性

命令执行

  • execute_command: 在 Linux 系统上执行 shell 命令

    • 支持指定工作目录

    • 可配置超时时间

    • 返回标准输出、标准错误和退出码

文件操作

  • read_file: 读取文件内容

  • write_file: 写入文件内容(支持追加模式)

  • list_directory: 列出目录内容

  • create_directory: 创建目录(支持递归创建)

  • delete_file: 删除文件或目录

  • file_exists: 检查文件或目录是否存在

  • get_file_info: 获取文件或目录的详细信息

  • copy_file: 复制文件或目录

  • move_file: 移动或重命名文件或目录

Related MCP server: Linux MCP Server

安装

  1. 克隆或下载此项目

  2. 安装依赖:

npm install
  1. 构建项目:

npm run build

使用方法

在 Cursor 中配置

在 Cursor 的设置中添加 MCP 服务器配置。编辑你的 MCP 配置文件(通常在 ~/.cursor/mcp.json 或类似位置):

{
  "mcpServers": {
    "linux-ops": {
      "command": "node",
      "args": ["/path/to/mcp/dist/index.js"]
    }
  }
}

或者如果你使用 npm 全局安装:

{
  "mcpServers": {
    "linux-ops": {
      "command": "mcp-linux-ops"
    }
  }
}

开发模式

在开发时,你可以使用 tsx 直接运行:

npm run dev

工具说明

execute_command

执行 shell 命令并返回结果。

参数:

  • command (必需): 要执行的 shell 命令

  • workingDirectory (可选): 执行命令的工作目录

  • timeout (可选): 命令超时时间(秒,默认 30)

示例:

{
  "command": "ls -la",
  "workingDirectory": "/home/user",
  "timeout": 10
}

read_file

读取文件内容。

参数:

  • filePath (必需): 要读取的文件路径

  • encoding (可选): 文件编码(默认 "utf-8")

write_file

写入文件内容。

参数:

  • filePath (必需): 要写入的文件路径

  • content (必需): 要写入的内容

  • encoding (可选): 文件编码(默认 "utf-8")

  • append (可选): 是否追加模式(默认 false)

list_directory

列出目录内容。

参数:

  • directoryPath (必需): 要列出的目录路径

  • includeHidden (可选): 是否包含隐藏文件(默认 false)

create_directory

创建目录。

参数:

  • directoryPath (必需): 要创建的目录路径

  • recursive (可选): 是否递归创建父目录(默认 true)

delete_file

删除文件或目录。

参数:

  • path (必需): 要删除的文件或目录路径

  • recursive (可选): 删除目录时是否递归(默认 false)

file_exists

检查文件或目录是否存在。

参数:

  • path (必需): 要检查的文件或目录路径

get_file_info

获取文件或目录的详细信息。

参数:

  • filePath (必需): 文件或目录路径

copy_file

复制文件或目录。

参数:

  • source (必需): 源文件或目录路径

  • destination (必需): 目标路径

  • recursive (可选): 复制目录时是否递归(默认 true)

move_file

移动或重命名文件或目录。

参数:

  • source (必需): 源文件或目录路径

  • destination (必需): 目标路径

安全注意事项

⚠️ 警告: 此服务器允许执行任意 shell 命令,具有与运行用户相同的权限。请确保:

  1. 只在受信任的环境中使用

  2. 不要在生产环境中以 root 权限运行

  3. 考虑添加命令白名单或权限控制

  4. 限制可访问的文件系统路径

许可证

MIT

F
license - not found
-
quality - not tested
D
maintenance

Maintenance

Maintainers
Response time
Release cycle
Releases (12mo)
Commit activity

Resources

Unclaimed servers have limited discoverability.

Looking for Admin?

If you are the server author, to access and configure the admin panel.

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/zql78/mcp-linux-ops'

If you have feedback or need assistance with the MCP directory API, please join our Discord server