Skip to content
KitploitKITPLOIT
工具博客
提交
工具博客
提交

黑客、渗透测试和网络安全工具,武装您的安全武器库!

Kitploit 是一个黑客、网络安全和渗透测试工具的目录。发现最新的项目更新,查找漏洞、分析系统、自动化测试并加强你的安全。

··订阅源·联系·隐私·© 2026 Kitploit

工具目录

分类

查看所有分类
Loading categories
CVE-2025-6514 — mcp-remote 暴露于操作系统命令注入 | Kitploit
工具/GitHubGitHub/cyberency/cve-2025-6514
漏洞分析Web安全命令与控制实用工具与框架身份验证API 安全
GitHubcyberency/cve-2025-6514

CVE-2025-6514

mcp-remote 暴露于操作系统命令注入

查看仓库
7139个月前尚未审核

最受欢迎

查看全部 →

发现我们社区最常用的工具。

探索所有工具

浏览我们的工具集合

查看所有工具 →
分享

mcp-remote

将仅支持本地(stdio)服务器的 MCP 客户端连接到远程 MCP 服务器,并支持身份验证:

注意:这是一个可用的概念验证,但应被视为实验性。

为什么需要它?

到目前为止,大多数 MCP 服务器都通过 stdio 传输在本地安装。这样做有一些好处:客户端和服务器可以隐式信任彼此,因为用户已授予它们运行权限。添加 API 密钥等机密信息可以使用环境变量来完成,并且永远不会离开你的机器。此外,基于 npx 和 uvx 构建还可以让用户避免显式的安装步骤。

然而,大多数可以迁移到网络的软件最终确实迁移到了网络,这是有原因的:当你只需一次部署就能向所有用户推送更新时,发现和修复 bug 以及迭代新功能要容易得多。

借助最新的 MCP 授权规范,我们现在有了一个安全的方式来与世界共享 MCP 服务器,而无需在用户的笔记本电脑上运行代码。或者至少,如果所有流行的 MCP 客户端都已经支持它的话,你本可以做到。但大多数客户端仅支持 stdio,而那些确实支持 HTTP+SSE 的客户端尚不支持所需的 OAuth 流程。

这就是 mcp-remote 的用武之地。一旦你选择的 MCP 客户端支持远程且经过授权的服务器,你就可以移除它。在那之前,只需加入这一行代码,即可为你想要的 MCP 客户端做好准备!

使用方法

所有最流行的 MCP 客户端(Claude Desktop、Cursor 和 Windsurf)都使用以下配置格式:

root@kitploit:~
{
  "mcpServers": {
    "remote-example": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://remote.mcp.server/sse"
      ]
    }
  }
}

自定义标头

要绕过身份验证,或在对远程服务器的所有请求中发送自定义标头,请传递 --header CLI 参数:

root@kitploit:~
{
  "mcpServers": {
    "remote-example": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://remote.mcp.server/sse",
        "--header",
        "Authorization: Bearer ${AUTH_TOKEN}"
      ],
      "env": {
        "AUTH_TOKEN": "..."
      }
    },
  }
}

注意: Cursor 和 Claude Desktop(Windows)存在一个 bug,即在调用 npx 时 args 内的空格没有转义,从而导致这些值被破坏。你可以使用以下方法解决:

root@kitploit:~
{
  // 其余配置...
  "args": [
    "mcp-remote",
    "https://remote.mcp.server/sse",
    "--header",
    "Authorization:${AUTH_HEADER}" // 注意 ':' 前后没有空格
  ],
  "env": {
    "AUTH_HEADER": "Bearer <auth-token>" // 环境变量中空格没问题
  }
},

标志

  • 如果 npx 产生错误,考虑将 -y 作为第一个参数添加,以自动接受安装 mcp-remote 包。
root@kitploit:~
      "command": "npx",
      "args": [
        "-y"
        "mcp-remote",
        "https://remote.mcp.server/sse"
      ]
  • 要强制 npx 始终检查 mcp-remote 的更新版本,请添加 @latest 标志:
root@kitploit:~
      "args": [
        "mcp-remote@latest",
        "https://remote.mcp.server/sse"
      ]
  • 要更改 mcp-remote 监听 OAuth 重定向的端口(默认为 3334),请在服务器 URL 后添加一个额外的参数。请注意,无论你指定什么端口,如果该端口不可用,系统将随机选择一个开放端口。
root@kitploit:~
      "args": [
        "mcp-remote",
        "https://remote.mcp.server/sse",
        "9696"
      ]
  • 要更改 mcp-remote 注册为 OAuth 回调 URL 的主机(默认为 localhost),请添加 --host 标志。
root@kitploit:~
      "args": [
        "mcp-remote",
        "https://remote.mcp.server/sse",
        "--host",
        "127.0.0.1"
      ]
  • 要允许在受信任的私有网络中使用 HTTP 连接,请添加 --allow-http 标志。注意:仅应在流量不会被拦截的安全私有网络中使用此选项。
root@kitploit:~
      "args": [
        "mcp-remote",
        "http://internal-service.vpc/sse",
        "--allow-http"
      ]
  • 要启用详细调试日志,请添加 --debug 标志。这会将详细日志写入 ~/.mcp-auth/{server_hash}_debug.log,其中包含时间戳以及关于身份验证过程、连接和令牌刷新的详细信息。
root@kitploit:~
      "args": [
        "mcp-remote",
        "https://remote.mcp.server/sse",
        "--debug"
      ]
  • 要为 mcp-remote 启用出站 HTTP(S) 代理,请添加 --enable-proxy 标志。启用后,mcp-remote 将使用来自常见环境变量(例如 HTTP_PROXY、HTTPS_PROXY 和 NO_PROXY)的代理设置。
root@kitploit:~
    "args": [
      "mcp-remote",
      "https://remote.mcp.server/sse",
      "--enable-proxy"
    ],
    "env": {
      "HTTPS_PROXY": "http://127.0.0.1:3128",
      "NO_PROXY": "localhost,127.0.0.1"
    }
  • 要从远程服务器中忽略特定工具,请添加 --ignore-tool 标志。这将从 tools/list 响应中过滤掉与指定模式匹配的工具,并阻止 tools/call 请求。支持使用 * 的通配符模式。
root@kitploit:~
      "args": [
        "mcp-remote",
        "https://remote.mcp.server/sse",
        "--ignore-tool",
        "delete*",
        "--ignore-tool",
        "remove*"
      ]

你可以指定多个 --ignore-tool 标志来忽略不同的模式。示例:

  • delete* - 忽略所有以 "delete" 开头的工具(例如 deleteTask、deleteUser)
  • *account - 忽略所有以 "account" 结尾的工具(例如 getAccount、updateAccount)
  • exactTool - 仅忽略名称恰好为 "exactTool" 的工具
  • 要更改 OAuth 回调的超时时间(默认为 30 秒),请使用 --auth-timeout 标志并指定秒数。如果服务器端的认证过程需要较长时间,这会很有用。
root@kitploit:~
      "args": [
        "mcp-remote",
        "https://remote.mcp.server/sse",
        "--auth-timeout",
        "60"
      ]

传输策略

MCP Remote 支持在连接到 MCP 服务器时采用不同的传输策略。这允许你控制是使用 Server-Sent Events (SSE) 还是 HTTP 传输,以及尝试它们的顺序。

使用 --transport 标志指定传输策略:

root@kitploit:~
npx mcp-remote https://example.remote/server --transport sse-only

可用策略:

  • http-first(默认):先尝试 HTTP 传输,如果 HTTP 返回 404 错误则回退到 SSE
  • sse-first:先尝试 SSE 传输,如果 SSE 返回 405 错误则回退到 HTTP
  • http-only:仅使用 HTTP 传输,如果服务器不支持则失败
  • sse-only:仅使用 SSE 传输,如果服务器不支持则失败

静态 OAuth 客户端元数据

MCP Remote 支持提供静态 OAuth 客户端元数据,而不是使用 mcp-remote 的默认值。当连接到期望特定客户端/软件 ID 或作用域的 OAuth 服务器时,这很有用。

使用 --static-oauth-client-metadata 标志,将客户端元数据作为 JSON 字符串或以 @ 为前缀的文件路径提供:

root@kitploit:~
npx mcp-remote https://example.remote/server --static-oauth-client-metadata '{ "scope": "space separated scopes" }'
# 使用 node readfile,因此如果不确定当前工作目录,最好使用绝对路径
npx mcp-remote https://example.remote/server --static-oauth-client-metadata '@/Users/username/Library/Application Support/Claude/oauth_client_metadata.json'

静态 OAuth 客户端信息

根据规范,建议但不强制要求服务器支持 OAuth 动态客户端注册。

对于这些服务器,MCP Remote 支持提供静态 OAuth 客户端信息。当连接到需要预注册客户端的 OAuth 服务器时,这很有用。

使用 --static-oauth-client-info 标志,将客户端元数据作为 JSON 字符串或以 @ 为前缀的文件路径提供:

root@kitploit:~
export MCP_REMOTE_CLIENT_ID=xxx
export MCP_REMOTE_CLIENT_SECRET=yyy
npx mcp-remote https://example.remote/server --static-oauth-client-info "{ \"client_id\": \"$MCP_REMOTE_CLIENT_ID\", \"client_secret\": \"$MCP_REMOTE_CLIENT_SECRET\" }"
# 使用 node readfile,因此如果不确定当前工作目录,最好使用绝对路径
npx mcp-remote https://example.remote/server --static-oauth-client-info '@/Users/username/Library/Application Support/Claude/oauth_client_info.json'

Claude Desktop

官方文档

要在 Claude Desktop 中添加 MCP 服务器,你需要编辑位于以下位置的配置文件:

  • macOS:~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows:%APPDATA%\Claude\claude_desktop_config.json

如果该文件尚不存在,你可能需要在设置 > 开发者下启用它。

重启 Claude Desktop 以应用配置文件中的更改。重启后,你应该会在输入框的右下角看到一个锤子图标。

Cursor

官方文档。配置文件位于 ~/.cursor/mcp.json。

从版本 0.48.0 开始,Cursor 直接支持未经身份验证的 SSE 服务器。如果你的 MCP 服务器使用官方的 MCP OAuth 授权协议,你仍然需要添加一个 "command" 服务器并调用 mcp-remote。

Windsurf

官方文档。配置文件位于 ~/.codeium/windsurf/mcp_config.json。

构建远程 MCP 服务器

有关构建和部署远程 MCP 服务器(包括作为有效的 OAuth 客户端)的说明,请参阅以下资源:

  • https://developers.cloudflare.com/agents/guides/remote-mcp-server/

特别是,请参阅:

  • https://github.com/cloudflare/workers-oauth-provider 用于在 Cloudflare Workers 中定义符合 MCP 的 OAuth 服务器
  • https://github.com/cloudflare/agents/tree/main/examples/mcp 用于使用 agents 框架定义 McpAgent

有关测试这些服务器的更多信息,请参阅:

  • https://developers.cloudflare.com/agents/guides/test-remote-mcp-server/

知道更多想要分享的资源吗?请将它们添加到此 Readme 并发送 PR!

故障排除

清除你的 ~/.mcp-auth 目录

mcp-remote 将所有凭证信息存储在 ~/.mcp-auth(或 MCP_REMOTE_CONFIG_DIR 指向的任何位置)中。如果你遇到持续性问题,请尝试运行:

root@kitploit:~
rm -rf ~/.mcp-auth

然后重启你的 MCP 客户端。

检查你的 Node 版本

确保你安装的 Node 版本是 18 或更高。Claude Desktop 会使用你系统版本的 Node,即使你在其他位置安装了更新的版本也是如此。

重启 Claude

修改 claude_desktop_config.json 时,完全重启 Claude 可能会有帮助。

VPN 证书

如果你处于 VPN 后,可能会遇到问题。你可以尝试设置 NODE_EXTRA_CA_CERTS 环境变量指向 CA 证书文件。如果使用 claude_desktop_config.json,可能如下所示:

root@kitploit:~
{
 "mcpServers": {
    "remote-example": {
      "command": "npx",
      "args": [
        "mcp-remote",
        "https://remote.mcp.server/sse"
      ],
      "env": {
        "NODE_EXTRA_CA_CERTS": "{你的 CA 证书文件路径}.pem"
      }
    }
  }
}

检查日志

  • 实时跟踪 Claude Desktop 日志
  • MacOS / Linux:
    tail -n 20 -F ~/Library/Logs/Claude/mcp*.log
  • 对于 WSL 上的 bash:
    tail -n 20 -f "C:\Users\YourUsername\AppData\Local\Claude\Logs\mcp.log"
  • Powershell:
    Get-Content "C:\Users\YourUsername\AppData\Local\Claude\Logs\mcp.log" -Wait -Tail 20

调试

调试日志

针对复杂问题排查(尤其是令牌刷新或认证问题),请使用 --debug 标志:

root@kitploit:~
"args": [
  "mcp-remote",
  "https://remote.mcp.server/sse",
  "--debug"
]

这会在 ~/.mcp-auth/{server_hash}_debug.log 中创建详细的日志,包含时间戳以及关于连接和认证过程每一步的完整信息。当你遇到令牌刷新、笔记本电脑休眠/唤醒问题或认证问题时,请在寻求支持时提供这些日志。

认证错误

如果你遇到 /callback URL 返回的以下错误:

root@kitploit:~
Authentication Error
Token exchange failed: HTTP 400

你可以运行 rm -rf ~/.mcp-auth 来清除本地存储的所有状态和令牌。

"客户端"模式

在命令行(而非 MCP 服务器)上运行以下命令:

root@kitploit:~
npx -p mcp-remote@latest mcp-remote-client https://remote.mcp.server/sse

这将会执行整个授权流程,并尝试列出远程 URL 上的工具和资源。可以先运行 rm -rf ~/.mcp-auth 看看过期的凭证是否是问题所在,否则希望在这些日志中看到比 MCP 客户端日志中更明显的错误。

下载工具