Entropic 2.14.3
Local-first agentic inference engine
Loading...
Searching...
No Matches
external_bridge.h File Reference

Unix socket MCP bridge — exposes a running engine to external clients. More...

#include <entropic/entropic_export.h>
#include <entropic/types/config.h>
#include <nlohmann/json_fwd.hpp>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <filesystem>
#include <memory>
#include <mutex>
#include <map>
#include <set>
#include <string>
#include <thread>
#include <unordered_map>
#include <unordered_set>
#include <vector>
Include dependency graph for external_bridge.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  entropic::ExternalBridge
 Unix socket MCP bridge for external client access. More...
 
struct  entropic::ExternalBridge::AsyncTask
 Async task state for background entropic.ask runs. More...
 

Namespaces

namespace  entropic
 Activate model on GPU (WARM → ACTIVE).
 

Typedefs

using entropic_handle_t = entropic_engine *
 

Detailed Description

Unix socket MCP bridge — exposes a running engine to external clients.

When mcp.external.enabled is true, the engine starts an ExternalBridge that listens on a unix domain socket and serves JSON-RPC 2.0 (MCP protocol) to external clients such as Claude Code. The bridge operates on the already-configured engine handle — no second engine instance.

Exposed tools:
Named <prefix>.<suffix>, where prefix is mcp.external.tool_prefix (default "entropic", so the stock names are unchanged). gh#145: a consumer app hosting this engine advertises its OWN namespace — the engine is a substrate, not the product.
  • <prefix>.ask — submit a prompt, get the full response
  • <prefix>.ask_status — poll an async ask
  • <prefix>.status — engine version + message count
  • <prefix>.context_clear — reset conversation
  • <prefix>.context_count — message count
Socket path:
Uses ExternalMCPConfig.socket_path if set, otherwise derived from the project directory via compute_socket_path().
Thread safety:
The bridge runs a background accept loop and serves EACH CLIENT ON ITS OWN THREAD (v2.1.2, issue #4 — a TUI and a Claude Code session may be connected at once). Requests on a single connection are sequential.

The engine handle's api_mutex does NOT serialize access to the engine: gh#109 removed it from every run entry point so a long turn cannot block entropic_interrupt(). Until v2.12.0 that made two concurrent asks a data race on the shared conversation and on the llama context (gh#144). The bridge now serializes turns itself, so a second caller QUEUES rather than racing or being refused, and reports its position through the status tool.

Version
2.12.0

Definition in file external_bridge.h.

Typedef Documentation

◆ entropic_handle_t

Definition at line 64 of file external_bridge.h.