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

C API implementation for external MCP server management. More...

#include "engine_handle.h"
#include <entropic/entropic.h>
#include <entropic/mcp/mcp_json_discovery.h>
#include <entropic/types/logging.h>
#include "json_serializers.h"
#include <cstring>
Include dependency graph for entropic_mcp.cpp:

Go to the source code of this file.

Functions

static entropic_error_t check_server_mgr (entropic_handle_t h)
 Check handle prerequisites for MCP server APIs.
 
static entropic::ExternalServerConfig parse_external_server_spec (const char *name, const nlohmann::json &j)
 Register an external MCP server at runtime.
 
ENTROPIC_EXPORT entropic_error_t entropic_register_mcp_server (entropic_handle_t handle, const char *name, const char *config_json)
 Register an external MCP server from JSON config (C ABI).
 
ENTROPIC_EXPORT entropic_error_t entropic_deregister_mcp_server (entropic_handle_t handle, const char *name)
 Deregister an external MCP server.
 
ENTROPIC_EXPORT char * entropic_list_mcp_servers (entropic_handle_t handle)
 List all MCP servers as JSON array.
 

Variables

static auto logger = entropic::log::get("facade.mcp")
 

Detailed Description

C API implementation for external MCP server management.

Implements entropic_register_mcp_server, entropic_deregister_mcp_server, and entropic_list_mcp_servers from entropic.h.

Version
2.0.0

Definition in file entropic_mcp.cpp.

Function Documentation

◆ check_server_mgr()

static entropic_error_t check_server_mgr ( entropic_handle_t  h)
static

Check handle prerequisites for MCP server APIs.

Parameters
hEngine handle.
Returns
ENTROPIC_OK if valid, error code otherwise.

Definition at line 31 of file entropic_mcp.cpp.

◆ entropic_deregister_mcp_server()

ENTROPIC_EXPORT entropic_error_t entropic_deregister_mcp_server ( entropic_handle_t  handle,
const char *  name 
)

Deregister an external MCP server.

Parameters
handleEngine handle returned by entropic_create.
nameMCP server name (must be unique).
Returns
ENTROPIC_OK or error code.

Definition at line 138 of file entropic_mcp.cpp.

◆ entropic_list_mcp_servers()

ENTROPIC_EXPORT char * entropic_list_mcp_servers ( entropic_handle_t  handle)

List all MCP servers as JSON array.

List all MCP servers with status information.

Parameters
handleEngine handle returned by entropic_create.
Returns
JSON string (caller frees), or NULL.

Definition at line 166 of file entropic_mcp.cpp.

◆ entropic_register_mcp_server()

ENTROPIC_EXPORT entropic_error_t entropic_register_mcp_server ( entropic_handle_t  handle,
const char *  name,
const char *  config_json 
)

Register an external MCP server from JSON config (C ABI).

Register an external MCP server at runtime.

Definition at line 105 of file entropic_mcp.cpp.

◆ parse_external_server_spec()

static entropic::ExternalServerConfig parse_external_server_spec ( const char *  name,
const nlohmann::json &  j 
)
static

Register an external MCP server at runtime.

Issue #9 (v2.1.4): parses the FULL ExternalServerConfig from config_json — including env and explicit transport. Pre-2.1.4 the runtime path silently dropped env, leaving spawned children with an empty environment (not even PATH). Env keys are filtered through the same blocklist used by .mcp.json discovery (is_blocked_env_var) so PATH/LD_PRELOAD/etc. cannot be injected.

Recognized config_json fields:

  • "command" (string) — stdio executable
  • "args" (string[]) — stdio arguments
  • "env" (object) — stdio environment (block-filtered)
  • "url" (string) — SSE endpoint (mutually exclusive)
  • "transport" (string) — "stdio" | "sse"; auto-inferred if absent
Parameters
handleEngine handle returned by entropic_create.
nameMCP server name (must be unique).
config_jsonJSON-serialized MCP server configuration.
Returns
ENTROPIC_OK or error code.

Parse an ExternalServerConfig from register-mcp JSON.

Extracted from entropic_register_mcp_server to keep it knots-clean. Env vars on the block list are skipped with a warning.

Parameters
nameServer name.
jParsed config JSON.
Returns
Populated ExternalServerConfig. @utility
Version
2.3.7

Definition at line 73 of file entropic_mcp.cpp.

Variable Documentation

◆ logger

auto logger = entropic::log::get("facade.mcp")
static

Definition at line 22 of file entropic_mcp.cpp.