Entropic 2.3.8
Local-first agentic inference engine
Loading...
Searching...
No Matches
mcp_c_api.cpp File Reference

C API implementation for i_mcp_server.h. More...

#include <entropic/interfaces/i_mcp_server.h>
#include <entropic/mcp/server_base.h>
#include <cstdlib>
#include <cstring>
Include dependency graph for mcp_c_api.cpp:

Go to the source code of this file.

Functions

static entropic::MCPServerBasecast (entropic_mcp_server_t server)
 Cast opaque handle to MCPServerBase pointer.
 
static char * alloc_string (const std::string &s)
 Allocate a C string copy for caller-owned return.
 
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.
 
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.
 
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.
 

Detailed Description

C API implementation for i_mcp_server.h.

Bridges the pure C interface to the C++ MCPServerBase class. Each function casts the opaque handle and delegates.

Version
1.8.5

Definition in file mcp_c_api.cpp.

Function Documentation

◆ alloc_string()

static char * alloc_string ( const std::string &  s)
static

Allocate a C string copy for caller-owned return.

Uses malloc so the caller can deallocate via entropic_free() (which is the canonical public free in facade/entropic.cpp and wraps free(3)). Mismatched new[]/free is undefined behavior.

Parameters
sSource string.
Returns
Heap-allocated copy (free with entropic_free).

Definition at line 41 of file mcp_c_api.cpp.

◆ cast()

static entropic::MCPServerBase * cast ( entropic_mcp_server_t  server)
static

Cast opaque handle to MCPServerBase pointer.

Parameters
serverOpaque handle.
Returns
C++ server pointer.

Definition at line 25 of file mcp_c_api.cpp.

◆ entropic_mcp_server_configure()

entropic_error_t entropic_mcp_server_configure ( entropic_mcp_server_t  server,
const char *  config_json 
)

Configure a server.

Configure a server instance after creation.

Parameters
serverServer handle.
config_jsonConfiguration JSON.
Returns
ENTROPIC_OK on success.

Definition at line 107 of file mcp_c_api.cpp.

◆ entropic_mcp_server_destroy()

void entropic_mcp_server_destroy ( entropic_mcp_server_t  server)

Destroy a server instance.

Parameters
serverServer handle.

Definition at line 142 of file mcp_c_api.cpp.

◆ entropic_mcp_server_execute()

char * entropic_mcp_server_execute ( entropic_mcp_server_t  server,
const char *  tool_name,
const char *  args_json 
)

Execute a tool.

Execute a tool and return ServerResponse JSON envelope.

Parameters
serverServer handle.
tool_nameTool name.
args_jsonJSON arguments.
Returns
Caller-owned ServerResponse JSON.

Definition at line 86 of file mcp_c_api.cpp.

◆ entropic_mcp_server_list_tools()

char * entropic_mcp_server_list_tools ( entropic_mcp_server_t  server)

List tools as JSON array.

List tools as JSON array string.

Parameters
serverServer handle.
Returns
Caller-owned JSON string.

Definition at line 70 of file mcp_c_api.cpp.

◆ entropic_mcp_server_name()

const char * entropic_mcp_server_name ( entropic_mcp_server_t  server)

Get server name.

Get the server name.

Parameters
serverServer handle.
Returns
Server name (server-owned).

Definition at line 56 of file mcp_c_api.cpp.

◆ entropic_mcp_server_set_working_dir()

entropic_error_t entropic_mcp_server_set_working_dir ( entropic_mcp_server_t  server,
const char *  path 
)

Set server working directory.

Set the working directory for a server.

Parameters
serverServer handle.
pathWorking directory path.
Returns
ENTROPIC_OK on success.

Definition at line 126 of file mcp_c_api.cpp.