include/entropic/interfaces/i_mcp_server.h

← API

include/entropic/interfaces/i_mcp_server.h

Functions

ENTROPIC_EXPORT int entropic_plugin_api_version(void)

Report the plugin API version this plugin was built against.

Implemented BY THE PLUGIN, called by the engine's loader. Return ENTROPIC_MCP_PLUGIN_API_VERSION; a plugin reporting anything else is rejected with ENTROPIC_ERROR_PLUGIN_VERSION_MISMATCH and not registered. Declared here (v2.10.1) rather than described only in prose so that plugin definitions pick up ENTROPIC_EXPORT from this header. Report the plugin API version this plugin was built against.

Returns
  • Plugin API version.
  • Version number.
  • TEST_PLUGIN_API_VERSION (the contract version unless the build overrode it to produce a deliberately-incompatible plugin).

ENTROPIC_EXPORT entropic_mcp_server_t entropic_create_server(void)

Construct a server instance.

Implemented BY THE PLUGIN, called by the engine's loader once per configured .so. Parameterless for ABI uniformity — pass construction parameters via entropic_mcp_server_configure() instead. The returned handle is owned by the engine and released with entropic_mcp_server_destroy(). Declared here (v2.10.1) rather than described only in prose so that plugin definitions pick up ENTROPIC_EXPORT from this header.

Returns
  • Opaque server handle, or NULL on failure.
  • Opaque handle, owned by the caller until destroy.

ENTROPIC_EXPORT const char * entropic_mcp_server_name(entropic_mcp_server_t server)

Get the server name.

Get the server name. Get the server name.

Parameters
  • server — Server handle.
  • server — Server handle (unused — name is constant).
Returns
  • Null-terminated server name string. Owned by the server.
  • Server name (server-owned).
  • TEST_PLUGIN_SERVER_NAME, valid for the process lifetime.

ENTROPIC_EXPORT char * entropic_mcp_server_list_tools(entropic_mcp_server_t server)

List tools as JSON array string.

List tools as JSON array string. List tools as JSON array string.

Parameters
  • server — Server handle.
  • server — Server handle (unused — tool set is static).
Returns
  • JSON string of tool definitions. Caller must free with entropic_free().
  • Caller-owned JSON string.
  • malloc'd JSON array; caller frees with entropic_free().

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

Execute a tool and return ServerResponse JSON envelope.

Execute a tool and return ServerResponse JSON envelope. Execute a tool and return ServerResponse JSON envelope. Hand-rolls the text extraction rather than pulling in a JSON library — a real plugin would use its own; the point here is that the engine never sees the plugin's dependencies.

Parameters
  • server — Server handle.
  • tool_name — Tool name (without server prefix).
  • args_json — JSON string of arguments.
  • tool_name — Tool name.
  • args_json — JSON arguments.
  • tool_name — Local tool name (no server prefix).
Returns
  • JSON string: {"result":"...","directives":[...]}. Caller must free with entropic_free(). Empty directives array when tool has no side effects.
  • Caller-owned ServerResponse JSON.
  • malloc'd ServerResponse envelope; caller frees with entropic_free().

ENTROPIC_EXPORT entropic_error_t entropic_mcp_server_configure(entropic_mcp_server_t server, const char *config_json)

Configure a server instance after creation.

Some servers need construction parameters (root_dir, config). The entropic_create_server() signature is parameterless for ABI uniformity. Per-server configuration is passed via this call. Configure a server instance after creation. Configure a server instance after creation.

Parameters
  • server — Server handle.
  • config_json — JSON configuration string.
  • config_json — Configuration JSON.
  • config_json — JSON configuration.
Returns
  • ENTROPIC_OK on success.
  • ENTROPIC_OK, or ENTROPIC_ERROR_INVALID_CONFIG on a null handle.

ENTROPIC_EXPORT entropic_error_t entropic_mcp_server_set_working_dir(entropic_mcp_server_t server, const char *path)

Set the working directory for a server.

Base class default is no-op. Directory-aware servers (filesystem, bash, git) implement this. Enables ScopedSandbox (v2.1.5; formerly ScopedWorktree) to swap directories across .so boundaries without breaking isolation. Set the working directory for a server. Set the working directory for a server.

Parameters
  • server — Server handle.
  • path — Working directory path.
  • path — Working directory.
Returns
  • ENTROPIC_OK on success.
  • ENTROPIC_OK, or ENTROPIC_ERROR_INVALID_CONFIG on a null handle.

ENTROPIC_EXPORT void entropic_mcp_server_destroy(entropic_mcp_server_t server)

Destroy a server instance.

Parameters
  • server — Server handle to destroy. NULL is a safe no-op.
  • server — Server handle.
  • server — Handle to destroy; NULL is a safe no-op.

ENTROPIC_EXPORT void entropic_free(void *ptr)

Free a string allocated by the server.

Free a string allocated by the server. Free memory allocated by the engine or entropic_alloc().

Parameters
  • ptr — Pointer returned by list_tools or execute. NULL is a safe no-op.
  • ptr — Pointer to free; NULL is a safe no-op.
threadsafety
Thread-safe.

Types

typedef struct entropic_mcp_server* entropic_mcp_server_t

Opaque handle to an MCP server instance.

typedef entropic_state_provider_t

Macros

ENTROPIC_MCP_PLUGIN_API_VERSION

Value: 1

Current MCP plugin API version.

Bumped when MCPServerBase or ToolBase virtual method signatures change. A plugin built against an older vtable loaded into a newer engine will be rejected with ENTROPIC_ERROR_PLUGIN_VERSION_MISMATCH.

entropic_state_provider_t

Read-only engine state provider for introspection tools.

char *(* entropic_state_provider_t::get_config) (void *user_data)

Get current engine configuration as JSON.

char *(* entropic_state_provider_t::get_identities) (void *user_data)

Get loaded identities as JSON array.

char *(* entropic_state_provider_t::get_tools) (void *user_data)

Get available tools as JSON array.

char *(* entropic_state_provider_t::get_history) (int max_entries, void *user_data)

Get recent tool call history as JSON array.

Parameters
  • max_entries — Maximum entries to return (0 = all).

char *(* entropic_state_provider_t::get_state) (void *user_data)

Get engine state as JSON.

char *(* entropic_state_provider_t::get_metrics) (void *user_data)

Get engine metrics as JSON.

char *(* entropic_state_provider_t::get_docs) (const char *section, void *user_data)

Get bundled documentation as text.

Parameters
  • section — Section name (NULL = full doc).

char *(* entropic_state_provider_t::search_delegations) (const char *query, int max_results, void *user_data)

Search prior delegation summaries (gh#32, v2.1.6).

Backs entropic.followup. Returns a JSON array of objects with fields {delegation_id, target_tier, summary, completed_at}, containing up to max_results records whose summary substring-matches query. May be NULL on engines built without a storage backend; the tool surfaces a typed error in that case. Caller must free the returned string with entropic_free().

Parameters
  • query — Keyword/phrase to match (NULL-safe).
  • max_results — Maximum records to return (>=1).
  • user_data — Opaque provider state.
Returns
JSON string (caller frees), or NULL on error.

char *(* entropic_state_provider_t::load_delegation_conversation) (const char *delegation_id, void *user_data)

Load a delegation's full child conversation (gh#32, v2.1.6).

Backs entropic.resume_delegation. Returns the conversation JSON previously persisted via storage_save_conversation, scoped to the delegation's child_conversation_id. May be NULL when storage is unavailable or the id is unknown — the tool surfaces a typed error. Caller must free with entropic_free().

Parameters
  • delegation_id — Storage delegation id.
  • user_data — Opaque provider state.
Returns
JSON string (caller frees), or NULL on error.

char *(* entropic_state_provider_t::get_residency) (void *user_data)

Get current VRAM residency-set snapshot (gh#57, v2.2.4).

Backs the engine's introspection surface for prompt-time decisioning ("which tier models are loaded right now"). Mirrors the C ABI entropic_residency_snapshot JSON schema exactly. May be NULL on pre-v2.2.4 engines or before configure_dir runs; the tool surfaces an empty residency array in that case. Caller must free with entropic_free().

Parameters
  • user_data — Opaque provider state.
Returns
JSON string (caller frees), or NULL on error.

void* entropic_state_provider_t::user_data

Opaque user data passed to all callbacks.