Skip to content

Commit 07242c1

Browse files
committed
chore: Cleanup
1 parent 9bc53b8 commit 07242c1

File tree

2 files changed

+5
-21
lines changed

2 files changed

+5
-21
lines changed

src/mcp/mcp_client.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,12 @@ namespace agent_cpp {
1111

1212
namespace {
1313

14-
// Parse URL into host and path components
1514
void
1615
parse_url(const std::string& url, std::string& host, std::string& path)
1716
{
18-
// Find scheme end
1917
size_t scheme_end = url.find("://");
2018
size_t host_start = (scheme_end != std::string::npos) ? scheme_end + 3 : 0;
2119

22-
// Find path start
2320
size_t path_start = url.find('/', host_start);
2421
if (path_start != std::string::npos) {
2522
host = url.substr(0, path_start);
@@ -123,13 +120,11 @@ MCPClient::send_request(const std::string& method, const json& params)
123120
res->body);
124121
}
125122

126-
// Extract session ID from response headers
127123
auto session_it = res->headers.find("Mcp-Session-Id");
128124
if (session_it != res->headers.end()) {
129125
session_id_ = session_it->second;
130126
}
131127

132-
// Get content type
133128
std::string content_type;
134129
auto ct_it = res->headers.find("Content-Type");
135130
if (ct_it != res->headers.end()) {
@@ -180,7 +175,6 @@ MCPClient::send_notification(const std::string& method, const json& params)
180175
headers.emplace("Mcp-Session-Id", session_id_);
181176
}
182177

183-
// Fire and forget for notifications
184178
http_client_->Post(path_, headers, request_body, "application/json");
185179
}
186180

src/mcp/mcp_client.h

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,11 @@
1010

1111
#include "tool.h"
1212

13-
// Forward declarations
13+
// Forward declaration
1414
namespace httplib {
1515
class Client;
1616
}
1717

18-
namespace agent_cpp {
19-
class MCPClient;
20-
}
21-
2218
namespace agent_cpp {
2319

2420
using json = nlohmann::json;
@@ -49,22 +45,16 @@ struct MCPToolResult
4945
bool is_error = false;
5046
};
5147

52-
/// @brief Configuration options for MCPClient
5348
struct MCPClientConfig
5449
{
55-
int connection_timeout_sec = 10; ///< Connection timeout in seconds
56-
int read_timeout_sec = 30; ///< Read timeout in seconds
57-
int write_timeout_sec = 10; ///< Write timeout in seconds
50+
int connection_timeout_sec = 10;
51+
int read_timeout_sec = 30;
52+
int write_timeout_sec = 10;
5853
};
5954

6055
class MCPClient : public std::enable_shared_from_this<MCPClient>
6156
{
6257
public:
63-
/// @brief Create an MCPClient instance
64-
/// @param url The MCP server URL
65-
/// @param config Optional configuration for timeouts
66-
/// @note Use this factory method instead of direct construction to enable
67-
/// proper lifetime management with MCPTool objects.
6858
static std::shared_ptr<MCPClient> create(
6959
const std::string& url,
7060
const MCPClientConfig& config = MCPClientConfig{});
@@ -114,4 +104,4 @@ class MCPClient : public std::enable_shared_from_this<MCPClient>
114104
json parse_response(const std::string& response);
115105
};
116106

117-
}
107+
} // namespace agent_cpp

0 commit comments

Comments
 (0)