42 auto* p =
static_cast<char*
>(std::malloc(s.size() + 1));
43 std::memcpy(p, s.c_str(), s.size() + 1);
57 if (server ==
nullptr) {
71 if (server ==
nullptr) {
88 const char* tool_name,
89 const char* args_json) {
90 if (server ==
nullptr || tool_name ==
nullptr) {
92 R
"({"result":"Error: null server or tool_name","directives":[]})");
95 tool_name, args_json ? args_json :
"{}");
109 const char* config_json) {
110 if (server ==
nullptr) {
114 config_json ? config_json :
"{}");
129 if (server ==
nullptr || path ==
nullptr) {
Concrete base class for MCP servers (80% logic).
std::string execute(const std::string &tool_name, const std::string &args_json)
Execute a tool and wrap result in ServerResponse JSON.
const std::string & name() const
Get the server name.
virtual bool set_working_dir(const std::string &path)
Set the working directory.
virtual bool configure(const std::string &config_json)
Configure the server after creation.
entropic_error_t
Error codes returned by all C API functions.
@ ENTROPIC_ERROR_INVALID_ARGUMENT
NULL pointer, empty string, out-of-range value.
@ ENTROPIC_ERROR_IO
File/network I/O error.
@ ENTROPIC_ERROR_INVALID_CONFIG
Config validation failed (missing fields, bad values)
Pure C interface contract for MCP server plugins.
struct entropic_mcp_server * entropic_mcp_server_t
Opaque handle to an MCP server instance.
char * entropic_mcp_server_execute(entropic_mcp_server_t server, const char *tool_name, const char *args_json)
Execute a tool.
entropic_error_t entropic_mcp_server_configure(entropic_mcp_server_t server, const char *config_json)
Configure a server.
static char * alloc_string(const std::string &s)
Allocate a C string copy for caller-owned return.
entropic_error_t entropic_mcp_server_set_working_dir(entropic_mcp_server_t server, const char *path)
Set server working directory.
void entropic_mcp_server_destroy(entropic_mcp_server_t server)
Destroy a server instance.
const char * entropic_mcp_server_name(entropic_mcp_server_t server)
Get server name.
char * entropic_mcp_server_list_tools(entropic_mcp_server_t server)
List tools as JSON array.
static entropic::MCPServerBase * cast(entropic_mcp_server_t server)
Cast opaque handle to MCPServerBase pointer.
MCPServerBase concrete base class + ServerResponse.