Entropic 2.11.1
Local-first agentic inference engine
Loading...
Searching...
No Matches
plugin_server.h
Go to the documentation of this file.
1// SPDX-License-Identifier: Apache-2.0
27#pragma once
28
30
31#include <filesystem>
32#include <memory>
33#include <mutex>
34#include <string>
35
36namespace entropic {
37
47public:
64 static entropic_error_t load(const std::filesystem::path& path,
65 std::unique_ptr<PluginServer>& out);
66
72
73 PluginServer(const PluginServer&) = delete;
74 PluginServer& operator=(const PluginServer&) = delete;
75 PluginServer(PluginServer&&) = delete;
76 PluginServer& operator=(PluginServer&&) = delete;
77
84 const std::string& name() const { return name_; }
85
92 const std::filesystem::path& path() const { return path_; }
93
99 std::string list_tools() const;
100
108 std::string execute(const std::string& tool_name,
109 const std::string& args_json);
110
117 entropic_error_t configure(const std::string& config_json);
118
125 entropic_error_t set_working_dir(const std::string& dir);
126
127private:
128 /* Signatures of the plugin-side entry points (see i_mcp_server.h). */
129 using version_fn_t = int (*)();
130 using create_fn_t = entropic_mcp_server_t (*)();
131 using name_fn_t = const char* (*)(entropic_mcp_server_t);
132 using list_tools_fn_t = char* (*)(entropic_mcp_server_t);
133 using execute_fn_t = char* (*)(entropic_mcp_server_t, const char*,
134 const char*);
135 using configure_fn_t = entropic_error_t (*)(entropic_mcp_server_t,
136 const char*);
137 using set_dir_fn_t = entropic_error_t (*)(entropic_mcp_server_t,
138 const char*);
139 using destroy_fn_t = void (*)(entropic_mcp_server_t);
140 using free_fn_t = void (*)(void*);
141
148 PluginServer(void* handle, std::filesystem::path path);
149
156 entropic_error_t resolve_and_init();
157
164 entropic_error_t resolve_and_check_version();
165
172 entropic_error_t create_instance();
173
180 bool resolve_symbols();
181
190 void* resolve_one(const char* symbol_name, bool& ok) const;
191
198 bool resolve_factory_symbols();
199
206 bool resolve_instance_symbols();
207
220 std::string take_string(char* raw) const;
221
222 void* handle_{nullptr};
223 std::filesystem::path path_;
224 std::string name_;
225 entropic_mcp_server_t instance_{nullptr};
226
227 version_fn_t version_fn_{nullptr};
228 create_fn_t create_fn_{nullptr};
229 name_fn_t name_fn_{nullptr};
230 list_tools_fn_t list_tools_fn_{nullptr};
231 execute_fn_t execute_fn_{nullptr};
232 configure_fn_t configure_fn_{nullptr};
233 set_dir_fn_t set_dir_fn_{nullptr};
234 destroy_fn_t destroy_fn_{nullptr};
235 free_fn_t free_fn_{nullptr};
236
246 mutable std::mutex call_mutex_;
247};
248
249} // namespace entropic
A loaded MCP server plugin and its C-ABI entry points.
static entropic_error_t load(const std::filesystem::path &path, std::unique_ptr< PluginServer > &out)
Load a plugin .so and construct its server instance.
entropic_error_t configure(const std::string &config_json)
Pass configuration to the plugin instance.
const std::filesystem::path & path() const
Path this plugin was loaded from.
const std::string & name() const
Server name, used as the tool-routing prefix.
std::string list_tools() const
List the plugin's tools.
entropic_error_t set_working_dir(const std::string &dir)
Set the plugin's working directory.
std::string execute(const std::string &tool_name, const std::string &args_json)
Execute one of the plugin's tools.
~PluginServer()
Destroy the plugin instance, then close the library.
entropic_error_t
Error codes returned by all C API functions.
Definition error.h:37
Pure C interface contract for MCP server plugins.
struct entropic_mcp_server * entropic_mcp_server_t
Opaque handle to an MCP server instance.
Activate model on GPU (WARM → ACTIVE).
@ ok
Tool dispatched, returned non-empty content.