|
🛰️航天仿真算法库 SpaceAST 0.4.0
|
#include <McpServer.hpp>
Public 成员函数 | |
| void | setServerName (StringView name) |
| const std::string & | serverName () const |
| void | setServerVersion (StringView version) |
| const std::string & | serverVersion () const |
| void | setInstructions (StringView instructions) |
| const std::string & | instructions () const |
| ChatTools & | tools () |
| const ChatTools & | tools () const |
| McpTool * | addTool (std::unique_ptr< McpTool > tool) |
| template<typename T > | |
| McpTool * | addTool (std::unique_ptr< T > tool) |
| template<typename Func > | |
| McpTool * | addTool (Func func) |
| void | clearTools () |
| size_t | toolCount () const |
| McpTool * | findTool (StringView name) const |
| bool | handleRequest (const JsonValue &request, JsonValue &response) |
| std::string | handleLine (StringView line) |
| int | runStdio () |
MCP服务器
按行收发JSON-RPC消息,通过stdio与MCP客户端通信。 服务器只负责协议处理,不包含任何具体业务工具;工具通过 addTool 注册。
|
inline |
添加函数形式的工具
| func | 工具函数,签名为 std::string(const JsonValue&) |
| McpTool * ast::McpServer::findTool | ( | StringView | name | ) | const |
查找工具
| name | 工具名称 |
| std::string ast::McpServer::handleLine | ( | StringView | line | ) |
处理一行文本消息
| line | 一行JSON文本 |
处理一条JSON-RPC消息
| request | 请求 | |
| [out] | response | 响应 |
| int ast::McpServer::runStdio | ( | ) |
在stdio上运行服务器主循环