forked from xiaozhi/xiaozhi-esp32
[MCP] extend tools/list payload size to 8000
This commit is contained in:
@@ -11,7 +11,7 @@ dependencies:
|
|||||||
78/esp_lcd_nv3023: ~1.0.0
|
78/esp_lcd_nv3023: ~1.0.0
|
||||||
78/esp-wifi-connect: ~2.4.2
|
78/esp-wifi-connect: ~2.4.2
|
||||||
78/esp-opus-encoder: ~2.3.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
|
78/xiaozhi-fonts: ~1.3.2
|
||||||
espressif/led_strip: ^2.5.5
|
espressif/led_strip: ^2.5.5
|
||||||
espressif/esp_codec_dev: ~1.3.2
|
espressif/esp_codec_dev: ~1.3.2
|
||||||
|
|||||||
@@ -124,8 +124,10 @@ void McpServer::ParseMessage(const cJSON* json) {
|
|||||||
|
|
||||||
if (method_str == "initialize") {
|
if (method_str == "initialize") {
|
||||||
auto app_desc = esp_app_get_description();
|
auto app_desc = esp_app_get_description();
|
||||||
ReplyResult(id_int, "{\"protocolVersion\":\"2024-11-05\",\"capabilities\":{\"tools\":{}},"
|
std::string message = "{\"protocolVersion\":\"2024-11-05\",\"capabilities\":{\"tools\":{}},\"serverInfo\":{\"name\":\"" BOARD_NAME "\",\"version\":\"";
|
||||||
"\"serverInfo\":{\"name\":\"" BOARD_NAME "\",\"version\":\"" + std::string(app_desc->version) + "\"}}");
|
message += app_desc->version;
|
||||||
|
message += "\"}}";
|
||||||
|
ReplyResult(id_int, message);
|
||||||
} else if (method_str == "tools/list") {
|
} else if (method_str == "tools/list") {
|
||||||
std::string cursor_str = "";
|
std::string cursor_str = "";
|
||||||
if (params != nullptr) {
|
if (params != nullptr) {
|
||||||
@@ -161,18 +163,24 @@ void McpServer::ParseMessage(const cJSON* json) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void McpServer::ReplyResult(int id, const std::string& result) {
|
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);
|
Application::GetInstance().SendMcpMessage(payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
void McpServer::ReplyError(int id, const std::string& message) {
|
void McpServer::ReplyError(int id, const std::string& message) {
|
||||||
std::string payload = "{\"jsonrpc\":\"2.0\",\"id\":";
|
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);
|
Application::GetInstance().SendMcpMessage(payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
void McpServer::GetToolsList(int id, const std::string& cursor) {
|
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\":[";
|
std::string json = "{\"tools\":[";
|
||||||
|
|
||||||
bool found_cursor = cursor.empty();
|
bool found_cursor = cursor.empty();
|
||||||
|
|||||||
Reference in New Issue
Block a user