Skip to content

Commit bcde26e

Browse files
committed
style: apply clang-format
1 parent 6ad26bf commit bcde26e

8 files changed

Lines changed: 38 additions & 32 deletions

File tree

include/fastmcpp/client/client.hpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,8 @@ class IResettableTransport
5959
using ServerRequestHandler =
6060
std::function<fastmcpp::Json(const std::string& method, const fastmcpp::Json& params)>;
6161

62-
/// Optional transport interface: some transports can accept server-initiated requests and send responses.
62+
/// Optional transport interface: some transports can accept server-initiated requests and send
63+
/// responses.
6364
class IServerRequestTransport
6465
{
6566
public:
@@ -663,7 +664,7 @@ class Client
663664
}
664665

665666
/// Register roots/sampling/elicitation callbacks (placeholders for parity)
666-
void set_roots_callback(const std::function<fastmcpp::Json()>& cb)
667+
void set_roots_callback(const std::function<fastmcpp::Json()>& cb)
667668
{
668669
set_roots_callback_impl(cb);
669670
}
@@ -714,7 +715,7 @@ class Client
714715
};
715716

716717
std::shared_ptr<CallbackState> callbacks_;
717-
std::unordered_map<std::string, fastmcpp::Json> tool_output_schemas_;
718+
std::unordered_map<std::string, fastmcpp::Json> tool_output_schemas_;
718719

719720
std::function<fastmcpp::Json()> get_roots_callback() const
720721
{
@@ -745,16 +746,15 @@ class Client
745746
std::lock_guard<std::mutex> lock(callbacks_->mutex);
746747
callbacks_->roots_callback = cb;
747748
}
748-
void set_sampling_callback_impl(
749-
const std::function<fastmcpp::Json(const fastmcpp::Json&)>& cb)
749+
void set_sampling_callback_impl(const std::function<fastmcpp::Json(const fastmcpp::Json&)>& cb)
750750
{
751751
if (!callbacks_)
752752
callbacks_ = std::make_shared<CallbackState>();
753753
std::lock_guard<std::mutex> lock(callbacks_->mutex);
754754
callbacks_->sampling_callback = cb;
755755
}
756-
void set_elicitation_callback_impl(
757-
const std::function<fastmcpp::Json(const fastmcpp::Json&)>& cb)
756+
void
757+
set_elicitation_callback_impl(const std::function<fastmcpp::Json(const fastmcpp::Json&)>& cb)
758758
{
759759
if (!callbacks_)
760760
callbacks_ = std::make_shared<CallbackState>();
@@ -811,7 +811,8 @@ class Client
811811
}
812812

813813
// Internal constructor for cloning
814-
Client(std::shared_ptr<ITransport> t, std::shared_ptr<CallbackState> callbacks, bool /*internal*/)
814+
Client(std::shared_ptr<ITransport> t, std::shared_ptr<CallbackState> callbacks,
815+
bool /*internal*/)
815816
: transport_(std::move(t)), callbacks_(std::move(callbacks))
816817
{
817818
configure_transport_callbacks();

include/fastmcpp/client/sampling.hpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@ using SamplingHandlerResult = std::variant<std::string, fastmcpp::Json>;
2222
using SamplingHandler = std::function<SamplingHandlerResult(const fastmcpp::Json& params)>;
2323

2424
/// Build a minimal MCP CreateMessageResult with a single text content block.
25-
inline fastmcpp::Json make_text_result(std::string text,
26-
std::string model = "fastmcpp-client",
27-
std::string role = "assistant")
25+
inline fastmcpp::Json make_text_result(std::string text, std::string model = "fastmcpp-client",
26+
std::string role = "assistant")
2827
{
2928
return fastmcpp::Json{
3029
{"role", std::move(role)},
3130
{"model", std::move(model)},
32-
{"content", fastmcpp::Json::array(
33-
{fastmcpp::Json{{"type", "text"}, {"text", std::move(text)}}})},
31+
{"content",
32+
fastmcpp::Json::array({fastmcpp::Json{{"type", "text"}, {"text", std::move(text)}}})},
3433
};
3534
}
3635

@@ -49,4 +48,3 @@ create_sampling_callback(SamplingHandler handler)
4948
}
5049

5150
} // namespace fastmcpp::client::sampling
52-

include/fastmcpp/client/transports.hpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ class StdioTransport : public ITransport
9696
/// 1. Client connects to /sse endpoint (GET) to establish event stream
9797
/// 2. Client sends JSON-RPC requests to /messages endpoint (POST)
9898
/// 3. Server sends JSON-RPC responses back via the SSE stream
99-
class SseClientTransport : public ITransport, public IServerRequestTransport, public IResettableTransport
99+
class SseClientTransport : public ITransport,
100+
public IServerRequestTransport,
101+
public IResettableTransport
100102
{
101103
public:
102104
/// Construct an SSE client transport
@@ -121,7 +123,7 @@ class SseClientTransport : public ITransport, public IServerRequestTransport, pu
121123
/// Check if a session ID has been set.
122124
bool has_session() const;
123125

124-
void set_server_request_handler(ServerRequestHandler handler) override;
126+
void set_server_request_handler(ServerRequestHandler handler) override;
125127

126128
void reset(bool full = false) override;
127129

include/fastmcpp/client/types.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,7 +343,7 @@ inline void from_json(const fastmcpp::Json& j, ToolInfo& t)
343343
t.title = j["title"].get<std::string>();
344344
if (j.contains("description"))
345345
t.description = j["description"].get<std::string>();
346-
t.inputSchema = j.value("inputSchema", fastmcpp::Json::object());
346+
t.inputSchema = j.value("inputSchema", fastmcpp::Json::object());
347347
if (j.contains("outputSchema"))
348348
t.outputSchema = j["outputSchema"];
349349
if (j.contains("execution"))
@@ -389,7 +389,7 @@ inline void from_json(const fastmcpp::Json& j, ResourceInfo& r)
389389
r._meta = j["_meta"];
390390
}
391391

392-
inline void to_json(fastmcpp::Json& j, const ResourceTemplate& t)
392+
inline void to_json(fastmcpp::Json& j, const ResourceTemplate& t)
393393
{
394394
j = fastmcpp::Json{{"uriTemplate", t.uriTemplate}, {"name", t.name}};
395395
if (t.title)
@@ -406,7 +406,7 @@ inline void to_json(fastmcpp::Json& j, const ResourceTemplate& t)
406406
j["_meta"] = *t._meta;
407407
}
408408

409-
inline void from_json(const fastmcpp::Json& j, ResourceTemplate& t)
409+
inline void from_json(const fastmcpp::Json& j, ResourceTemplate& t)
410410
{
411411
t.uriTemplate = j.at("uriTemplate").get<std::string>();
412412
t.name = j.at("name").get<std::string>();

src/client/transports.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -708,7 +708,7 @@ void SseClientTransport::start_sse_listener()
708708

709709
if (!aggregated.empty())
710710
{
711-
// Handle endpoint event specially - it's not JSON
711+
// Handle endpoint event specially - it's not JSON
712712
if (event_type == "endpoint")
713713
{
714714
std::lock_guard<std::mutex> lock(endpoint_mutex_);
@@ -721,9 +721,9 @@ void SseClientTransport::start_sse_listener()
721721
{
722722
pos += std::string("session_id=").size();
723723
auto end = endpoint_path_.find_first_of("&#", pos);
724-
session_id_ = endpoint_path_.substr(
725-
pos, end == std::string::npos ? std::string::npos
726-
: (end - pos));
724+
session_id_ = endpoint_path_.substr(pos, end == std::string::npos
725+
? std::string::npos
726+
: (end - pos));
727727
}
728728
}
729729
else
@@ -919,7 +919,7 @@ fastmcpp::Json SseClientTransport::request(const std::string& route, const fastm
919919
cli.set_connection_timeout(5, 0);
920920
cli.set_read_timeout(30, 0);
921921

922-
// Use the endpoint path from SSE if available, otherwise use default
922+
// Use the endpoint path from SSE if available, otherwise use default
923923
std::string post_path;
924924
{
925925
std::lock_guard<std::mutex> lock(endpoint_mutex_);

tests/server/interactions_part2b.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -904,7 +904,7 @@ void test_tool_meta_custom_fields()
904904
std::cout << "Test: tool list with meta fields...\n";
905905

906906
auto srv = create_meta_variations_server();
907-
client::Client c(std::make_unique<client::LoopbackTransport>(srv));
907+
client::Client c(std::make_unique<client::LoopbackTransport>(srv));
908908

909909
// Test that list_tools_mcp can access list-level _meta
910910
auto result = c.list_tools_mcp();
@@ -959,7 +959,7 @@ void test_resource_meta_fields()
959959
std::cout << "Test: resource with meta fields...\n";
960960

961961
auto srv = create_meta_variations_server();
962-
client::Client c(std::make_unique<client::LoopbackTransport>(srv));
962+
client::Client c(std::make_unique<client::LoopbackTransport>(srv));
963963

964964
auto resources = c.list_resources();
965965
bool found = false;

tests/server/sse_bidirectional_requests.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,9 @@ Json make_result_response(const Json& request_id, Json result)
2828

2929
Json make_error_response(const Json& request_id, int code, const std::string& message)
3030
{
31-
return Json{{"jsonrpc", "2.0"}, {"id", request_id}, {"error", Json{{"code", code}, {"message", message}}}};
31+
return Json{{"jsonrpc", "2.0"},
32+
{"id", request_id},
33+
{"error", Json{{"code", code}, {"message", message}}}};
3234
}
3335
} // namespace
3436

@@ -101,8 +103,8 @@ int main()
101103

102104
std::this_thread::sleep_for(500ms);
103105

104-
auto transport = std::make_unique<fastmcpp::client::SseClientTransport>(
105-
"http://127.0.0.1:" + std::to_string(port));
106+
auto transport = std::make_unique<fastmcpp::client::SseClientTransport>("http://127.0.0.1:" +
107+
std::to_string(port));
106108
auto* sse_transport = transport.get();
107109
fastmcpp::client::Client client(std::move(transport));
108110

@@ -178,7 +180,8 @@ int main()
178180
Json result;
179181
try
180182
{
181-
result = session->send_request("sampling/createMessage", params, std::chrono::milliseconds(5000));
183+
result = session->send_request("sampling/createMessage", params,
184+
std::chrono::milliseconds(5000));
182185
}
183186
catch (const std::exception& e)
184187
{
@@ -201,7 +204,8 @@ int main()
201204
}
202205
if (result.value("model", std::string()) != "fastmcpp-client")
203206
{
204-
std::cerr << "Unexpected model in sampling response: " << result.value("model", std::string()) << "\n";
207+
std::cerr << "Unexpected model in sampling response: "
208+
<< result.value("model", std::string()) << "\n";
205209
sse_server->stop();
206210
return 1;
207211
}

tests/server/streamable_http_integration.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,8 @@ void test_session_management()
238238
transport.request("initialize", init_params);
239239
assert(transport.has_session() && "Should have session after re-initialize");
240240
assert(transport.session_id() != session_id && "Session ID should change after reset");
241-
assert(server.session_count() == 2 && "Server should have 2 sessions after reset + initialize");
241+
assert(server.session_count() == 2 &&
242+
"Server should have 2 sessions after reset + initialize");
242243

243244
std::cout << "PASSED\n";
244245
}

0 commit comments

Comments
 (0)