Linux MCP Server

Linux MCP Server

linux-mcp-server•bymartindai

A Spring Boot and Spring AI based MCP server that exposes a shell execution tool for running commands on local or remote Linux hosts.

License: MIT•Runtime: Awaiting documentation review•Category: cloud devops

WHAT IT DOES

  • •Registers a single MCP tool named executeShell that takes a host IP, a working directory and a full shell command.
  • •Chooses between local process execution and remote SSH execution automatically.
  • •Reuses SSH connections through a Caffeine cache with a default five-minute expiry.
  • •Maintains remote hosts in a hosts.json file that can be updated by restarting the service.

BEST FOR

  • •Connecting Claude Desktop or other MCP clients to run Linux shell commands through a standard MCP endpoint.
  • •Automating script execution across multiple remote Linux machines listed in a hosts file.
  • •Giving AI assistants access to both local and remote shell operations for operations work.

ABOUT LINUX-MCP-SERVER

Linux MCP Server is cataloged as an MCP server attributed to martindai. A Spring Boot and Spring AI based MCP server that exposes a shell execution tool for running commands on local or remote Linux hosts. It is categorized under cloud devops. See the capability inspector for recorded interfaces and their independent review status; consult upstream documentation for the current interface.

HOW TO INSTALL

Installation configuration is not reviewed. No executable setup is offered for this entry; inspect the source repository before proceeding.

LICENSE

Catalog license label: MIT. Check the source repository's current license and terms before using, modifying or distributing this software.

能力检查器

能力定义尚未审核。未核验的采集内容不会作为可信接口展示。

Tools (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Resources (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

Prompts (0)

暂无可展示的已审核记录。这不表示上游不支持此能力。

NEWSLETTER - COMING LATER

Newsletter subscriptions are not open yet

Email delivery is not connected. This page does not collect email addresses or create subscriptions.

Browse the registry for current listings instead.

Community Reviews

Coming later

Reviews for Linux MCP Server are not available yet

Review publishing and storage are not connected. This page does not collect or publish ratings or comments, including after sign-in.

FREQUENTLY ASKED QUESTIONS

Which transport does the MCP server use?

It uses streamable HTTP with the MCP endpoint at /mcp by default.

Which SSH authentication method does it support?

It currently uses password authentication configured in hosts.json, with key-based login needing code extension.

How are remote hosts configured?

Remote hosts are listed in src/main/resources/hosts.json with IP, username and password entries.

上游原版 README

在 GitHub 查看同一版本原文

README.md · 4917a2fe6ee8 · 采集于 2026-11-13 10:29:59 UTC

保留上游原文,不做 AI 改写。为安全起见过滤脚本、表单和不安全链接。

当前显示最后一次成功采集的文档快照,请以来源页面为准。

Linux MCP Server

基于 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 机器上执行脚本,返回标准输出与错误日志。

功能亮点

  • 双模式执行:自动判断命令执行位置,支持本地进程调度与远程 SSH 执行。
  • 连接池管理:基于 Caffeine 缓存复用 SSH 连接,默认 5 分钟自动过期清理。
  • 轻量配置:使用简单的 hosts.json 维护远程主机清单,可热重启生效。
  • Spring Boot 原生集成:开箱即用的 mvn spring-boot:run/可执行 JAR 部署方式,默认监听 3001 端口。
  • MCP 协议兼容:依赖 spring-ai-starter-mcp-server-webmvc,支持 STREAMABLE HTTP 通道,适配主流 MCP 客户端。

快速开始

环境准备

  • Java 17+
  • Maven 3.6+(推荐使用仓库自带的 ./mvnw/mvnw.cmd)
  • 具备 SSH 服务的目标 Linux 主机

获取代码

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 中追加条目并重启服务。

与 AI 助手集成

以 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 账户并限制可执行命令范围。
  • 网络限制:通过防火墙/安全组限制 MCP Server 与目标主机的访问来源。

开发与调试

  • 代码结构主要位于 src/main/java/com/doodl6/mcp/linux,可按需扩展新的工具方法。
  • 如需调整 SSH 缓存策略,可修改 RemoteShellService 中的 CACHE_DURATION_MINUTES、MAX_CACHE_SIZE。
  • 修改完成后建议手动触发一次 executeShell(本地与远程各一次)验证输出与错误处理逻辑。

许可证

项目基于 MIT 许可证 开源,可自由使用与二次开发。

Install configuration

Are you the maintainer?

Claim this server with your GitHub account to request manual ownership verification.

README Embed Badge
Markdown

Link to the catalog listing for Linux MCP Server from your README. This badge does not certify ownership, compatibility or security.

[![MCP catalog listing](https://img.shields.io/badge/MCP-awesome--mcp-orange?style=flat-square)](https://awesome-mcp.com/servers/linux-mcp-server)

REPOSITORY STATS

GitHub StarsUnavailable
ForksUnavailable

Public repository statistics could not be verified. Check the configured source address; unavailable counts are not zero.

下载与拉取统计

来源、范围和时段分别列出;不相加,不代表安装人数、活跃用户或安全审核。

尚无已审核的包 / 镜像标识,暂不展示下载统计。

Related cloud devops MCP Servers

Alternative and complementary servers in the same category

View all in cloud devops →
Huawei MCP Server
mcp-server-huaweiclouddeveloper•huaweiclouddeveloper

A Model Context Protocol server built on Huawei Cloud services that enables AI assistants to operate Huawei Cloud resources within conversational workflows, supporting ECS, OBS, GaussDB, and other cloud products.

Repository stats unavailable
Cloud & DevOps
Coolify MCP Server
coolify-mcp-server•wrediam

An MCP server that exposes the Coolify v4.3.1 REST API so AI clients can manage applications, databases, services, servers, deployments, and more.

Repository stats unavailable
Cloud & DevOps

A deprecated Model Context Protocol server for interacting with Kong Konnect APIs, enabling AI assistants to query and analyze Kong Gateway configurations, traffic, and analytics.

Repository stats unavailable
Cloud & DevOps