include/entropic/mcp/tool_executor.h

← API

include/entropic/mcp/tool_executor.h

entropic::PreconditionCheck

Outcome of precondition checks for a single tool call.

std::optional<Message> entropic::PreconditionCheck::rejection

Rejection message (nullopt if cleared)

ToolResultKind entropic::PreconditionCheck::kind

Category on rejection.

entropic::ToolExecutor

Processes tool calls from model output.

entropic::ToolExecutor::ToolExecutor(ServerManager &server_manager, const LoopConfig &loop_config, EngineCallbacks &callbacks, ToolExecutorHooks hooks={})

Construct with shared dependencies.

Parameters
  • server_manager — Server manager for tool execution.
  • loop_config — Loop configuration.
  • callbacks — Shared callbacks.
  • hooks — Optional engine-level hooks.
  • server_manager — Server manager.

void entropic::ToolExecutor::set_permission_persist(const PermissionPersistInterface &persist)

Set permission persistence interface.

Parameters
  • persist — Permission persist callbacks (wired by facade).
  • persist — Permission persist callbacks.

void entropic::ToolExecutor::set_server_resolver(ServerManager *(*fn)(const std::string &session_key, void *user_data), void *user_data)

Resolve a session's MCP servers (gh#166, v2.13.0).

Install the workspace server resolver (gh#166). Injected by the facade: only it knows which workspace a session is bound to, and a workspace owns its OWN server instances because a server holds one working directory. Unset (the default) means every session uses the manager this executor was constructed with — the pre-2.13.0 behaviour exactly.

Parameters
  • fn — Resolver, or nullptr to clear.
  • user_data — Forwarded to the resolver.

void entropic::ToolExecutor::set_tier_allowed_tools(const std::unordered_map< std::string, std::vector< std::string > > *map)

Wire the per-tier allowed_tools map for dispatch-time enforcement.

(gh#83, v2.5.2) Stores a pointer to the facade-owned map (keyed by tier name → allowed tool names). The facade caches it after the executor is constructed, so a pointer to the live map keeps the wiring order-independent. nullptr (default) = no enforcement (the pre-v2.5.2 pass-through behavior).

Parameters
  • map — Pointer to the tier→allowed_tools map (facade-owned; must outlive the executor). nullptr disables enforcement.

std::vector< Message > entropic::ToolExecutor::process_tool_calls(LoopContext &ctx, const std::vector< ToolCall > &tool_calls)

Process a batch of tool calls.

Batch handling before per-call dispatch: entropic.delegate is sorted last, then the batch is truncated to the effective per-turn limit — a per-identity override when the context carries one, the global LoopConfig value otherwise.

Parameters
  • ctx — Mutable loop context.
  • tool_calls — Tool calls from model output.
  • ctx — Loop context (provides effective_max_tool_calls_per_turn, P3-18).
Returns
  • Vector of result messages to append to context.
  • One result message per processed call, in processing order; short of the input count when the batch was truncated or a circuit-breaker/directive stopped it early.

const ToolCallHistory & entropic::ToolExecutor::tool_history() const

Access the tool-call history ring buffer.

Returns
Const reference to history (read-only for validator retry enrichment and diagnostic tools).

void entropic::ToolExecutor::set_hooks(const HookInterface &hooks)

Set the hook dispatch interface.

Parameters
  • hooks — Hook dispatch interface.

void entropic::ToolExecutor::set_authorization_manager(MCPAuthorizationManager *auth_mgr)

Set the MCP authorization manager.

Parameters
  • auth_mgr — Authorization manager (must outlive ToolExecutor).