include/entropic/mcp/plugin_server.h¶
include/entropic/mcp/plugin_server.h
entropic::PluginServer
A loaded MCP server plugin and its C-ABI entry points.
entropic_error_t entropic::PluginServer::load(const std::filesystem::path &path, std::unique_ptr< PluginServer > &out)
Load a plugin .so and construct its server instance.
Load a plugin .so and construct its server instance. Performs the full sequence: dlopen, resolve all nine entry points, verify entropic_plugin_api_version() against ENTROPIC_MCP_PLUGIN_API_VERSION, then entropic_create_server(). Every failure is logged with the offending path before returning. dlopen, then dlsym of all nine entry points, then the API-version check, then entropic_create_server(). Every failure is typed and logged with its path — a configured plugin never fails silently.
- Parameters
path— Filesystem path to the plugin shared object.outout — Receives the loaded plugin on success; untouched otherwise.path— Plugin shared object path.outout — Receives the loaded plugin on success; left untouched on failure.
- Returns
- ENTROPIC_OK, ENTROPIC_ERROR_PLUGIN_LOAD_FAILED (dlopen or a missing entry point or a null instance), or ENTROPIC_ERROR_PLUGIN_VERSION_MISMATCH.
- ENTROPIC_OK on success; ENTROPIC_ERROR_PLUGIN_LOAD_FAILED when dlopen fails, an entry point is missing, or the factory yields a null/unnamed instance; ENTROPIC_ERROR_PLUGIN_VERSION_MISMATCH when the plugin reports a different API version.
entropic::PluginServer::~PluginServer()
Destroy the plugin instance, then close the library.
Order matters: the instance's destructor lives inside the library, so the library must outlive it. destroy() therefore happens-after every other call on the handle, and dlclose happens-after destroy().
entropic::PluginServer::PluginServer(const PluginServer &)=delete
PluginServer & entropic::PluginServer::operator=(const PluginServer &)=delete
entropic::PluginServer::PluginServer(PluginServer &&)=delete
PluginServer & entropic::PluginServer::operator=(PluginServer &&)=delete
const std::string & entropic::PluginServer::name() const
Server name, used as the tool-routing prefix.
- Returns
- Name reported by entropic_mcp_server_name() at load time.
const std::filesystem::path & entropic::PluginServer::path() const
Path this plugin was loaded from.
- Returns
- Filesystem path.
std::string entropic::PluginServer::list_tools() const
List the plugin's tools.
Descriptors use inputSchema (camelCase), which is what ServerManager::get_tool_schema parses so a plugin tool gets the same argument validation a built-in does.
- Returns
- JSON array string; "[]" if the plugin returned nothing.
- JSON array string of tool descriptors; "[]" when the plugin returned nothing.
std::string entropic::PluginServer::execute(const std::string &tool_name, const std::string &args_json)
Execute one of the plugin's tools.
Serialised on a per-instance mutex so the threading promise the plugin header makes to authors — "the engine never runs these concurrently on one handle" — holds by construction rather than by every upstream caller behaving. No ordering is promised between distinct handles and the calling thread is not fixed.
- Parameters
tool_name— Local tool name (no server prefix).args_json— JSON arguments.tool_name— Local tool name (no server prefix); borrowed for the call.args_json— JSON arguments; borrowed for the call.
- Returns
- ServerResponse JSON envelope.
- The plugin's ServerResponse JSON envelope, copied out of plugin-owned memory; empty when the plugin returned null.
entropic_error_t entropic::PluginServer::configure(const std::string &config_json)
Pass configuration to the plugin instance.
Serialised on the same per-instance mutex as execute().
- Parameters
config_json— JSON configuration string.config_json— JSON configuration string; borrowed for the call.
- Returns
- Whatever the plugin's configure entry point returns.
- The plugin's own entropic_error_t result, forwarded verbatim.
entropic_error_t entropic::PluginServer::set_working_dir(const std::string &dir)
Set the plugin's working directory.
Serialised on the same per-instance mutex as execute().
- Parameters
dir— Directory path.dir— Directory path; borrowed for the call.
- Returns
- Whatever the plugin's set_working_dir entry point returns.
- The plugin's own entropic_error_t result, forwarded verbatim.