Config is the same across clients — only the file and path differ.
{
"mcpServers": [
{
"args": [
"http://localhost:3001/mcp"
],
"name": "linux-mcp-server",
"type": "http",
"command": "http"
}
]
}Are you the author?
Add this badge to your README to show your security score and help users find safe servers.
基于 Spring Boot 与 Spring AI 构建的 Model Context Protocol (MCP) 服务端,实现对本地与远程 Linux 主机的安全 Shell 命令执行。通过 MCP 标准接口,可被 Claude Desktop 等支持 MCP 的 AI 助手直接接入,扩展 AI 的运维能力。
Run this in your terminal to verify the server starts. Then let us know if it worked — your result helps other developers.
npx -y 'linux-mcp-server' 2>&1 | head -1 && echo "✓ Server started successfully"
After testing, let us know if it worked:
Five weighted categories — click any category to see the underlying evidence.
No known CVEs.
Checked linux-mcp-server against OSV.dev.
Click any tool to inspect its schema.
Be the first to review
Have you used this server?
Share your experience — it helps other developers decide.
Sign in to write a review.
Others in devops
MCP server for using the GitLab API
MCP Server for kubernetes management commands
MCP server for Dynatrace Managed to access logs, events, and metrics.
MCP server for no-payment x402 surface triage, 402 Index health checks, and paid review handoff.
MCP Security Weekly
Get CVE alerts and security updates for Linux Mcp Server and similar servers.
Start a conversation
Ask a question, share a tip, or report an issue.
Sign in to join the discussion.
基于 Spring Boot 与 Spring AI 构建的 Model Context Protocol (MCP) 服务端,实现对本地与远程 Linux 主机的安全 Shell 命令执行。通过 MCP 标准接口,可被 Claude Desktop 等支持 MCP 的 AI 助手直接接入,扩展 AI 的运维能力。
Linux MCP Server 将 Shell 执行封装成一个 MCP 工具 executeShell,由 Spring AI 自动注册到 MCP Server。客户端通过标准 MCP 调用,指定目标主机和命令,即可在本地或远程 Linux 机器上执行脚本,返回标准输出与错误日志。
hosts.json 维护远程主机清单,可热重启生效。mvn spring-boot:run/可执行 JAR 部署方式,默认监听 3001 端口。spring-ai-starter-mcp-server-webmvc,支持 STREAMABLE HTTP 通道,适配主流 MCP 客户端。./mvnw/mvnw.cmd)git clone <repository-url>
cd linux-mcp-server
编辑 src/main/resources/hosts.json:
[
{
"ip": "192.168.1.100",
"username": "devops",
"password": "your_password"
}
]
ip:目标主机地址,需与 executeShell 中的 machineIp 对应。username/password:SSH 登录凭据,目前采用密码认证,可在代码中扩展密钥登录。⚠️ 建议不要将生产凭据提交到版本库,使用环境变量或配置中心管理敏感信息。
开发环境直接运行:
mvn spring-boot:run
或打包独立运行:
mvn clean package
java -jar target/linux-mcp-server-1.0.0.jar
启动完成后,默认在 http://localhost:3001/mcp 暴露 MCP 接入点。
关键配置集中在 src/main/resources/application.yml:
server:
port: 3001 # MCP Server 监听端口
spring.ai.mcp.server:
name: linux-mcp-server
version: 1.0.0
protocol: STREAMABLE # 使用流式 HTTP 传输
streamable-http:
mcp-endpoint: /mcp # MCP 入口路径
如需自定义:
mcp-endpoint 时,记得同步更新 MCP 客户端配置。hosts.json 中追加条目并重启服务。以 Claude Desktop 为例,可在其 claude_desktop_config.json 中添加:
{
"mcpServers": [
{
"name": "linux-mcp-server",
"type": "http",
"command": "http",
"args": ["http://localhost:3001/mcp"]
}
]
}
连接成功后,Claude 将自动发现工具 executeShell:
machineIp(可选):为空或本地地址执行本机命令。path(可选):命令执行目录,缺省为 /。shell(必填):需要执行的完整命令。hosts.json 以明文保存密码,仅用于开发或受控环境;生产环境请改用密钥认证或外部安全存储。PromiscuousVerifier 跳过主机指纹校验,部署到生产前应替换为已知主机列表以防中间人攻击。root 账户并限制可执行命令范围。src/main/java/com/doodl6/mcp/linux,可按需扩展新的工具方法。RemoteShellService 中的 CACHE_DURATION_MINUTES、MAX_CACHE_SIZE。executeShell(本地与远程各一次)验证输出与错误处理逻辑。项目基于 MIT 许可证 开源,可自由使用与二次开发。