Skip to content

Commit 2125bf3

Browse files
committed
Add 165 server interaction tests for Python parity
Comprehensive test coverage matching Python's test_server_interactions.py: - TestTools, TestToolParameters, TestOutputSchema, TestContentTypes - TestResource, TestResourceTemplates, TestResourceAnnotations - TestPrompts, TestPromptVariations, TestMeta - TestCapabilities, TestProgressAndNotifications, TestRootsNotification - TestCancelledNotification, TestLogging, TestImageContent - TestEmbeddedResource, TestToolInputValidation, TestResourceSubscribe - TestCompletionEdgeCases, TestBatchOperations, TestTransportEdgeCases - Unicode, pagination, large data, error handling, and edge cases Also fixes iterator dereference bug in client.hpp when accessing structuredContent without registered outputSchema.
1 parent 54dc027 commit 2125bf3

3 files changed

Lines changed: 4937 additions & 4 deletions

File tree

‎CMakeLists.txt‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,10 @@ if(FASTMCPP_BUILD_TESTS)
229229
target_link_libraries(fastmcpp_server_patterns PRIVATE fastmcpp_core)
230230
add_test(NAME fastmcpp_server_patterns COMMAND fastmcpp_server_patterns)
231231

232+
add_executable(fastmcpp_server_interactions tests/server/interactions.cpp)
233+
target_link_libraries(fastmcpp_server_interactions PRIVATE fastmcpp_core)
234+
add_test(NAME fastmcpp_server_interactions COMMAND fastmcpp_server_interactions)
235+
232236
add_executable(fastmcpp_client_transports tests/client/transports.cpp)
233237
target_link_libraries(fastmcpp_client_transports PRIVATE fastmcpp_core)
234238
add_test(NAME fastmcpp_client_transports COMMAND fastmcpp_client_transports)

‎include/fastmcpp/client/client.hpp‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -594,10 +594,12 @@ class Client {
594594
if (wrap_result && structured.contains("result")) {
595595
result.data = coerce_to_schema(it->second["properties"]["result"], structured["result"]);
596596
} else if (structured.contains("result")) {
597-
result.data = coerce_to_schema(it->second.contains("properties") && it->second["properties"].contains("result")
598-
? it->second["properties"]["result"]
599-
: fastmcpp::Json::object(),
600-
structured["result"]);
597+
if (it != tool_output_schemas_.end() &&
598+
it->second.contains("properties") && it->second["properties"].contains("result")) {
599+
result.data = coerce_to_schema(it->second["properties"]["result"], structured["result"]);
600+
} else {
601+
result.data = structured["result"];
602+
}
601603
} else {
602604
if (it != tool_output_schemas_.end()) {
603605
result.data = coerce_to_schema(it->second, structured);

0 commit comments

Comments
 (0)