跳转到内容
MCP 指南deprecated

MCP 历史安装草案(未公开)

保留的 MCP 架构草案,不代表 RailWise 已对外发布安装包、服务端或配置方式。

复核 2026-07-20入门不进入公开索引RailWise 技术团队
MCP 指南
环境 最低版本 推荐版本 说明
Node.js 18.0.0 20.x LTS 运行时环境,必须安装
npm 9.0.0 10.x 包管理器,随 Node.js 安装
操作系统 - macOS 14+ / Windows 11 / Ubuntu 22.04 支持主流桌面和服务器系统
内存 512 MB 1 GB 运行时的内存占用
网络 - 稳定互联网连接 访问 RailWise API 服务
AI 客户端 最低版本 传输方式 说明
Claude Desktop 0.8.0 stdio 通过标准输入输出通信
Cursor 0.45.0 stdio 通过标准输入输出通信
Windsurf 1.0.0 stdio 通过标准输入输出通信
Cline 3.0.0 stdio 通过标准输入输出通信

注意:当前版本仅支持 stdio 传输方式。SSE(Server-Sent Events)传输方式将在后续版本中支持,用于远程服务器部署场景。

2.1 方式一:使用 npx 直接运行(推荐)

Section titled “2.1 方式一:使用 npx 直接运行(推荐)”

无需全局安装,每次运行自动获取最新版本:

Terminal window
npx -y @railwise/mcp-server

优点

  • 无需手动更新,始终使用最新版本
  • 不污染全局 npm 包空间
  • 适合快速试用和验证

缺点

  • 每次启动需要下载(如果本地无缓存)
  • 离线环境无法使用
Terminal window
# 全局安装
npm install -g @railwise/mcp-server
# 验证安装
railwise-mcp-server --version

优点

  • 启动速度快,无需重复下载
  • 支持离线环境运行
  • 可以使用本地配置文件

缺点

  • 需要手动执行更新命令

适用于需要自定义修改或贡献代码的开发者:

Terminal window
# 克隆仓库
git clone https://github.com/railwise/mcp-server.git
cd mcp-server
# 安装依赖
npm install
# 构建项目
npm run build
# 运行开发模式
npm run dev
# 或运行生产构建
npm start
Terminal window
# 检查当前版本
npm list -g @railwise/mcp-server
# 更新到最新版本
npm update -g @railwise/mcp-server
# 或强制重新安装最新版本
npm install -g @railwise/mcp-server@latest
Terminal window
# 清除 npx 缓存,确保下次使用最新版本
npx clear-npx-cache
# 或手动删除缓存目录
rm -rf ~/.npm/_npx

RailWise MCP Server 通过环境变量进行配置,以下是所有支持的环境变量:

环境变量 必填 默认值 说明
RAILWISE_API_KEY - RailWise API 访问密钥
RAILWISE_API_URL https://api.railwise.cn/v1 RailWise API 服务端点
RAILWISE_MCP_LOG_LEVEL info 日志级别:debug/info/warn/error
RAILWISE_MCP_LOG_FILE - 日志文件路径,默认输出到 stderr
RAILWISE_MCP_TIMEOUT 30000 API 请求超时时间(毫秒)
RAILWISE_MCP_MAX_RETRIES 3 API 请求失败时的最大重试次数
RAILWISE_MCP_TRANSPORT stdio 传输方式:stdio/sse
RAILWISE_MCP_SSE_PORT 3000 SSE 传输时的监听端口
NODE_ENV production 运行环境:development/production
  1. 登录 RailWise 开发者平台
  2. 进入 “API 管理”“密钥管理”
  3. 点击 “创建新密钥”
  4. 填写密钥名称(如 “Claude Desktop 集成”)
  5. 选择权限范围(建议根据最小权限原则选择)
  6. 复制生成的 API Key(注意:密钥只显示一次,请妥善保存

安全提示:API Key 相当于您的账户密码,请勿将其提交到代码仓库或分享给他人。建议使用环境变量或本地配置文件管理密钥。

编辑 Claude Desktop 配置文件:

  • macOS~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows%APPDATA%/Claude/claude_desktop_config.json
{
"mcpServers": {
"railwise": {
"command": "npx",
"args": ["-y", "@railwise/mcp-server"],
"env": {
"RAILWISE_API_KEY": "rw_live_xxxxxxxxxxxxxxxx",
"RAILWISE_API_URL": "https://api.railwise.cn/v1",
"RAILWISE_MCP_LOG_LEVEL": "info"
}
}
}
}

编辑 Cursor MCP 配置文件:

  • macOS~/.cursor/mcp.json
  • Windows%USERPROFILE%/.cursor/mcp.json
{
"mcpServers": {
"railwise": {
"command": "npx",
"args": ["-y", "@railwise/mcp-server"],
"env": {
"RAILWISE_API_KEY": "rw_live_xxxxxxxxxxxxxxxx",
"RAILWISE_API_URL": "https://api.railwise.cn/v1"
}
}
}
}

编辑 Windsurf 配置文件:

  • macOS~/.windsurf/mcp_config.json
  • Windows%USERPROFILE%/.windsurf/mcp_config.json
{
"mcpServers": {
"railwise": {
"command": "npx",
"args": ["-y", "@railwise/mcp-server"],
"env": {
"RAILWISE_API_KEY": "rw_live_xxxxxxxxxxxxxxxx",
"RAILWISE_API_URL": "https://api.railwise.cn/v1"
}
}
}
}

对于全局安装的用户,可以创建本地配置文件简化管理:

Terminal window
# 创建配置文件目录
mkdir -p ~/.config/railwise-mcp
# 创建配置文件
cat > ~/.config/railwise-mcp/config.json << 'EOF'
{
"apiKey": "rw_live_xxxxxxxxxxxxxxxx",
"apiUrl": "https://api.railwise.cn/v1",
"logLevel": "info",
"timeout": 30000,
"maxRetries": 3
}
EOF

然后在 AI 客户端配置中指定配置文件路径:

{
"mcpServers": {
"railwise": {
"command": "railwise-mcp-server",
"args": ["--config", "~/.config/railwise-mcp/config.json"]
}
}
}
Terminal window
# 检查版本
npx @railwise/mcp-server --version
# 输出:@railwise/mcp-server/1.2.0
# 检查配置
npx @railwise/mcp-server --check-config
# 输出:✓ API Key 有效
# ✓ API 服务端点可访问
# ✓ 权限验证通过
# 查看可用工具列表
npx @railwise/mcp-server --list-tools
# 输出:Available tools (12):
# - railwise_query_monitoring_data
# - railwise_query_project_info
# - railwise_query_device_status
# ...

配置完成后,在 AI 助手中发送以下消息验证连接:

用户:RailWise MCP 连接状态如何?

AI:RailWise MCP Server 连接正常。当前可用工具:

  • railwise_query_monitoring_data — 查询监测数据
  • railwise_query_project_info — 查询项目信息
  • railwise_query_device_status — 查询设备状态
  • …(共 12 个工具)

您可以通过我直接访问 RailWise 的监测数据和工程计算能力。

{
"mcpServers": {
"railwise-dev": {
"command": "npx",
"args": ["-y", "@railwise/mcp-server"],
"env": {
"RAILWISE_API_KEY": "rw_test_xxxxxxxxxxxxxxxx",
"RAILWISE_API_URL": "https://api-staging.railwise.cn/v1",
"RAILWISE_MCP_LOG_LEVEL": "debug"
}
},
"railwise-prod": {
"command": "npx",
"args": ["-y", "@railwise/mcp-server"],
"env": {
"RAILWISE_API_KEY": "rw_live_xxxxxxxxxxxxxxxx",
"RAILWISE_API_URL": "https://api.railwise.cn/v1",
"RAILWISE_MCP_LOG_LEVEL": "info"
}
}
}
}

对于需要内网部署的企业客户,可以配置私有 API 网关:

{
"mcpServers": {
"railwise-internal": {
"command": "npx",
"args": ["-y", "@railwise/mcp-server"],
"env": {
"RAILWISE_API_KEY": "rw_live_xxxxxxxxxxxxxxxx",
"RAILWISE_API_URL": "https://internal-api.company.com/railwise/v1",
"RAILWISE_MCP_TIMEOUT": "60000"
}
}
}
}
Terminal window
# 全局卸载
npm uninstall -g @railwise/mcp-server
# 清理配置文件(可选)
rm -rf ~/.config/railwise-mcp
问题 原因 解决方案
command not found: npx Node.js 未安装或未加入 PATH 重新安装 Node.js,确保 npm 和 npx 在 PATH 中
API Key 无效 密钥错误或已过期 在开发者平台重新生成 API Key
连接超时 网络问题或 API 服务不可用 检查网络连接,确认 API URL 配置正确
权限不足 API Key 权限范围不足 在开发者平台调整密钥权限
AI 客户端无法识别工具 MCP 配置格式错误 检查 JSON 格式,确认路径和参数正确

本文档由 RailWise 技术文档团队维护,最后更新于 2025-01-15。

引用与复核把知识带回真实工程判断

引用时保留页面与来源线索;涉及标准条文、阈值、频率和项目结论,请回到现行依据与责任人复核。

查看 Agent 使用规则