mcp-linux-ops

mcp-linux-ops

Enables LLMs to execute shell commands and perform file operations on a Linux system, exposing tools like execute_command, read_file, write_file, and more.

Category
Visit Server

README

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: 移动或重命名文件或目录

安装

  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

Recommended Servers

playwright-mcp

playwright-mcp

A Model Context Protocol server that enables LLMs to interact with web pages through structured accessibility snapshots without requiring vision models or screenshots.

Official
Featured
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

An AI-powered tool that generates modern UI components from natural language descriptions, integrating with popular IDEs to streamline UI development workflow.

Official
Featured
Local
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

Enables interaction with Audiense Insights accounts via the Model Context Protocol, facilitating the extraction and analysis of marketing insights and audience data including demographics, behavior, and influencer engagement.

Official
Featured
Local
TypeScript
VeyraX MCP

VeyraX MCP

Single MCP tool to connect all your favorite tools: Gmail, Calendar and 40 more.

Official
Featured
Local
graphlit-mcp-server

graphlit-mcp-server

The Model Context Protocol (MCP) Server enables integration between MCP clients and the Graphlit service. Ingest anything from Slack to Gmail to podcast feeds, in addition to web crawling, into a Graphlit project - and then retrieve relevant contents from the MCP client.

Official
Featured
TypeScript
Kagi MCP Server

Kagi MCP Server

An MCP server that integrates Kagi search capabilities with Claude AI, enabling Claude to perform real-time web searches when answering questions that require up-to-date information.

Official
Featured
Python
E2B

E2B

Using MCP to run code via e2b.

Official
Featured
Neon Database

Neon Database

MCP server for interacting with Neon Management API and databases

Official
Featured
Exa Search

Exa Search

A Model Context Protocol (MCP) server lets AI assistants like Claude use the Exa AI Search API for web searches. This setup allows AI models to get real-time web information in a safe and controlled way.

Official
Featured
Qdrant Server

Qdrant Server

This repository is an example of how to create a MCP server for Qdrant, a vector search engine.

Official
Featured