mirror of
https://github.com/78/xiaozhi-esp32.git
synced 2026-01-14 09:17:20 +08:00
[MCP] extend tools/list payload size to 8000
Some checks failed
Build and Test / build (push) Has been cancelled
Some checks failed
Build and Test / build (push) Has been cancelled
This commit is contained in:
parent
0b98392286
commit
6d5331dddd
@ -11,7 +11,7 @@ dependencies:
|
||||
78/esp_lcd_nv3023: ~1.0.0
|
||||
78/esp-wifi-connect: ~2.4.2
|
||||
78/esp-opus-encoder: ~2.3.2
|
||||
78/esp-ml307: ~2.0.2
|
||||
78/esp-ml307: ~2.0.3
|
||||
78/xiaozhi-fonts: ~1.3.2
|
||||
espressif/led_strip: ^2.5.5
|
||||
espressif/esp_codec_dev: ~1.3.2
|
||||
|
||||
@ -124,8 +124,10 @@ void McpServer::ParseMessage(const cJSON* json) {
|
||||
|
||||
if (method_str == "initialize") {
|
||||
auto app_desc = esp_app_get_description();
|
||||
ReplyResult(id_int, "{\"protocolVersion\":\"2024-11-05\",\"capabilities\":{\"tools\":{}},"
|
||||
"\"serverInfo\":{\"name\":\"" BOARD_NAME "\",\"version\":\"" + std::string(app_desc->version) + "\"}}");
|
||||
std::string message = "{\"protocolVersion\":\"2024-11-05\",\"capabilities\":{\"tools\":{}},\"serverInfo\":{\"name\":\"" BOARD_NAME "\",\"version\":\"";
|
||||
message += app_desc->version;
|
||||
message += "\"}}";
|
||||
ReplyResult(id_int, message);
|
||||
} else if (method_str == "tools/list") {
|
||||
std::string cursor_str = "";
|
||||
if (params != nullptr) {
|
||||
@ -161,18 +163,24 @@ void McpServer::ParseMessage(const cJSON* json) {
|
||||
}
|
||||
|
||||
void McpServer::ReplyResult(int id, const std::string& result) {
|
||||
std::string payload = "{\"jsonrpc\":\"2.0\",\"id\":" + std::to_string(id) + ",\"result\":" + result + "}";
|
||||
std::string payload = "{\"jsonrpc\":\"2.0\",\"id\":";
|
||||
payload += std::to_string(id) + ",\"result\":";
|
||||
payload += result;
|
||||
payload += "}";
|
||||
Application::GetInstance().SendMcpMessage(payload);
|
||||
}
|
||||
|
||||
void McpServer::ReplyError(int id, const std::string& message) {
|
||||
std::string payload = "{\"jsonrpc\":\"2.0\",\"id\":";
|
||||
payload += std::to_string(id) + ",\"error\":{\"message\":\"" + message + "\"}}";
|
||||
payload += std::to_string(id);
|
||||
payload += ",\"error\":{\"message\":\"";
|
||||
payload += message;
|
||||
payload += "\"}}";
|
||||
Application::GetInstance().SendMcpMessage(payload);
|
||||
}
|
||||
|
||||
void McpServer::GetToolsList(int id, const std::string& cursor) {
|
||||
const int max_payload_size = 1400; // ML307 MQTT publish size limit
|
||||
const int max_payload_size = 8000;
|
||||
std::string json = "{\"tools\":[";
|
||||
|
||||
bool found_cursor = cursor.empty();
|
||||
|
||||
Loading…
Reference in New Issue
Block a user