|
Entropic 2.3.8
Local-first agentic inference engine
|
Manages MCP server instances and routes tool calls. More...
#include <entropic/mcp/server_manager.h>
Public Member Functions | |
| ServerManager (const PermissionsConfig &permissions, const std::filesystem::path &project_dir) | |
| Construct with permission config and project directory. | |
| void | register_server (std::unique_ptr< MCPServerBase > server) |
| Register a built-in server (in-process, ownership transferred). | |
| void | init_builtins (const MCPConfig &mcp_config, const std::vector< std::string > &tier_names, const std::string &data_dir) |
| Register built-in servers based on config flags. | |
| void | initialize () |
| Initialize all registered servers. | |
| std::string | list_tools () const |
| List all tools from all connected servers. | |
| std::string | execute (const std::string &tool_name, const std::string &args_json) |
| Execute a tool call via the appropriate server. | |
| MCPServerBase * | get_server (const std::string &name) const |
| Get a registered in-process server by name. | |
| std::vector< std::string > | server_names () const |
| List registered server names (in-process + external). | |
| const std::filesystem::path & | project_dir () const |
| Get the project root directory. | |
| std::string | get_tool_schema (const std::string &tool_name) const |
| Get the JSON Schema for a tool's input parameters. | |
| bool | is_explicitly_allowed (const std::string &tool_name, const std::string &args_json) const |
| Check if tool is explicitly allowed (skip prompting). | |
| std::string | get_permission_pattern (const std::string &tool_name, const std::string &args_json) const |
| Generate permission pattern via server class delegation. | |
| bool | skip_duplicate_check (const std::string &tool_name) const |
| Check if tool should skip duplicate detection. | |
| MCPAccessLevel | get_required_access_level (const std::string &tool_name) const |
| Get the required access level for a tool. | |
| void | add_permission (const std::string &pattern, bool allow) |
| Add a runtime permission pattern. | |
| void | shutdown () |
| Shutdown all servers (in-process + external). | |
| std::vector< std::string > | connect_external_server (const ExternalServerConfig &spec) |
| Connect to an external MCP server at runtime (canonical spec-based API). | |
| std::vector< std::string > | connect_external_server (const std::string &name, const std::string &command="", const std::vector< std::string > &args={}, const std::string &url="") |
| Connect by primitive parameters (legacy convenience). | |
| void | disconnect_external_server (const std::string &name) |
| Disconnect and remove an external server. | |
| std::map< std::string, ServerInfo > | list_server_info () const |
| Get snapshot of all servers with current status. | |
| void | process_health_events () |
| Process pending health events (call from engine loop). | |
| void | set_mcp_config (const MCPConfig &config) |
| Set MCP config for external server initialization. | |
| void | interrupt_external_tools () |
| Abort in-flight tool calls across every external MCP client. | |
Manages MCP server instances and routes tool calls.
Owns both in-process servers (v1.8.5) and external MCP clients (v1.8.7). Tool routing by server prefix is uniform across both. External servers discovered from .mcp.json and YAML config.
Definition at line 56 of file server_manager.h.
| entropic::ServerManager::ServerManager | ( | const PermissionsConfig & | permissions, |
| const std::filesystem::path & | project_dir | ||
| ) |
Construct with permission config and project directory.
| permissions | Permission configuration. |
| project_dir | Project root directory. |
| permissions | Permission configuration. |
| project_dir | Project root directory. |
Definition at line 32 of file server_manager.cpp.
| void entropic::ServerManager::add_permission | ( | const std::string & | pattern, |
| bool | allow | ||
| ) |
Add a runtime permission pattern.
| pattern | Permission pattern. |
| allow | true for allow list, false for deny list. |
| pattern | Permission pattern. |
| allow | true for allow list. |
Definition at line 359 of file server_manager.cpp.
| std::vector< std::string > entropic::ServerManager::connect_external_server | ( | const ExternalServerConfig & | spec | ) |
Connect to an external MCP server at runtime (canonical spec-based API).
Connect (canonical spec-based) — Issue #9, v2.1.4.
Issue #9 (v2.1.4): unifies the runtime API and config-file paths. The full ExternalServerConfig is honored — including env, which pre-2.1.4 was silently dropped from the 4-arg path. The ServerConfig.name field is required.
| spec | Full server config (transport/command/args/env/url). |
The full ExternalServerConfig is honored. Replaces the pre-2.1.4 runtime path which silently dropped env (and any future spec field).
Definition at line 598 of file server_manager.cpp.
| std::vector< std::string > entropic::ServerManager::connect_external_server | ( | const std::string & | name, |
| const std::string & | command = "", |
||
| const std::vector< std::string > & | args = {}, |
||
| const std::string & | url = "" |
||
| ) |
Connect by primitive parameters (legacy convenience).
Legacy primitive-args overload — forwards to spec-based API.
Forwards to the spec-based overload above; provided for backwards-compat with in-tree callers. Pre-2.1.4 callers that passed only command/args/url get default-empty env. Prefer the spec-based overload for new code. (#9, v2.1.4)
| name | Unique server name. |
| command | Stdio command (mutually exclusive with url). |
| args | Stdio command arguments. |
| url | SSE endpoint URL (mutually exclusive with command). |
Retained for in-tree callers that pre-date #9. New code should use the spec-based overload.
Definition at line 640 of file server_manager.cpp.
| void entropic::ServerManager::disconnect_external_server | ( | const std::string & | name | ) |
Disconnect and remove an external server.
| name | Server name to disconnect. |
| name | Server name. |
Definition at line 659 of file server_manager.cpp.
| std::string entropic::ServerManager::execute | ( | const std::string & | tool_name, |
| const std::string & | args_json | ||
| ) |
Execute a tool call via the appropriate server.
| tool_name | Fully-qualified name (e.g., "filesystem.read_file"). |
| args_json | JSON arguments string. |
Checks permissions before execution. Returns error JSON if denied or server not found.
| tool_name | Fully-qualified name. |
| args_json | JSON arguments. |
Definition at line 153 of file server_manager.cpp.
| std::string entropic::ServerManager::get_permission_pattern | ( | const std::string & | tool_name, |
| const std::string & | args_json | ||
| ) | const |
Generate permission pattern via server class delegation.
Generate permission pattern via server delegation.
| tool_name | Fully-qualified tool name. |
| args_json | Tool arguments as JSON. |
| tool_name | Fully-qualified tool name. |
| args_json | Tool arguments. |
Definition at line 301 of file server_manager.cpp.
| MCPAccessLevel entropic::ServerManager::get_required_access_level | ( | const std::string & | tool_name | ) | const |
Get the required access level for a tool.
| tool_name | Fully-qualified tool name (e.g., "filesystem.read_file"). |
| tool_name | Fully-qualified tool name. |
Definition at line 338 of file server_manager.cpp.
| MCPServerBase * entropic::ServerManager::get_server | ( | const std::string & | name | ) | const |
Get a registered in-process server by name.
| name | Server name (e.g., "entropic", "filesystem"). |
| name | Server name. |
Definition at line 177 of file server_manager.cpp.
| std::string entropic::ServerManager::get_tool_schema | ( | const std::string & | tool_name | ) | const |
Get the JSON Schema for a tool's input parameters.
| tool_name | Fully-qualified tool name. |
| tool_name | Fully-qualified tool name. |
Definition at line 206 of file server_manager.cpp.
| void entropic::ServerManager::init_builtins | ( | const MCPConfig & | mcp, |
| const std::vector< std::string > & | tier_names, | ||
| const std::string & | data_dir | ||
| ) |
Register built-in servers based on config flags.
Creates and registers enabled built-in servers (entropic, filesystem, bash, git, diagnostics, web). Called by the facade after construction.
| mcp_config | MCP config with enable flags. |
| tier_names | Tier names for entropic server schemas. |
| data_dir | Bundled data directory path. |
| mcp | MCP config with enable flags. |
| tier_names | Tier names for entropic server. |
| data_dir | Bundled data directory. |
Definition at line 46 of file server_manager.cpp.
| void entropic::ServerManager::initialize | ( | ) |
Initialize all registered servers.
Initialize all registered servers + external connections.
Definition at line 97 of file server_manager.cpp.
| void entropic::ServerManager::interrupt_external_tools | ( | ) |
Abort in-flight tool calls across every external MCP client.
Signal every external client to cancel its in-flight tool.
Invoked from the engine's interrupt path so Ctrl+C unwinds docs_server.py / bash etc. within ~100ms instead of waiting out the transport timeout. (P1-10, 2.0.6-rc16)
@utility
Called by AgentEngine::interrupt() via a facade-wired callback so tool dispatches to docs_server.py / bash / git unwind within ~100ms of Ctrl+C instead of running to completion. (P1-10, 2.0.6-rc16)
Definition at line 467 of file server_manager.cpp.
| bool entropic::ServerManager::is_explicitly_allowed | ( | const std::string & | tool_name, |
| const std::string & | args_json | ||
| ) | const |
Check if tool is explicitly allowed (skip prompting).
Check if tool is explicitly allowed.
| tool_name | Fully-qualified tool name. |
| args_json | Tool arguments as JSON. |
| tool_name | Fully-qualified tool name. |
| args_json | Tool arguments. |
Definition at line 286 of file server_manager.cpp.
| std::map< std::string, ServerInfo > entropic::ServerManager::list_server_info | ( | ) | const |
Get snapshot of all servers with current status.
Definition at line 686 of file server_manager.cpp.
| std::string entropic::ServerManager::list_tools | ( | ) | const |
List all tools from all connected servers.
List tools from all servers (in-process + external).
Definition at line 113 of file server_manager.cpp.
| void entropic::ServerManager::process_health_events | ( | ) |
Process pending health events (call from engine loop).
Process pending health events.
Definition at line 708 of file server_manager.cpp.
|
inline |
Get the project root directory.
Definition at line 137 of file server_manager.h.
| void entropic::ServerManager::register_server | ( | std::unique_ptr< MCPServerBase > | server | ) |
Register a built-in server (in-process, ownership transferred).
Register a built-in server.
| server | Server instance. |
| server | Server instance (ownership transferred). |
Definition at line 81 of file server_manager.cpp.
| std::vector< std::string > entropic::ServerManager::server_names | ( | ) | const |
List registered server names (in-process + external).
List all registered server names.
Definition at line 188 of file server_manager.cpp.
| void entropic::ServerManager::set_mcp_config | ( | const MCPConfig & | config | ) |
Set MCP config for external server initialization.
| config | MCP configuration with external_servers. |
| config | MCP configuration. |
Definition at line 453 of file server_manager.cpp.
| void entropic::ServerManager::shutdown | ( | ) |
Shutdown all servers (in-process + external).
Definition at line 369 of file server_manager.cpp.
| bool entropic::ServerManager::skip_duplicate_check | ( | const std::string & | tool_name | ) | const |
Check if tool should skip duplicate detection.
| tool_name | Fully-qualified tool name. |
| tool_name | Fully-qualified tool name. |
Definition at line 320 of file server_manager.cpp.