mcp-stdio-proxy 0.1.15

MCP (Model Context Protocol) proxy server and CLI tool for protocol conversion and remote service access
Documentation
### 测试说明
# 本地启动了一个 Streamable HTTP MCP 服务: http://0.0.0.0:8000/mcp
# 
# 重要:请求参数说明
# - mcpProtocol: 此参数不存在!会被忽略
# - backendProtocol: 指定后端服务的协议(可选,支持自动检测)
# - 客户端协议由请求路径决定:
#   - /mcp/sse/check_status → SSE 客户端协议
#   - /mcp/stream/check_status → Stream 客户端协议

### ========================================
### 方案 A:SSE 客户端 + Streamable HTTP 后端(协议转换)
### ========================================

### 1a. 检查服务状态 - 自动检测后端协议(推荐)
# 客户端使用 SSE 协议,后端自动检测为 Streamable HTTP
POST http://localhost:8085/mcp/sse/check_status
Content-Type: application/json

{
  "mcpId": "test-sse-streamable-service",
  "mcpJsonConfig": "{\"mcpServers\": {\"test-service\": {\"url\": \"http://127.0.0.1:8000/mcp\"}}}",
  "mcpType": "Persistent"
}

### 1b. 检查服务状态 - 手动指定后端协议
# 客户端使用 SSE 协议,手动指定后端为 Streamable HTTP
POST http://localhost:8085/mcp/sse/check_status
Content-Type: application/json

{
  "mcpId": "test-sse-to-stream-manual",
  "mcpJsonConfig": "{\"mcpServers\": {\"test-service\": {\"url\": \"http://127.0.0.1:8000/mcp\"}}}",
  "mcpType": "Persistent",
  "backendProtocol": "Stream"
}

### 1c. 检查服务状态 - 复杂配置测试
# 使用完整的 MCP 配置,包含认证、超时、重试等参数
POST http://localhost:8085/mcp/sse/check_status
Content-Type: application/json

{
  "mcpId": "test-sse-complex-config2",
  "mcpJsonConfig": "{\"mcpServers\": {\"test-service\": {\"type\": \"http\", \"url\": \"http://127.0.0.1:8000/mcp\", \"auth_token\": \"Bearer token...\", \"headers\": {\"X-Custom-Header\": \"value\"}, \"time\": 30, \"connect_timeout_secs\": 5, \"max_retries\": 3, \"retry_min_backoff_ms\": 100, \"retry_max_backoff_ms\": 5000}}}",
  "mcpType": "Persistent"
}

### 2a. 获取 SSE 连接(自动检测版本)
GET http://localhost:8085/mcp/sse/proxy/test-streamable-service/sse
Accept: text/event-stream

### 2b. 获取 SSE 连接(手动指定版本)
GET http://localhost:8085/mcp/sse/proxy/test-sse-to-stream-manual/sse
Accept: text/event-stream

### 3. 发送 initialize 消息(需要先从 SSE 响应中获取 sessionId)
# 替换 {sessionId} 为实际的 session ID
POST http://localhost:8085/mcp/sse/proxy/test-streamable-service/message?sessionId={sessionId}
Content-Type: application/json

{
  "jsonrpc": "2.0",
  "id": "msg-1",
  "method": "initialize",
  "params": {
    "protocolVersion": "2024-11-05",
    "capabilities": {},
    "clientInfo": {
      "name": "test-client",
      "version": "1.0.0"
    }
  }
}

### 4. 列出可用工具
POST http://localhost:8085/mcp/sse/proxy/test-streamable-service/message?sessionId={sessionId}
Content-Type: application/json

{
  "jsonrpc": "2.0",
  "id": "msg-2",
  "method": "tools/list",
  "params": {}
}

### ========================================
### 方案 B:Streamable HTTP 客户端 + Streamable HTTP 后端(透明代理)
### ========================================

### 5. 检查服务状态 - Stream 到 Stream(自动检测)
# 客户端和后端都使用 Streamable HTTP 协议
POST http://localhost:8085/mcp/stream/check_status
Content-Type: application/json

{
  "mcpId": "test-stream-to-stream",
  "mcpJsonConfig": "{\"mcpServers\": {\"test-service\": {\"url\": \"http://127.0.0.1:8000/mcp\"}}}",
  "mcpType": "Persistent"
}

### 6. 发送 Streamable HTTP 请求 - initialize
POST http://localhost:8085/mcp/stream/proxy/test-stream-to-stream
Content-Type: application/json
Accept: application/json, text/event-stream

{
  "jsonrpc": "2.0",
  "id": "msg-1",
  "method": "initialize",
  "params": {
    "protocolVersion": "2024-11-05",
    "capabilities": {},
    "clientInfo": {
      "name": "test-client",
      "version": "1.0.0"
    }
  }
}

### 7. 列出可用工具
POST http://localhost:8085/mcp/stream/proxy/test-stream-to-stream
Content-Type: application/json
Accept: application/json, text/event-stream

{
  "jsonrpc": "2.0",
  "id": "msg-2",
  "method": "tools/list",
  "params": {}
}

### ========================================
### 清理服务
### ========================================

### 8a. 清理 SSE 服务(自动检测)
DELETE http://localhost:8085/mcp/config/delete/test-streamable-service
Content-Type: application/json

{}

### 8b. 清理 SSE 服务(手动指定)
DELETE http://localhost:8085/mcp/config/delete/test-sse-to-stream-manual
Content-Type: application/json

{}

### 8c. 清理 SSE 服务(复杂配置)
DELETE http://localhost:8085/mcp/config/delete/test-sse-complex-config
Content-Type: application/json

{}

### 8d. 清理 Stream 服务
DELETE http://localhost:8085/mcp/config/delete/test-stream-to-stream
Content-Type: application/json

{}

### ========================================
### 方案 C:SSE 客户端 + 阿里云百炼 SSE 后端(SSE 到 SSE)
### ========================================

### 9a. 检查服务状态 - 阿里云百炼 SSE 服务
# 客户端使用 SSE 协议,后端为阿里云百炼 SSE 服务
POST http://localhost:8085/mcp/sse/check_status
Content-Type: application/json

{
  "mcpId": "test-aliyun-bailian-sse",
  "mcpJsonConfig": "{\"mcpServers\": {\"mcp-NjZmY2NhZDc5NTQz\": {\"type\": \"sse\", \"description\": \"阿里云百炼_新浪实时汇率报价\", \"isActive\": true, \"name\": \"阿里云百炼_阿里云百炼_新浪实时汇率报价\", \"baseUrl\": \"https://dashscope.aliyuncs.com/api/v1/mcps/mcp-NjZmY2NhZDc5NTQz/sse\", \"headers\": {\"Authorization\": \"Bearer sk-d39046bd64b446d8a19d642e9a2b8967\"}}}}",
  "mcpType": "Persistent"
}

### 9b. 获取 SSE 连接 - 阿里云百炼服务
GET http://localhost:8085/mcp/sse/proxy/test-aliyun-bailian-sse/sse
Accept: text/event-stream

### 9c. 发送 initialize 消息 - 阿里云百炼服务(需要先从 SSE 响应中获取 sessionId)
# 替换 {sessionId} 为实际的 session ID
POST http://localhost:8085/mcp/sse/proxy/test-aliyun-bailian-sse/message?sessionId={sessionId}
Content-Type: application/json

{
  "jsonrpc": "2.0",
  "id": "msg-1",
  "method": "initialize",
  "params": {
    "protocolVersion": "2024-11-05",
    "capabilities": {},
    "clientInfo": {
      "name": "test-client",
      "version": "1.0.0"
    }
  }
}

### 9d. 列出可用工具 - 阿里云百炼服务
POST http://localhost:8085/mcp/sse/proxy/test-aliyun-bailian-sse/message?sessionId={sessionId}
Content-Type: application/json

{
  "jsonrpc": "2.0",
  "id": "msg-2",
  "method": "tools/list",
  "params": {}
}

### 9e. 清理阿里云百炼 SSE 服务
DELETE http://localhost:8085/mcp/config/delete/test-aliyun-bailian-sse
Content-Type: application/json

{}

### ========================================
### 方案 D:SSE 客户端 + Nuwax 图像服务 SSE 后端(SSE 到 SSE)
### ========================================

### 10a. 检查服务状态 - Nuwax 图像理解和生成 SSE 服务
# 客户端使用 SSE 协议,后端为 Nuwax 图像服务 SSE
POST http://localhost:8085/mcp/sse/check_status
Content-Type: application/json

{
  "mcpId": "test-nuwax-image-service",
  "mcpJsonConfig": "{\"mcpServers\": {\"image-understanding-and-generation\": {\"type\": \"sse\", \"url\": \"https://mcp-sse-api.nuwax.com/?ts=TENANT_SECRET&id=image-services\"}}}",
  "mcpType": "Persistent"
}

### 10b. 获取 SSE 连接 - Nuwax 图像服务
GET http://localhost:8085/mcp/sse/proxy/test-nuwax-image-service/sse
Accept: text/event-stream

### 10c. 发送 initialize 消息 - Nuwax 图像服务(需要先从 SSE 响应中获取 sessionId)
# 替换 {sessionId} 为实际的 session ID
POST http://localhost:8085/mcp/sse/proxy/test-nuwax-image-service/message?sessionId={sessionId}
Content-Type: application/json

{
  "jsonrpc": "2.0",
  "id": "msg-1",
  "method": "initialize",
  "params": {
    "protocolVersion": "2024-11-05",
    "capabilities": {},
    "clientInfo": {
      "name": "test-client",
      "version": "1.0.0"
    }
  }
}

### 10d. 列出可用工具 - Nuwax 图像服务
POST http://localhost:8085/mcp/sse/proxy/test-nuwax-image-service/message?sessionId={sessionId}
Content-Type: application/json

{
  "jsonrpc": "2.0",
  "id": "msg-2",
  "method": "tools/list",
  "params": {}
}

### 10e. 清理 Nuwax 图像服务 SSE 服务
DELETE http://localhost:8085/mcp/config/delete/test-nuwax-image-service
Content-Type: application/json

{}