Remote MCP SSH Gateway

MIT License
3
  • Linux
  • Apple

Integrations

  • Provides access to MLB Stats API tools for retrieving and analyzing baseball statistics

MCP 服务器 SSH 客户端

一个模型上下文协议服务器(远程 SSH 客户端),通过 SSH 连接到远程 MCP 服务器。此客户端支持访问和使用托管在远程服务器上的 MCP 工具,为 MCP 通信提供安全的通道。

特征

  • 通过 SSH 连接到任何 MCP 服务器
  • 通过安全的 SSH 通道代理所有 MCP 协议命令
  • 支持基于密钥的身份验证
  • 支持 MCP 功能,包括工具、提示和资源

安装

uv管理的 python 项目中,通过以下方式添加依赖项:

uv add m2m-mcp-server-ssh-client

或者,对于使用pip作为依赖项的项目:

pip install m2m-mcp-server-ssh-client

直接从源安装:

git clone https://github.com/Machine-To-Machine/m2m-mcp-server-ssh-client.git cd m2m-mcp-server-ssh-client pip install -e .

要在项目内运行服务器:

uv run m2m-mcp-server-ssh-client

常见用例

1. 使用演示服务器快速启动

我们维护一个公共演示服务器,其中已配置好各种 MCP 工具,可供使用。(该服务器将一直开放,直到我们发布开放的去中心化注册表为止。)

该演示服务器有多个 MCP 服务器,包括 HackerNews、MLB Stats API 和 Formula 1 API 工具供您试验。

克劳德

要将 Claude 连接到此服务器,只需将以下内容添加到 Claude Desktop 设置中。

"mcpServers": { "remote-mcp-tools": { "command": "uvx", "args": [ "m2m-mcp-server-ssh-client", "--host", "mcp-beta.machinetomachine.ai", "--port", "8022", "--use-key-server" ] } }
命令行
# Connect to the M2M public demo server with automatic key exchange uv run m2m-mcp-server-ssh-client --host mcp-beta.machinetomachine.ai --use-key-server

2. 本地开发测试

要设置您自己的 SSH 服务器,请参阅m2m-mcp-server-ssh-server

使用您自己的 MCP 工具进行本地测试:

# Connect to a local MCP SSH server uv run m2m-mcp-server-ssh-client

上述命令将尝试连接到监听端口 8022 的本地 SSH 服务器。

在本地测试时,可以使用密钥服务器简化密钥交换:

# Use the key server for automatic key management (if server has --run-key-server enabled) uv run m2m-mcp-server-ssh-client --use-key-server

上述命令将尝试使用在端口 8000 上运行的密钥服务器。

3.远程服务器连接

连接到您自己的托管 MCP 服务器:

# Using existing SSH keys uv run m2m-mcp-server-ssh-client --host your-server.example.com --client-key ~/.ssh/your_key --known-hosts ~/.ssh/known_hosts

您可以通过在远程服务器上运行密钥服务器并在客户端中进行配置来简化密钥交换。

与 AI 平台一起使用

Claude 桌面集成

将其添加到 Claude 桌面设置:

"mcpServers": { "remote-mcp-tools": { "command": "uvx", "args": [ "m2m-mcp-server-ssh-client", "--host", "mcp-beta.machinetomachine.ai", "--port", "8022", "--use-key-server" ] } }

MCP 检查器

用于调试或探索可用工具:

npx @modelcontextprotocol/inspector -- uvx m2m-mcp-server-ssh-client --host mcp-beta.machinetomachine.ai --port 8022 --use-key-server

用法

命令行选项

  • --host :远程 SSH 服务器主机(默认:“localhost”)
  • --port :远程 SSH 服务器端口(默认值:8022)
  • --username :SSH 用户名(默认值:“mcp”)
  • --client-key :客户端私钥文件(默认值:“~/.ssh/m2m_mcp_server_ssh_client”)
  • --known-hosts :已知主机文件的路径(默认值:“~/.ssh/known_hosts”)
  • --passphrase :私钥的密码(默认值:无)
  • --disable-host-key-checking :跳过服务器签名验证(默认值:False)
  • --log-level :设置日志级别(默认值:INFO)

详细示例

与远程服务器的基本连接

连接到在端口 8022 上运行的远程 MCP 服务器(SSH 服务器):

uvx m2m-mcp-server-ssh-client --host mcp.example.com

使用自定义 SSH 密钥

指定特定的 SSH 密钥进行身份验证:

uvx m2m-mcp-server-ssh-client --host mcp.example.com --client-key ~/.ssh/mcp_custom_key

如果您的密钥受密码保护:

uvx m2m-mcp-server-ssh-client --host mcp.example.com --client-key ~/.ssh/mcp_custom_key --passphrase "your-passphrase"

用于故障排除的调试模式

启用详细日志记录以解决连接问题:

uvx m2m-mcp-server-ssh-client --host mcp.example.com --log-level DEBUG

密钥服务器集成

MCP SSH 客户端可以使用密钥服务器进行动态密钥交换和验证:

uvx m2m-mcp-server-ssh-client --host mcp.example.com --use-key-server

使用密钥服务器时:

  1. 客户端从http://host:key-server-port/server_pub_key获取服务器的公钥
  2. 客户端在http://host:key-server-port/register向服务器注册其公钥
  3. 为 SSH 连接创建一个临时的known_hosts文件

此功能与--known-hosts--disable-host-key-checking互斥。

禁用主机密钥检查

⚠️ 安全警告:使用--disable-host-key-checking会使您的连接容易受到中间人攻击。请仅在受信任的网络中或出于开发/测试目的使用此选项。

uvx m2m-mcp-server-ssh-client --host localhost --disable-host-key-checking

配置 Claude 桌面

添加到您的 Claude 设置:

"mcpServers": { "remote-servers": { "command": "uvx", "args": [ "m2m-mcp-server-ssh-client", "--host", "example.com", "--port", "8022", "--username", "mcp" ] } }

要使用特定密钥进行更安全的配置:

"mcpServers": { "remote-servers": { "command": "uvx", "args": [ "m2m-mcp-server-ssh-client", "--host", "mcp-server.example.com", "--port", "8022", "--username", "claude-mcp", "--client-key", "~/.ssh/claude_mcp_key", "--known-hosts", "~/.ssh/mcp_remote_server" ] } }

工作原理

MCP 服务器 SSH 客户端会与运行 MCP 工具的 MCP 服务器 SSH 服务器(即m2m-mcp-server-ssh-server建立 SSH 连接。然后,它会执行以下操作:

  1. 创建镜像远程 MCP 服务器功能的本地代理服务器
  2. 通过 SSH 连接将所有 MCP 请求转发到远程服务器
  3. 将远程服务器的响应返回到本地客户端

这使您可以使用在远程机器上运行的工具,就像它们是在本地安装的一样。

身份验证流程

安全注意事项

  • 在生产环境中始终使用主机密钥验证
  • 使用受密码保护的 SSH 密钥来增强安全性
  • 考虑使用专用 SSH 密钥进行 MCP 连接
  • 为 SSH 密钥文件设置适当的权限(600)
  • 在远程服务器上使用专用的、权限有限的用户

常见问题故障排除

连接被拒绝

Error running MCP SSH client: [Errno 111] Connection refused

解决方案:验证主机和端口是否正确以及 SSH 服务是否正在运行。

身份验证失败

Error running MCP SSH client: Authentication failed

解决方案:检查密钥文件路径。确保远程服务器已安装您的公钥。

主机密钥验证失败

Error running MCP SSH client: Host key verification failed

解决方案:将主机密钥添加到您的 known_hosts 文件或使用--disable-host-key-checking (仅用于测试)。

依赖项

  • anyio(>=4.5.0)
  • asyncssh(>=2.20.0)
  • mcp(>=1.1.3)
  • pydantic(>=2.0.0)

发展

设置开发环境

git clone https://github.com/Machine-To-Machine/m2m-mcp-server-ssh-client.git cd m2m-mcp-server-ssh-client uv venv source .venv/bin/activate # On Windows: .venv\Scripts\activate uv pip install -e ".[dev]"

代码质量

# Run linting uv run ruff check . # Run formatting check uv run ruff format --check . # Run security checks uv run bandit -r src/

调试

您可以使用 MCP 检查器来调试客户端:

npx @modelcontextprotocol/inspector uvx m2m-mcp-server-ssh-client --host example.com

对于高级调试,请使用以下工作流程:

  1. 使用--log-level DEBUG启动客户端
  2. 检查SSH连接参数及握手过程
  3. 如果使用自定义密钥,请验证正确的路径和权限
  4. 直接使用ssh -v先测试基本连通性

贡献

我们欢迎您为扩展和改进m2m-mcp-server-ssh-client做出贡献。无论您是想添加新功能、增强现有功能还是改进文档,您的意见都非常宝贵。

欢迎提交 Pull 请求!欢迎贡献新想法、错误修复或改进。

贡献指南

  1. 分叉存储库
  2. 创建功能分支: git checkout -b feature-name
  3. 提交您的更改: git commit -am 'Add some feature'
  4. 推送到分支: git push origin feature-name
  5. 提交拉取请求

执照

MIT 许可证 - 有关详细信息,请参阅 LICENSE 文件。

作者

  • 机器对机器
-
security - not tested
A
license - permissive license
-
quality - not tested

remote-capable server

The server can be hosted and run remotely because it primarily relies on remote services or has no dependency on the local environment.

m2m-mcp-server-ssh-client 提供统一的 MCP 服务器接口,通过 SSH 安全地连接到聚合 MCP 服务器的 m2m-mcp-server-ssh-server 后端。此设置使用基于 SSH 密钥的强健身份验证,提供对各种远程工具的安全单点访问。

  1. Features
    1. Installation
      1. Common Use Cases
        1. 1. Quick Start with Demo Server
        2. 2. Local Development Testing
        3. 3. Remote Server Connection
      2. Usage with AI Platforms
        1. Claude Desktop Integration
        2. MCP Inspector
      3. Usage
        1. Command Line Options
      4. Detailed Examples
        1. Basic Connection to a Remote Server
        2. Using a Custom SSH Key
        3. Debug Mode for Troubleshooting
        4. Key Server Integration
        5. Disabling Host Key Checking
        6. Configure for Claude Desktop
      5. How It Works
        1. Authentication Flow
      6. Security Considerations
        1. Troubleshooting Common Issues
          1. Connection Refused
          2. Authentication Failure
          3. Host Key Verification Failed
        2. Dependencies
          1. Development
            1. Setup Development Environment
            2. Code Quality
          2. Debugging
            1. Contributing
              1. Contribution Guidelines
            2. License
              1. Authors

                Related MCP Servers

                • A
                  security
                  A
                  license
                  A
                  quality
                  An MCP server that enables secure terminal command execution, directory navigation, and file system operations through a standardized interface for LLMs.
                  Last updated -
                  10
                  23
                  Python
                  MIT License
                  • Apple
                • -
                  security
                  A
                  license
                  -
                  quality
                  A secure MCP (Model Context Protocol) server hosted on Google Cloud Run that enables team collaboration by providing authenticated access via Google Cloud IAM, allowing teams to share custom MCP servers over the internet before official MCP authentication is implemented.
                  Last updated -
                  16
                  TypeScript
                  MIT License
                • -
                  security
                  F
                  license
                  -
                  quality
                  A personal MCP server for securely storing and accessing API keys across projects using the macOS Keychain, letting AI assistants and applications retrieve credentials through natural language.
                  Last updated -
                  10
                  TypeScript
                  • Apple
                • -
                  security
                  F
                  license
                  -
                  quality
                  A server that enables remote command execution over SSH through the Model Context Protocol (MCP), supporting both password and private key authentication.
                  Last updated -
                  JavaScript

                View all related MCP servers

                ID: n9j5lavce3