@@ -307,185 +307,273 @@ interface是智能体对外提供的接口,Interface分为两类接口:
307307
308308#### JSON-RPC 2.0 接口描述文档
309309
310- 下面是一个JSON -RPC 2.0 接口描述文档的示例 :
310+ 下面是一个符合OpenRPC规范的JSON -RPC 2.0 接口描述文档示例 :
311311
312312``` json
313313{
314- "protocolType" : " ANP" ,
315- "protocolVersion" : " 1.0.0" ,
316- "type" : " JSON-RPC 2.0" ,
317- "url" : " https://grand-hotel.com/api/jsonrpc-interface.json" ,
318- "security" : {
319- "didwba" : {
320- "scheme" : " didwba" ,
321- "in" : " header" ,
322- "name" : " Authorization"
323- }
314+ "openrpc" : " 1.3.2" ,
315+ "info" : {
316+ "title" : " Grand Hotel Services API" ,
317+ "version" : " 1.0.0" ,
318+ "description" : " JSON-RPC 2.0 API for hotel services including room management, booking, and guest services" ,
319+ "x-anp-protocol-type" : " ANP" ,
320+ "x-anp-protocol-version" : " 1.0.0"
324321 },
325- "transport" : {
322+ "security" : [
323+ {
324+ "didwba" : []
325+ }
326+ ],
327+ "servers" : [
328+ {
329+ "name" : " Production Server" ,
330+ "url" : " https://grand-hotel.com/api/v1/jsonrpc" ,
331+ "description" : " Production server for Grand Hotel API"
332+ }
333+ ],
334+ "x-transport" : {
326335 "protocol" : " HTTPS" ,
327336 "host" : " grand-hotel.com" ,
328337 "path" : " /api/v1/jsonrpc" ,
329338 "method" : " POST" ,
330339 "port" : 443 ,
331- "contentType" : " application/json" ,
332- },
333- "info" : {
334- "title" : " Grand Hotel Services API" ,
335- "version" : " 1.0.0" ,
336- "description" : " JSON-RPC 2.0 API for hotel services including room management, booking, and guest services"
340+ "contentType" : " application/json"
337341 },
338342 "methods" : [
339343 {
340344 "name" : " searchRooms" ,
341- "description" : " Search available hotel rooms based on criteria" ,
342- "params" : {
343- "type" : " object" ,
344- "properties" : {
345- "checkIn" : {
346- "type" : " string" ,
347- "format" : " date" ,
348- "description" : " Check-in date in YYYY-MM-DD format"
349- },
350- "checkOut" : {
351- "type" : " string" ,
352- "format" : " date" ,
353- "description" : " Check-out date in YYYY-MM-DD format"
354- },
355- "guests" : {
356- "type" : " integer" ,
357- "minimum" : 1 ,
358- "maximum" : 8 ,
359- "description" : " Number of guests"
360- },
361- "roomType" : {
362- "type" : " string" ,
363- "enum" : [" standard" , " deluxe" , " suite" , " presidential" ],
364- "description" : " Preferred room type"
345+ "summary" : " Search available hotel rooms" ,
346+ "description" : " Search available hotel rooms based on criteria such as dates, number of guests, and room type" ,
347+ "params" : [
348+ {
349+ "name" : " searchCriteria" ,
350+ "description" : " Room search criteria" ,
351+ "required" : true ,
352+ "schema" : {
353+ "type" : " object" ,
354+ "properties" : {
355+ "checkIn" : {
356+ "type" : " string" ,
357+ "format" : " date" ,
358+ "description" : " Check-in date in YYYY-MM-DD format"
359+ },
360+ "checkOut" : {
361+ "type" : " string" ,
362+ "format" : " date" ,
363+ "description" : " Check-out date in YYYY-MM-DD format"
364+ },
365+ "guests" : {
366+ "type" : " integer" ,
367+ "minimum" : 1 ,
368+ "maximum" : 8 ,
369+ "description" : " Number of guests"
370+ },
371+ "roomType" : {
372+ "type" : " string" ,
373+ "enum" : [" standard" , " deluxe" , " suite" , " presidential" ],
374+ "description" : " Preferred room type"
375+ }
376+ },
377+ "required" : [" checkIn" , " checkOut" , " guests" ]
365378 }
366- },
367- "required" : [" checkIn" , " checkOut" , " guests" ]
368- },
379+ }
380+ ],
369381 "result" : {
370- "type" : " object" ,
371- "properties" : {
372- "rooms" : {
373- "type" : " array" ,
374- "items" : {
375- "$ref" : " #/definitions/Room"
382+ "name" : " searchResult" ,
383+ "description" : " Search results containing available rooms" ,
384+ "schema" : {
385+ "type" : " object" ,
386+ "properties" : {
387+ "rooms" : {
388+ "type" : " array" ,
389+ "items" : {
390+ "$ref" : " #/components/schemas/Room"
391+ }
392+ },
393+ "total" : {
394+ "type" : " integer" ,
395+ "description" : " Total number of available rooms"
376396 }
377- },
378- "total" : {
379- "type" : " integer" ,
380- "description" : " Total number of available rooms"
381397 }
382398 }
383399 }
384400 },
385401 {
386402 "name" : " makeReservation" ,
387- "description" : " Create a new hotel reservation" ,
388- "params" : {
403+ "summary" : " Create hotel reservation" ,
404+ "description" : " Create a new hotel reservation with guest information and booking details" ,
405+ "params" : [
406+ {
407+ "name" : " reservationData" ,
408+ "description" : " Reservation information" ,
409+ "required" : true ,
410+ "schema" : {
411+ "type" : " object" ,
412+ "properties" : {
413+ "roomId" : {
414+ "type" : " string" ,
415+ "description" : " Unique room identifier"
416+ },
417+ "guestInfo" : {
418+ "$ref" : " #/components/schemas/GuestInfo"
419+ },
420+ "checkIn" : {
421+ "type" : " string" ,
422+ "format" : " date" ,
423+ "description" : " Check-in date"
424+ },
425+ "checkOut" : {
426+ "type" : " string" ,
427+ "format" : " date" ,
428+ "description" : " Check-out date"
429+ },
430+ "specialRequests" : {
431+ "type" : " string" ,
432+ "description" : " Special requests or preferences"
433+ }
434+ },
435+ "required" : [" roomId" , " guestInfo" , " checkIn" , " checkOut" ]
436+ }
437+ }
438+ ],
439+ "result" : {
440+ "name" : " reservationResult" ,
441+ "description" : " Reservation confirmation details" ,
442+ "schema" : {
443+ "type" : " object" ,
444+ "properties" : {
445+ "reservationId" : {
446+ "type" : " string" ,
447+ "description" : " Unique reservation identifier"
448+ },
449+ "confirmationNumber" : {
450+ "type" : " string" ,
451+ "description" : " Booking confirmation number"
452+ },
453+ "totalAmount" : {
454+ "type" : " number" ,
455+ "description" : " Total reservation amount"
456+ }
457+ }
458+ }
459+ }
460+ }
461+ ],
462+ "components" : {
463+ "securitySchemes" : {
464+ "didwba" : {
465+ "type" : " http" ,
466+ "scheme" : " bearer" ,
467+ "bearerFormat" : " DID-WBA" ,
468+ "description" : " DID-WBA authentication scheme"
469+ }
470+ },
471+ "schemas" : {
472+ "Room" : {
389473 "type" : " object" ,
390474 "properties" : {
391- "roomId " : {
475+ "id " : {
392476 "type" : " string" ,
393477 "description" : " Unique room identifier"
394478 },
395- "guestInfo" : {
396- "$ref" : " #/definitions/GuestInfo"
397- },
398- "checkIn" : {
479+ "type" : {
399480 "type" : " string" ,
400- "format " : " date "
481+ "description " : " Room type "
401482 },
402- "checkOut " : {
403- "type" : " string " ,
404- "format " : " date "
483+ "price " : {
484+ "type" : " number " ,
485+ "description " : " Room price per night "
405486 },
406- "specialRequests" : {
407- "type" : " string" ,
408- "description" : " Special requests or preferences"
487+ "amenities" : {
488+ "type" : " array" ,
489+ "items" : {
490+ "type" : " string"
491+ },
492+ "description" : " List of room amenities"
493+ },
494+ "availability" : {
495+ "type" : " boolean" ,
496+ "description" : " Room availability status"
409497 }
410- },
411- "required" : [" roomId" , " guestInfo" , " checkIn" , " checkOut" ]
498+ }
412499 },
413- "result " : {
500+ "GuestInfo " : {
414501 "type" : " object" ,
415502 "properties" : {
416- "reservationId " : {
503+ "firstName " : {
417504 "type" : " string" ,
418- "description" : " Unique reservation identifier "
505+ "description" : " Guest's first name "
419506 },
420- "confirmationNumber " : {
507+ "lastName " : {
421508 "type" : " string" ,
422- "description" : " Booking confirmation number "
509+ "description" : " Guest's last name "
423510 },
424- "totalAmount" : {
425- "type" : " number" ,
426- "description" : " Total reservation amount"
511+ "email" : {
512+ "type" : " string" ,
513+ "format" : " email" ,
514+ "description" : " Guest's email address"
515+ },
516+ "phone" : {
517+ "type" : " string" ,
518+ "description" : " Guest's phone number"
427519 }
428- }
520+ },
521+ "required" : [" firstName" , " lastName" , " email" ]
429522 }
430523 }
431- ],
432- "definitions" : {
433- "Room" : {
434- "type" : " object" ,
435- "properties" : {
436- "id" : {"type" : " string" },
437- "type" : {"type" : " string" },
438- "price" : {"type" : " number" },
439- "amenities" : {"type" : " array" , "items" : {"type" : " string" }},
440- "availability" : {"type" : " boolean" }
441- }
442- },
443- "GuestInfo" : {
444- "type" : " object" ,
445- "properties" : {
446- "firstName" : {"type" : " string" },
447- "lastName" : {"type" : " string" },
448- "email" : {"type" : " string" , "format" : " email" },
449- "phone" : {"type" : " string" }
450- },
451- "required" : [" firstName" , " lastName" , " email" ]
452- }
453524 }
454525}
455526```
456527
457- ##### JSON-RPC 2.0 接口文档字段说明
528+ ##### OpenRPC规范字段说明
458529
459530| 字段名称 | 类型 | 是否必需 | 描述 |
460531| ---------| ------| ---------| ------|
461- | jsonrpc | string | 必需 | JSON-RPC协议版本,固定值为"2.0" |
462- | security | object | 必需 | 安全机制定义,包含认证方式和参数配置 |
463- | transport | object | 必需 | 传输层配置,包含协议、端点、方法等信息 |
464- | info | object | 必需 | API基本信息,包含标题、版本、描述 |
532+ | openrpc | string | 必需 | OpenRPC规范版本,当前使用"1.3.2" |
533+ | info | object | 必需 | API基本信息,包含标题、版本、描述等 |
534+ | servers | array | 可选 | 服务器列表,定义API端点地址 |
465535| methods | array | 必需 | 可调用的方法列表 |
466- | definitions | object | 可选 | 数据结构定义,用于复用 |
536+ | components | object | 可选 | 可复用的组件定义,包括schemas和securitySchemes |
537+ | security | array | 可选 | 安全要求定义 |
538+ | x-transport | object | 可选 | ANP扩展字段:传输层配置信息 |
539+
540+ ##### Info对象字段说明
541+
542+ | 字段名称 | 类型 | 描述 |
543+ | ---------| ------| ------|
544+ | title | string | API名称 |
545+ | version | string | API版本号 |
546+ | description | string | API功能描述 |
547+ | x-anp-protocol-type | string | ANP扩展字段:协议类型 |
548+ | x-anp-protocol-version | string | ANP扩展字段:ANP协议版本 |
467549
468- ##### Transport对象字段说明
550+ ##### X- Transport对象字段说明(ANP扩展)
469551
470552| 字段名称 | 类型 | 描述 |
471553| ---------| ------| ------|
472554| protocol | string | 传输协议,如"HTTPS"、"HTTP" |
473555| host | string | 服务器主机名 |
474- | basePath | string | API基础路径 |
475- | endpoint | string | 具体的API端点路径 |
556+ | path | string | API端点路径 |
476557| port | integer | 端口号,HTTPS默认443,HTTP默认80 |
477558| method | string | HTTP请求方法,JSON-RPC通常使用"POST" |
478559| contentType | string | 内容类型,通常为"application/json" |
479- | fullUrl | string | 完整的API访问地址 |
480560
481561##### Method对象字段说明
482562
483563| 字段名称 | 类型 | 描述 |
484564| ---------| ------| ------|
485565| name | string | 方法名称,用于RPC调用 |
486- | description | string | 方法功能描述 |
487- | params | object | 输入参数的JSON Schema定义 |
488- | result | object | 返回结果的JSON Schema定义 |
566+ | summary | string | 方法简要描述 |
567+ | description | string | 方法详细功能描述 |
568+ | params | array | 输入参数列表,每个参数包含name、description、required和schema |
569+ | result | object | 返回结果定义,包含name、description和schema |
570+
571+ ##### Components对象字段说明
572+
573+ | 字段名称 | 类型 | 描述 |
574+ | ---------| ------| ------|
575+ | schemas | object | 数据结构定义,用于复用 |
576+ | securitySchemes | object | 安全认证方案定义 |
489577
490578#### MCP server接口文档描述
491579
0 commit comments