
用于运行Linux命令的MCP服务器和客户端
概览
Linux 命令 MCP 是一个基于模型上下文协议(MCP)构建的远程命令执行系统,允许安全且标准化地执行 Linux 命令。 MCP服务器配置在claude_desktop_config.json文件中,通常位于~/.config/Claude/claude_desktop_config.json。 - “command”:指定执行程序(node, npx, uvx)- “args”: 服务器可执行文件的完整路径- 确保路径是通往你index.js的绝对路径 - 始终使用完整的绝对路径 - 验证文件权限 - 确保指定文件可执行 - Node.js(v18.x 或更高版本)- npm - PM2(用于进程管理) 可用命令:1. exec - 执行Linux命令 2.列表 [目录] - 列表目录内容 3.帮助 - 显示此帮助 4.退出 - 退出客户端 : Linux 命令 MCP 服务器现在支持通过 stdin! 的交互式脚本! 你现在可以使用 stdin 参数为交互式脚本提供输入:
概述(AI 翻译)
概述
Linux 命令 MCP 是一个基于模型上下文协议(MCP)构建的远程命令执行系统,允许安全且标准化地执行 Linux 命令。
Claude 桌面 MCP 服务器配置
理解配置
MCP服务器配置在claude_desktop_config.json文件中,通常位于~/.config/Claude/claude_desktop_config.json。
配置结构
Linux 命令 MCP 服务器配置
配置解释
"command":指定执行者 ([node,npx,uvx)"args":服务器可执行文件的完整路径- 确保路径是绝对路径,通往你的
index.js
重要配置技巧
- 始终使用完整的绝对路径
- 验证文件权限
- 确保指定文件是可执行的
先修条件
- Node.js(v18.x 或更高版本)
- NPM
- PM2(用于流程管理)
安装
-
克隆仓库
-
安装服务器依赖
-
安装客户端依赖
用途
启动服务器
-
导航到服务器目录
-
从PM2开始
使用客户端
可用命令:
- exec - 执行 Linux 命令
本页由 AI 翻译,技术细节请以原文为准。
README
以下为原文 README 节选,完整内容请查看原文。
Linux Command MCP (Model Context Protocol)
Overview
Linux Command MCP is a remote command execution system built using the Model Context Protocol (MCP), allowing secure and standardized execution of Linux commands.
Configuration for Claude Desktop MCP Servers
Understanding the Configuration
The MCP servers are configured in the claude_desktop_config.json file, typically located at ~/.config/Claude/claude_desktop_config.json.
Configuration Structure
"mcpServers": {
"server-name": {
"command": "node|npx|uvx",
"args": ["server-specific-arguments"],
"env": {
"OPTIONAL_ENVIRONMENT_VARIABLES": "value"
}
}
}
Linux Command MCP Server Configuration
"linux-command": {
"command": "node",
"args": [
"/full/path/to/linux-command-mcp/server/dist/index.js"
]
}
Configuration Explained
"command": Specifies the executor (node,npx,uvx)"args": Full path to the server’s executable- Ensure the path is an absolute path to your
index.js
Important Configuration Tips
- Always use full, absolute paths
- Verify file permissions
- Ensure the specified file is executable
Prerequisites
- Node.js (v18.x or later)
- npm
- PM2 (for process management)
Installation
- Clone the repository
git clone
cd linux-command-mcp
- Install server dependencies
cd server
npm install
npm run build
- Install client dependencies
cd ../client
npm install
npm run build
Usage
Starting the Server
- Navigate to the server directory
cd server
- Start with PM2
npm run pm2:start
Using the Client
Available Commands:
- exec - Execute a Linux command
- list [directory] - List directory contents
- help - Show this help
- exit - Exit the client
Execute commands directly:
# In the client directory
npm start
exec "ls -l"
exec "list /home"
exec "uname -a"
Interactive Commands & Stdin Support
✨ NEW: The Linux Command MCP server now supports interactive scripts via stdin!
Using stdin Parameter
You can now provide input to interactive scripts using the stdin parameter:
// Example: Run an interactive Python game
await callTool('execute-command', {
command: 'python3 /path/to/interactive_script.py',
stdin: '15\n2\n1\n2\n1\n' // Automated responses
});
How it works:
- The
stdinparameter sends input to the script before execution - Input is sent line-by-line (use
\nfor newlines) - Script runs to completion with automated responses
- All output is captured and returned
Interactive Script Examples
Python game with input:
# Game expects: number of sticks, then player moves
stdin: "15\n2\n1\n2\n1\n"
Setup wizard:
# Wizard expects: username, email, confirm
stdin: "johndoe\[email protected]\ny\n"
Multiple choice prompt:
安装
This server does not publish a one-line install command.
Open the repository installation guide 新手?先看 mcpskill.org 教程 →配置
"mcpServers": {
"server-name": {
"command": "node|npx|uvx",
"args": ["server-specific-arguments"],
"env": {
"OPTIONAL_ENVIRONMENT_VARIABLES": "value"
}
}
}