docs: add /mcp endpoint to OpenAPI spec (JSON-RPC, 13 paths)
This commit is contained in:
@@ -659,6 +659,72 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"/mcp": {
|
||||||
|
"post": {
|
||||||
|
"summary": "MCP 端点(Model Context Protocol,AI 助手接入)",
|
||||||
|
"description": "JSON-RPC 2.0 应用协议端点,非 REST 资源接口。\n供支持 MCP 的 AI 客户端(Claude Desktop / Cursor 等)通过 tools/call 调用桥的行情/交易能力。\n支持方法: initialize、notifications/initialized、ping、tools/list、tools/call。\n9 个工具(qmt_kline / qmt_quote / qmt_tick / qmt_instrument / qmt_trading_dates /\nqmt_positions / qmt_asset / qmt_orders / qmt_trades)与各 HTTP 查询接口 1:1。\n请求/响应均为 JSON-RPC 2.0 信封;JSON-RPC 错误(parse/invalid/method not found/\ninvalid params/internal)走 HTTP 200;非法 body 走 400 {\"detail\":...}。\n鉴权: 复用桥 TOKEN(X-Token header 或 ?token=)。\n不做订阅/长连接(实时数据走 HTTP 订阅 + WS /ws 推送)。\n详细设计见 docs/迭代记录/MCP服务.md。\n",
|
||||||
|
"requestBody": {
|
||||||
|
"required": true,
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "JSON-RPC 2.0 请求对象(jsonrpc/id/method/params)",
|
||||||
|
"example": {
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"id": 1,
|
||||||
|
"method": "tools/call",
|
||||||
|
"params": {
|
||||||
|
"name": "qmt_quote",
|
||||||
|
"arguments": {
|
||||||
|
"code": "600519.SH"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"responses": {
|
||||||
|
"200": {
|
||||||
|
"description": "JSON-RPC 2.0 响应对象(含 result 或 error)",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "JSON-RPC 2.0 响应信封"
|
||||||
|
},
|
||||||
|
"example": {
|
||||||
|
"jsonrpc": "2.0",
|
||||||
|
"id": 1,
|
||||||
|
"result": {
|
||||||
|
"content": [
|
||||||
|
{
|
||||||
|
"type": "text",
|
||||||
|
"text": "{\"ok\": true, \"code\": \"600519.SH\", \"data\": {...}}"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"400": {
|
||||||
|
"description": "非法 body(非 JSON-RPC 格式)",
|
||||||
|
"content": {
|
||||||
|
"application/json": {
|
||||||
|
"schema": {
|
||||||
|
"$ref": "#/components/schemas/ErrorResponse"
|
||||||
|
},
|
||||||
|
"example": {
|
||||||
|
"detail": "parse error"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"components": {
|
"components": {
|
||||||
|
|||||||
@@ -514,6 +514,68 @@ paths:
|
|||||||
m_strTradeTime: 094648
|
m_strTradeTime: 094648
|
||||||
m_dCommission: 2.0
|
m_dCommission: 2.0
|
||||||
m_dTradeAmount: 2812.0
|
m_dTradeAmount: 2812.0
|
||||||
|
/mcp:
|
||||||
|
post:
|
||||||
|
summary: MCP 端点(Model Context Protocol,AI 助手接入)
|
||||||
|
description: 'JSON-RPC 2.0 应用协议端点,非 REST 资源接口。
|
||||||
|
|
||||||
|
供支持 MCP 的 AI 客户端(Claude Desktop / Cursor 等)通过 tools/call 调用桥的行情/交易能力。
|
||||||
|
|
||||||
|
支持方法: initialize、notifications/initialized、ping、tools/list、tools/call。
|
||||||
|
|
||||||
|
9 个工具(qmt_kline / qmt_quote / qmt_tick / qmt_instrument / qmt_trading_dates /
|
||||||
|
|
||||||
|
qmt_positions / qmt_asset / qmt_orders / qmt_trades)与各 HTTP 查询接口 1:1。
|
||||||
|
|
||||||
|
请求/响应均为 JSON-RPC 2.0 信封;JSON-RPC 错误(parse/invalid/method not found/
|
||||||
|
|
||||||
|
invalid params/internal)走 HTTP 200;非法 body 走 400 {"detail":...}。
|
||||||
|
|
||||||
|
鉴权: 复用桥 TOKEN(X-Token header 或 ?token=)。
|
||||||
|
|
||||||
|
不做订阅/长连接(实时数据走 HTTP 订阅 + WS /ws 推送)。
|
||||||
|
|
||||||
|
详细设计见 docs/迭代记录/MCP服务.md。
|
||||||
|
|
||||||
|
'
|
||||||
|
requestBody:
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
description: JSON-RPC 2.0 请求对象(jsonrpc/id/method/params)
|
||||||
|
example:
|
||||||
|
jsonrpc: '2.0'
|
||||||
|
id: 1
|
||||||
|
method: tools/call
|
||||||
|
params:
|
||||||
|
name: qmt_quote
|
||||||
|
arguments:
|
||||||
|
code: 600519.SH
|
||||||
|
responses:
|
||||||
|
'200':
|
||||||
|
description: JSON-RPC 2.0 响应对象(含 result 或 error)
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: object
|
||||||
|
description: JSON-RPC 2.0 响应信封
|
||||||
|
example:
|
||||||
|
jsonrpc: '2.0'
|
||||||
|
id: 1
|
||||||
|
result:
|
||||||
|
content:
|
||||||
|
- type: text
|
||||||
|
text: '{"ok": true, "code": "600519.SH", "data": {...}}'
|
||||||
|
'400':
|
||||||
|
description: 非法 body(非 JSON-RPC 格式)
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/ErrorResponse'
|
||||||
|
example:
|
||||||
|
detail: parse error
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
ErrorResponse:
|
ErrorResponse:
|
||||||
|
|||||||
Reference in New Issue
Block a user