Skip to content

Commit 698ebce

Browse files
authored
Merge pull request #36 from 0xeb/fix/format-check-2026-02-28
style: apply clang-format for CI format-check
2 parents d76ae63 + e00aa09 commit 698ebce

12 files changed

Lines changed: 56 additions & 66 deletions

File tree

examples/instructions_server.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -40,24 +40,22 @@ int main(int argc, char* argv[])
4040
FastMCP app("instructions_http_server", "2.0.0",
4141
/*website_url=*/std::nullopt,
4242
/*icons=*/std::nullopt,
43-
/*instructions=*/std::string(
44-
"This server provides echo and add tools. "
45-
"Use 'echo' to repeat a message, and 'add' to sum two numbers."));
43+
/*instructions=*/
44+
std::string("This server provides echo and add tools. "
45+
"Use 'echo' to repeat a message, and 'add' to sum two numbers."));
4646

47-
app.tool(
48-
"echo",
49-
Json{{"type", "object"},
50-
{"properties", Json{{"message", Json{{"type", "string"}}}}},
51-
{"required", Json::array({"message"})}},
52-
[](const Json& args) { return args.at("message"); });
47+
app.tool("echo",
48+
Json{{"type", "object"},
49+
{"properties", Json{{"message", Json{{"type", "string"}}}}},
50+
{"required", Json::array({"message"})}},
51+
[](const Json& args) { return args.at("message"); });
5352

5453
app.tool(
5554
"add",
5655
Json{{"type", "object"},
5756
{"properties", Json{{"a", Json{{"type", "number"}}}, {"b", Json{{"type", "number"}}}}},
5857
{"required", Json::array({"a", "b"})}},
59-
[](const Json& args)
60-
{ return args.at("a").get<double>() + args.at("b").get<double>(); });
58+
[](const Json& args) { return args.at("a").get<double>() + args.at("b").get<double>(); });
6159

6260
auto handler = fastmcpp::mcp::make_mcp_handler(app);
6361

examples/stdio_instructions_server.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,22 @@ int main()
1313
fastmcpp::FastMCP app("instructions_e2e_server", "1.0.0",
1414
/*website_url=*/std::nullopt,
1515
/*icons=*/std::nullopt,
16-
/*instructions=*/std::string("This server provides echo and math tools. "
17-
"Use 'echo' to repeat input and 'add' to sum two numbers."));
16+
/*instructions=*/
17+
std::string("This server provides echo and math tools. "
18+
"Use 'echo' to repeat input and 'add' to sum two numbers."));
1819

19-
app.tool(
20-
"echo",
21-
Json{{"type", "object"},
22-
{"properties", Json{{"message", Json{{"type", "string"}}}}},
23-
{"required", Json::array({"message"})}},
24-
[](const Json& args) { return args.at("message"); });
20+
app.tool("echo",
21+
Json{{"type", "object"},
22+
{"properties", Json{{"message", Json{{"type", "string"}}}}},
23+
{"required", Json::array({"message"})}},
24+
[](const Json& args) { return args.at("message"); });
2525

2626
app.tool(
2727
"add",
2828
Json{{"type", "object"},
2929
{"properties", Json{{"a", Json{{"type", "number"}}}, {"b", Json{{"type", "number"}}}}},
3030
{"required", Json::array({"a", "b"})}},
31-
[](const Json& args)
32-
{ return args.at("a").get<double>() + args.at("b").get<double>(); });
31+
[](const Json& args) { return args.at("a").get<double>() + args.at("b").get<double>(); });
3332

3433
auto handler = fastmcpp::mcp::make_mcp_handler(app);
3534
fastmcpp::server::StdioServerWrapper server(handler);

include/fastmcpp/app.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ class FastMCP
121121
/// Backward-compatible constructor overload (legacy parameter order).
122122
FastMCP(std::string name, std::string version, std::optional<std::string> website_url,
123123
std::optional<std::vector<Icon>> icons,
124-
std::vector<std::shared_ptr<providers::Provider>> providers,
125-
int list_page_size = 0, bool dereference_schemas = true);
124+
std::vector<std::shared_ptr<providers::Provider>> providers, int list_page_size = 0,
125+
bool dereference_schemas = true);
126126
/// Backward-compatible constructor overload for `{}` provider arguments.
127127
FastMCP(std::string name, std::string version, std::optional<std::string> website_url,
128128
std::optional<std::vector<Icon>> icons,

include/fastmcpp/client/client.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -937,8 +937,8 @@ class Client
937937
if (error.contains("code") && error["code"].is_number_integer())
938938
{
939939
throw fastmcpp::Error("JSON-RPC error (" +
940-
std::to_string(error["code"].get<int>()) + "): " +
941-
message);
940+
std::to_string(error["code"].get<int>()) +
941+
"): " + message);
942942
}
943943
throw fastmcpp::Error("JSON-RPC error: " + message);
944944
}

include/fastmcpp/mcp/handler.hpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,12 @@ using SessionAccessor = std::function<std::shared_ptr<server::ServerSession>(con
3535
// - "tools/list"
3636
// - "tools/call"
3737
// The ToolManager provides invocation and input schema; descriptions are optional.
38-
std::function<fastmcpp::Json(const fastmcpp::Json&)> make_mcp_handler(
39-
const std::string& server_name, const std::string& version, const tools::ToolManager& tools,
40-
const std::unordered_map<std::string, std::string>& descriptions = {},
41-
const std::unordered_map<std::string, fastmcpp::Json>& input_schemas_override = {},
42-
const std::optional<std::string>& instructions = std::nullopt);
38+
std::function<fastmcpp::Json(const fastmcpp::Json&)>
39+
make_mcp_handler(const std::string& server_name, const std::string& version,
40+
const tools::ToolManager& tools,
41+
const std::unordered_map<std::string, std::string>& descriptions = {},
42+
const std::unordered_map<std::string, fastmcpp::Json>& input_schemas_override = {},
43+
const std::optional<std::string>& instructions = std::nullopt);
4344

4445
// Overload: build a handler from a generic Server plus explicit tool metadata.
4546
// tools_meta: vector of (tool_name, description, inputSchema)

src/app.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@ namespace fastmcpp
1616
{
1717

1818
FastMCP::FastMCP(std::string name, std::string version, std::optional<std::string> website_url,
19-
std::optional<std::vector<Icon>> icons,
20-
std::optional<std::string> instructions,
19+
std::optional<std::vector<Icon>> icons, std::optional<std::string> instructions,
2120
std::vector<std::shared_ptr<providers::Provider>> providers, int list_page_size,
2221
bool dereference_schemas)
2322
: server_(std::move(name), std::move(version), std::move(website_url), std::move(icons),

src/mcp/handler.cpp

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -922,13 +922,11 @@ make_mcp_handler(const std::string& server_name, const std::string& version,
922922
fastmcpp::Json result_obj = {
923923
{"protocolVersion", "2024-11-05"},
924924
{"capabilities", fastmcpp::Json{{"tools", fastmcpp::Json::object()}}},
925-
{"serverInfo",
926-
fastmcpp::Json{{"name", server_name}, {"version", version}}},
925+
{"serverInfo", fastmcpp::Json{{"name", server_name}, {"version", version}}},
927926
};
928927
if (instructions.has_value())
929928
result_obj["instructions"] = *instructions;
930-
return fastmcpp::Json{
931-
{"jsonrpc", "2.0"}, {"id", id}, {"result", result_obj}};
929+
return fastmcpp::Json{{"jsonrpc", "2.0"}, {"id", id}, {"result", result_obj}};
932930
}
933931

934932
if (method == "ping")
@@ -1103,8 +1101,7 @@ std::function<fastmcpp::Json(const fastmcpp::Json&)> make_mcp_handler(
11031101
{"serverInfo", serverInfo}};
11041102
if (server.instructions().has_value())
11051103
result_obj["instructions"] = *server.instructions();
1106-
return fastmcpp::Json{
1107-
{"jsonrpc", "2.0"}, {"id", id}, {"result", result_obj}};
1104+
return fastmcpp::Json{{"jsonrpc", "2.0"}, {"id", id}, {"result", result_obj}};
11081105
}
11091106

11101107
if (method == "ping")
@@ -1329,8 +1326,7 @@ make_mcp_handler(const std::string& server_name, const std::string& version,
13291326
{"serverInfo", serverInfo}};
13301327
if (server.instructions().has_value())
13311328
result_obj["instructions"] = *server.instructions();
1332-
return fastmcpp::Json{
1333-
{"jsonrpc", "2.0"}, {"id", id}, {"result", result_obj}};
1329+
return fastmcpp::Json{{"jsonrpc", "2.0"}, {"id", id}, {"result", result_obj}};
13341330
}
13351331

13361332
if (method == "ping")
@@ -1510,8 +1506,7 @@ make_mcp_handler(const std::string& server_name, const std::string& version,
15101506
{"serverInfo", serverInfo}};
15111507
if (server.instructions().has_value())
15121508
result_obj["instructions"] = *server.instructions();
1513-
return fastmcpp::Json{
1514-
{"jsonrpc", "2.0"}, {"id", id}, {"result", result_obj}};
1509+
return fastmcpp::Json{{"jsonrpc", "2.0"}, {"id", id}, {"result", result_obj}};
15151510
}
15161511

15171512
if (method == "ping")
@@ -1846,8 +1841,7 @@ make_mcp_handler(const FastMCP& app, SessionAccessor session_accessor)
18461841
{"serverInfo", serverInfo}};
18471842
if (app.instructions().has_value())
18481843
result_obj["instructions"] = *app.instructions();
1849-
return fastmcpp::Json{
1850-
{"jsonrpc", "2.0"}, {"id", id}, {"result", result_obj}};
1844+
return fastmcpp::Json{{"jsonrpc", "2.0"}, {"id", id}, {"result", result_obj}};
18511845
}
18521846

18531847
if (method == "ping")
@@ -2543,8 +2537,7 @@ std::function<fastmcpp::Json(const fastmcpp::Json&)> make_mcp_handler(const Prox
25432537
{"serverInfo", serverInfo}};
25442538
if (app.instructions().has_value())
25452539
result_obj["instructions"] = *app.instructions();
2546-
return fastmcpp::Json{
2547-
{"jsonrpc", "2.0"}, {"id", id}, {"result", result_obj}};
2540+
return fastmcpp::Json{{"jsonrpc", "2.0"}, {"id", id}, {"result", result_obj}};
25482541
}
25492542

25502543
if (method == "ping")
@@ -3009,8 +3002,7 @@ make_mcp_handler_with_sampling(const FastMCP& app, SessionAccessor session_acces
30093002
{"serverInfo", serverInfo}};
30103003
if (app.instructions().has_value())
30113004
result_obj["instructions"] = *app.instructions();
3012-
return fastmcpp::Json{
3013-
{"jsonrpc", "2.0"}, {"id", id}, {"result", result_obj}};
3005+
return fastmcpp::Json{{"jsonrpc", "2.0"}, {"id", id}, {"result", result_obj}};
30143006
}
30153007

30163008
if (method == "ping")

tests/app/mcp_apps.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -335,10 +335,11 @@ static int test_instructions_parsed_by_client()
335335

336336
auto handler = mcp::make_mcp_handler(app);
337337
client::Client c(std::make_unique<client::InProcessMcpTransport>(handler));
338-
auto init_result = c.call(
339-
"initialize", Json{{"protocolVersion", "2024-11-05"},
340-
{"capabilities", Json::object()},
341-
{"clientInfo", Json{{"name", "instructions-test"}, {"version", "1.0.0"}}}});
338+
auto init_result =
339+
c.call("initialize",
340+
Json{{"protocolVersion", "2024-11-05"},
341+
{"capabilities", Json::object()},
342+
{"clientInfo", Json{{"name", "instructions-test"}, {"version", "1.0.0"}}}});
342343
CHECK_TRUE(init_result.contains("instructions"),
343344
"client init result should contain instructions");
344345
CHECK_TRUE(init_result["instructions"] == "This server provides weather data.",

tests/client/api_advanced.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -508,17 +508,20 @@ void test_jsonrpc_envelope_normalization()
508508
bool elicitation_called = false;
509509
bool roots_called = false;
510510
c.set_sampling_callback(
511-
[&](const Json&) {
511+
[&](const Json&)
512+
{
512513
sampling_called = true;
513514
return Json::object();
514515
});
515516
c.set_elicitation_callback(
516-
[&](const Json&) {
517+
[&](const Json&)
518+
{
517519
elicitation_called = true;
518520
return Json::object();
519521
});
520522
c.set_roots_callback(
521-
[&]() {
523+
[&]()
524+
{
522525
roots_called = true;
523526
return Json::array({"root1"});
524527
});

tests/mcp/test_instructions.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,8 +198,7 @@ static void test_proxy_instructions()
198198
auto client_factory = [backend_handler]()
199199
{ return client::Client(std::make_unique<client::InProcessMcpTransport>(backend_handler)); };
200200

201-
ProxyApp proxy(client_factory, "proxy_srv", "1.0.0",
202-
std::string("Proxy instructions."));
201+
ProxyApp proxy(client_factory, "proxy_srv", "1.0.0", std::string("Proxy instructions."));
203202

204203
auto handler = mcp::make_mcp_handler(proxy);
205204
auto resp = handler(request(1, "initialize"));
@@ -242,8 +241,7 @@ static void test_server_accessors()
242241
{
243242
std::cout << "test_server_accessors...\n";
244243

245-
server::Server srv("acc_srv", "1.0", std::nullopt, std::nullopt,
246-
std::string("Initial."));
244+
server::Server srv("acc_srv", "1.0", std::nullopt, std::nullopt, std::string("Initial."));
247245
assert(srv.instructions().has_value());
248246
assert(*srv.instructions() == "Initial.");
249247

@@ -270,8 +268,7 @@ static void test_legacy_constructor_compatibility()
270268
assert(app_with_vector.list_page_size() == 3);
271269
assert(!app_with_vector.dereference_schemas());
272270

273-
FastMCP app_with_braces("legacy_app_braces", "1.0.0", std::nullopt, std::nullopt, {}, 0,
274-
false);
271+
FastMCP app_with_braces("legacy_app_braces", "1.0.0", std::nullopt, std::nullopt, {}, 0, false);
275272
assert(!app_with_braces.instructions().has_value());
276273
assert(app_with_braces.list_page_size() == 0);
277274
assert(!app_with_braces.dereference_schemas());

0 commit comments

Comments
 (0)