Entropic 2.3.8
Local-first agentic inference engine
Loading...
Searching...
No Matches
external_client.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
16#pragma once
17
19
20#include <cstdint>
21#include <memory>
22#include <mutex>
23#include <string>
24#include <vector>
25
26namespace entropic {
27
42public:
49 ExternalMCPClient(std::string name,
50 std::unique_ptr<Transport> transport);
51
57 bool connect();
58
63 void disconnect();
64
70 std::string list_tools() const;
71
79 std::string execute(const std::string& tool_name,
80 const std::string& args_json);
81
87 std::pair<std::vector<std::string>, std::vector<std::string>>
89
95 bool is_connected() const;
96
103 const std::string& name() const { return name_; }
104
114 void interrupt() { if (transport_) { transport_->interrupt(); } }
115
116private:
117 std::string name_;
118 std::unique_ptr<Transport> transport_;
119 std::string cached_tools_json_;
120 std::vector<std::string> cached_tool_names_;
121 mutable std::mutex tools_mutex_;
122 int next_id_{1};
123
124 static constexpr uint32_t DEFAULT_TIMEOUT_MS = 30000;
125 static constexpr uint32_t INIT_TIMEOUT_MS = 10000;
126
135 std::string build_request(const std::string& method,
136 const std::string& params = "{}");
137
144 bool send_initialize();
145
153 bool validate_init_response(const std::string& response);
154
161 bool query_tools();
162
170 static std::string extract_tool_result(
171 const std::string& response_json);
172
181 static std::string build_response(const std::string& result_text,
182 bool is_error = false);
183};
184
185} // namespace entropic
Client for an external MCP server (stdio or SSE).
std::string list_tools() const
List tools as JSON array string (cached).
const std::string & name() const
Get server name.
std::pair< std::vector< std::string >, std::vector< std::string > > refresh_tools()
Re-query tools/list and diff against cache.
bool is_connected() const
Check connection state.
void interrupt()
Abort any pending execute() by interrupting the transport.
bool connect()
Connect: open transport + MCP initialize + tools/list.
std::string execute(const std::string &tool_name, const std::string &args_json)
Execute a tool call via the external server.
void disconnect()
Disconnect: close transport.
Activate model on GPU (WARM → ACTIVE).
Abstract transport for external MCP server communication.