/open/v1/mcp 端点暴露业务工具,Agent 通过 JSON-RPC 2.0 调用。| 项目 | 值 |
|---|---|
| URL | https://open.longxiachuxing.com/api/open/v1/mcp |
| 方法 | POST |
| 协议 | JSON-RPC 2.0 |
| 鉴权 | HMAC-SHA256 签名或 Bearer Token(与标准 REST 一致) |
| 传输 | MCP "Streamable HTTP":支持 JSON 一次性响应 / SSE 流式推送 |
canonical = METHOD + "\n" + REQUEST_URI + "\n" + TIMESTAMP + "\n" + NONCE + "\n" + SHA256(BODY)
sign = HMAC_SHA256(app_secret, canonical)Accept 头控制:{
"jsonrpc": "2.0",
"id": 1,
"result": { ... }
}event: message 帧:event: message
data: {"jsonrpc":"2.0","id":1,"result":{...}}
{
"jsonrpc": "2.0",
"method": "initialize",
"params": {
"protocolVersion": "2024-11-05",
"capabilities": {},
"clientInfo": {
"name": "my-agent",
"version": "1.0.0"
}
},
"id": 1
}{
"jsonrpc": "2.0",
"id": 1,
"result": {
"protocolVersion": "2024-11-05",
"capabilities": {
"tools": {}
},
"serverInfo": {
"name": "rideclaw-mcp",
"version": "1.0.0"
}
}
}{
"jsonrpc": "2.0",
"method": "tools/list",
"id": 2
}{
"jsonrpc": "2.0",
"id": 2,
"result": {
"tools": [
{
"name": "flight.search",
"description": "按出发/到达城市与日期搜索航班,返回带舱位价格的航班列表。",
"inputSchema": {
"type": "object",
"required": ["trip_mode", "trip_type", "from_code", "to_code", "depart_date"],
"properties": {
"trip_mode": { "type": "string", "enum": ["domestic", "international"] },
"from_code": { "type": "string" },
"to_code": { "type": "string" },
"depart_date": { "type": "string" }
}
}
},
...
]
}
}{
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"name": "flight.search",
"arguments": {
"trip_mode": "domestic",
"trip_type": "oneway",
"from_code": "SZX",
"to_code": "PEK",
"depart_date": "2026-06-12",
"passengers": { "adult": 1, "child": 0, "infant": 0 },
"page_size": 10
}
},
"id": 3
}{
"jsonrpc": "2.0",
"id": 3,
"result": {
"content": [
{
"type": "text",
"text": "{\"search_id\":\"S_2026-06-12_SZX_PEK\",\"total\":42,\"flights\":[...]}"
}
],
"isError": false
}
}{
"jsonrpc": "2.0",
"id": 3,
"result": {
"content": [
{
"type": "text",
"text": "flight.search 参数错误: trip_mode 必填"
}
],
"isError": true
}
}注意:工具执行错误返回 result.isError=true,不是 JSON-RPCerror对象。只有协议层错误(如 method 不存在、JSON 格式错误)才返回error。
| 工具名 | 用途 | 关键参数 |
|---|---|---|
flight.search | 航班列表查询 | from_code, to_code, depart_date |
flight.airport_search | 机场搜索 | keyword |
flight.pricing | 验价 | search_offer_id, passengers |
flight.order_create | 创建订单 | offer_id, out_trade_no, passengers, contact |
flight.order_pay | 发起支付 | system_no, pay_type |
flight.order_detail | 订单详情 | system_no / out_trade_no |
flight.order_list | 订单列表 | status, start_date, end_date |
flight.order_cancel_fee | 查询取消手续费 | order_id |
flight.order_cancel | 取消 / 退票 | system_no, reason |
| 工具名 | 用途 | 关键参数 |
|---|---|---|
hotel.search | 酒店列表查询 | destination, check_in, check_out |
hotel.rooms | 房型详情 | search_offer_id |
hotel.order_create | 创建订单 | offer_id, out_trade_no, guests, contact |
| 工具名 | 用途 | 关键参数 |
|---|---|---|
taxi.estimate | 打车估价 | from_lng, from_lat, to_lng, to_lat |
train.search | 高铁查询 | from_station, to_station, dep_date |
bus.search | 城际巴士查询 | start_city_code, end_city_code, date |
inputSchema 见 tools/list 响应。{
"jsonrpc": "2.0",
"id": 1,
"error": {
"code": -32601,
"message": "方法不存在: tools/unknown"
}
}| code | 含义 |
|---|---|
-32700 | JSON 解析失败 |
-32600 | 无效请求 |
-32601 | 方法不存在 |
-32602 | 参数错误 |
-32603 | 内部错误 |
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"content": [{"type": "text", "text": "参数错误: from_code 不能为空"}],
"isError": true
}
}isError=true 后应自我修正参数重试。{
"servers": {
"rideclaw": {
"url": "https://open.longxiachuxing.com/api/open/v1/mcp",
"headers": {
"Authorization": "Bearer rdak_live_xxxxxxxx"
}
}
}
}cmd/agent),连接本地 /open/v1/mcp 端点,通过阿里云通义千问模型驱动。cmd/agent/README.md。order_create)的幂等键为 <app_id, out_trade_no>,重复调用返回首次创建的订单。offer_id 有效期 10 分钟,超时需重新调用。pending_pay → paid → ticketed),通过 Webhook 推送,不建议轮询 order_detail。