Skip to content

Commit 1024ae2

Browse files
RahulHeregophergogo
authored andcommitted
make format-cpp
1 parent 78ab59a commit 1024ae2

5 files changed

Lines changed: 34 additions & 40 deletions

File tree

include/mcp/types.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,8 @@ struct Request {
499499
// Generic result type for responses
500500
// Note: ListResourcesResult and ListToolsResult are defined outside jsonrpc
501501
// namespace but used here
502-
// json::JsonValue added to support arbitrary nested JSON responses (e.g., initialize)
502+
// json::JsonValue added to support arbitrary nested JSON responses (e.g.,
503+
// initialize)
503504
using ResponseResult = variant<std::nullptr_t,
504505
bool,
505506
int,

src/config/file_config_source.cc

Lines changed: 17 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -268,8 +268,8 @@ class FileConfigSource : public ConfigSource {
268268
int priority,
269269
const Options& opts = Options{})
270270
: name_(name), priority_(priority), options_(opts) {
271-
GOPHER_LOG(Info, "FileConfigSource created: name={} priority={}",
272-
name_, priority_);
271+
GOPHER_LOG(Info, "FileConfigSource created: name={} priority={}", name_,
272+
priority_);
273273
}
274274

275275
std::string getName() const override { return name_; }
@@ -285,18 +285,15 @@ class FileConfigSource : public ConfigSource {
285285
mcp::json::JsonValue loadConfiguration() override {
286286
// Keep logs under config.file so tests that attach a sink to
287287
// "config.file" see discovery start/end messages.
288-
GOPHER_LOG(Info, "Starting configuration discovery for source: {}{}",
289-
name_,
290-
(options_.trace_id.empty()
291-
? ""
292-
: (" trace_id=" + options_.trace_id)));
288+
GOPHER_LOG(
289+
Info, "Starting configuration discovery for source: {}{}", name_,
290+
(options_.trace_id.empty() ? "" : (" trace_id=" + options_.trace_id)));
293291

294292
// Determine the config file path using deterministic search order
295293
std::string config_path = findConfigFile();
296294

297295
if (config_path.empty()) {
298-
GOPHER_LOG(Warning, "No configuration file found for source: {}",
299-
name_);
296+
GOPHER_LOG(Warning, "No configuration file found for source: {}", name_);
300297
return mcp::json::JsonValue::object();
301298
}
302299

@@ -321,12 +318,12 @@ class FileConfigSource : public ConfigSource {
321318
base_config_path_ = config_path;
322319

323320
// Emit a brief summary and also dump top-level keys/types to aid debugging
324-
GOPHER_LOG(
325-
Info,
326-
"Configuration discovery completed: files_parsed={} "
327-
"includes_processed={} env_vars_expanded={} overlays_applied={}",
328-
context.files_parsed_count, context.includes_processed_count,
329-
context.env_vars_expanded_count, context.overlays_applied.size());
321+
GOPHER_LOG(Info,
322+
"Configuration discovery completed: files_parsed={} "
323+
"includes_processed={} env_vars_expanded={} overlays_applied={}",
324+
context.files_parsed_count, context.includes_processed_count,
325+
context.env_vars_expanded_count,
326+
context.overlays_applied.size());
330327

331328
if (config.isObject()) {
332329
for (const auto& key : config.keys()) {
@@ -451,8 +448,7 @@ class FileConfigSource : public ConfigSource {
451448
if (exists(path)) {
452449
// Determine which source won
453450
if (i == 0 && !explicit_config_path_.empty()) {
454-
GOPHER_LOG(Info, "Configuration source won: CLI --config={}",
455-
path);
451+
GOPHER_LOG(Info, "Configuration source won: CLI --config={}", path);
456452
} else if ((i == 0 || i == 1) && env_config) {
457453
GOPHER_LOG(
458454
Info,
@@ -483,8 +479,7 @@ class FileConfigSource : public ConfigSource {
483479
}
484480
size_t file_size = st.st_size;
485481
if (file_size > options_.max_file_size) {
486-
GOPHER_LOG(Error,
487-
"File exceeds maximum size limit: {} size={} limit={}",
482+
GOPHER_LOG(Error, "File exceeds maximum size limit: {} size={} limit={}",
488483
filepath, file_size, options_.max_file_size);
489484
throw std::runtime_error("File too large: " + filepath + " (" +
490485
std::to_string(file_size) + " bytes)");
@@ -499,14 +494,12 @@ class FileConfigSource : public ConfigSource {
499494
context.latest_mtime = file_mtime;
500495
}
501496

502-
GOPHER_LOG(Debug,
503-
"Loading configuration file: {} size={} last_modified={}",
497+
GOPHER_LOG(Debug, "Loading configuration file: {} size={} last_modified={}",
504498
filepath, file_size, last_modified);
505499

506500
std::ifstream file(filepath);
507501
if (!file.is_open()) {
508-
GOPHER_LOG(Error, "Failed to open configuration file: {}",
509-
filepath);
502+
GOPHER_LOG(Error, "Failed to open configuration file: {}", filepath);
510503
throw std::runtime_error("Cannot open config file: " + filepath);
511504
}
512505

@@ -932,8 +925,7 @@ class FileConfigSource : public ConfigSource {
932925
const mcp::json::JsonValue& base_config,
933926
const path& overlay_dir,
934927
ParseContext& context) {
935-
GOPHER_LOG(Info, "Scanning config.d directory: {}",
936-
overlay_dir.string());
928+
GOPHER_LOG(Info, "Scanning config.d directory: {}", overlay_dir.string());
937929

938930
mcp::json::JsonValue result = base_config;
939931
std::vector<path> overlay_files;

src/filter/http_codec_filter.cc

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,7 @@ network::FilterStatus HttpCodecFilter::onWrite(Buffer& data, bool end_stream) {
247247

248248
// Check if data is already HTTP-formatted (from routing filter)
249249
// If so, pass through without adding more HTTP framing
250-
if (body_data.length() >= 5 &&
251-
body_data.compare(0, 5, "HTTP/") == 0) {
250+
if (body_data.length() >= 5 && body_data.compare(0, 5, "HTTP/") == 0) {
252251
GOPHER_LOG_DEBUG(
253252
"HttpCodecFilter::onWrite - data already HTTP formatted, "
254253
"passing through");
@@ -293,7 +292,9 @@ network::FilterStatus HttpCodecFilter::onWrite(Buffer& data, bool end_stream) {
293292
// CORS headers for browser-based clients (e.g., MCP Inspector)
294293
response << "Access-Control-Allow-Origin: *\r\n";
295294
response << "Access-Control-Allow-Methods: GET, POST, OPTIONS\r\n";
296-
response << "Access-Control-Allow-Headers: Content-Type, Authorization, Accept, Mcp-Session-Id, Mcp-Protocol-Version\r\n";
295+
response
296+
<< "Access-Control-Allow-Headers: Content-Type, Authorization, "
297+
"Accept, Mcp-Session-Id, Mcp-Protocol-Version\r\n";
297298
response << "\r\n";
298299
// SSE data is already formatted by SSE filter
299300
response << body_data;
@@ -307,7 +308,9 @@ network::FilterStatus HttpCodecFilter::onWrite(Buffer& data, bool end_stream) {
307308
// CORS headers for browser-based clients (e.g., MCP Inspector)
308309
response << "Access-Control-Allow-Origin: *\r\n";
309310
response << "Access-Control-Allow-Methods: GET, POST, OPTIONS\r\n";
310-
response << "Access-Control-Allow-Headers: Content-Type, Authorization, Accept, Mcp-Session-Id, Mcp-Protocol-Version\r\n";
311+
response
312+
<< "Access-Control-Allow-Headers: Content-Type, Authorization, "
313+
"Accept, Mcp-Session-Id, Mcp-Protocol-Version\r\n";
311314
if (current_stream_) {
312315
response << "Connection: "
313316
<< (current_stream_->keep_alive ? "keep-alive" : "close")

src/filter/http_sse_filter_chain_factory.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -808,7 +808,8 @@ class HttpSseJsonRpcProtocolFilter
808808
resp.headers["Access-Control-Allow-Origin"] = "*";
809809
resp.headers["Access-Control-Allow-Methods"] = "GET, POST, OPTIONS";
810810
resp.headers["Access-Control-Allow-Headers"] =
811-
"Content-Type, Authorization, Accept, Mcp-Session-Id, Mcp-Protocol-Version";
811+
"Content-Type, Authorization, Accept, Mcp-Session-Id, "
812+
"Mcp-Protocol-Version";
812813
resp.headers["Access-Control-Max-Age"] = "86400"; // Cache for 24 hours
813814
resp.headers["Content-Length"] = "0";
814815
return resp;
@@ -875,7 +876,8 @@ class HttpSseJsonRpcProtocolFilter
875876
resp.headers["Access-Control-Allow-Origin"] = "*";
876877
resp.headers["Access-Control-Allow-Methods"] = "GET, POST, OPTIONS";
877878
resp.headers["Access-Control-Allow-Headers"] =
878-
"Content-Type, Authorization, Accept, Mcp-Session-Id, Mcp-Protocol-Version";
879+
"Content-Type, Authorization, Accept, Mcp-Session-Id, "
880+
"Mcp-Protocol-Version";
879881
resp.headers["Access-Control-Max-Age"] = "86400";
880882
resp.headers["Content-Length"] = "0";
881883
return resp;

tests/filter/test_options_notification.cc

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ TEST_F(OptionsNotificationTest, OptionsPreflightResponseFormat) {
5757
// Test OPTIONS response includes required MCP headers
5858
TEST_F(OptionsNotificationTest, OptionsAllowsMcpHeaders) {
5959
std::string allowed_headers =
60-
"Content-Type, Authorization, Accept, Mcp-Session-Id, Mcp-Protocol-Version";
60+
"Content-Type, Authorization, Accept, Mcp-Session-Id, "
61+
"Mcp-Protocol-Version";
6162

6263
// MCP Inspector uses these headers
6364
EXPECT_TRUE(allowed_headers.find("Mcp-Session-Id") != std::string::npos)
@@ -117,13 +118,8 @@ TEST_F(OptionsNotificationTest, NotificationNoJsonRpcResponse) {
117118
// Test OPTIONS for common MCP paths
118119
TEST_F(OptionsNotificationTest, OptionsRegisteredPaths) {
119120
// These paths should all handle OPTIONS requests
120-
std::vector<std::string> mcp_paths = {
121-
"/mcp",
122-
"/mcp/events",
123-
"/rpc",
124-
"/health",
125-
"/info"
126-
};
121+
std::vector<std::string> mcp_paths = {"/mcp", "/mcp/events", "/rpc",
122+
"/health", "/info"};
127123

128124
for (const auto& path : mcp_paths) {
129125
// Each path should be registered for OPTIONS

0 commit comments

Comments
 (0)