Entropic 2.3.8
Local-first agentic inference engine
Loading...
Searching...
No Matches
entropic::FilesystemServer Class Reference

Filesystem MCP server with read-before-write enforcement. More...

#include <entropic/mcp/servers/filesystem.h>

Inheritance diagram for entropic::FilesystemServer:
Collaboration diagram for entropic::FilesystemServer:

Public Member Functions

 FilesystemServer (const std::filesystem::path &root_dir, const FilesystemConfig &config, const std::string &data_dir, int model_context_bytes=0)
 Construct with root directory, config, and data dir.
 
 ~FilesystemServer () override
 Destructor (default, unique_ptr cleanup).
 
bool skip_duplicate_check (const std::string &tool_name) const override
 read_file must always execute (updates FileAccessTracker).
 
bool set_working_dir (const std::string &path) override
 Set working directory (changes root_dir).
 
const std::filesystem::path & root_dir () const
 Get the root directory.
 
FileAccessTrackertracker ()
 Get the file access tracker.
 
const FilesystemConfigconfig () const
 Get the filesystem config.
 
int max_read_bytes () const
 Get max read bytes (size gate).
 
std::filesystem::path resolve_path (const std::string &requested) const
 Resolve and validate a path against root.
 
const IgnoreMatcherignore () const
 Get the ignore matcher (#15, v2.1.4).
 
- Public Member Functions inherited from entropic::MCPServerBase
 MCPServerBase (std::string name)
 Construct with server name.
 
const std::string & name () const
 Get the server name.
 
void register_tool (ToolBase *tool)
 Register a tool with this server.
 
std::string list_tools () const
 List all registered tools as a JSON array string.
 
std::string execute (const std::string &tool_name, const std::string &args_json)
 Execute a tool and wrap result in ServerResponse JSON.
 
virtual std::string get_permission_pattern (const std::string &tool_name, const std::string &args_json) const
 Generate permission pattern for 'Always Allow/Deny'.
 
virtual bool configure (const std::string &config_json)
 Configure the server after creation.
 
const ToolRegistryregistry () const
 Get the tool registry (const).
 

Additional Inherited Members

- Protected Attributes inherited from entropic::MCPServerBase
std::string name_
 Server name.
 
ToolRegistry registry_
 Tool registry.
 

Detailed Description

Filesystem MCP server with read-before-write enforcement.

Version
1.8.5

Definition at line 74 of file filesystem.h.

Constructor & Destructor Documentation

◆ FilesystemServer()

entropic::FilesystemServer::FilesystemServer ( const std::filesystem::path &  root_dir,
const FilesystemConfig config,
const std::string &  data_dir,
int  model_context_bytes = 0 
)

Construct with root directory, config, and data dir.

Construct filesystem server, create and register all tools.

Parameters
root_dirProject root directory.
configFilesystem configuration.
data_dirPath to bundled data directory (for tool JSONs).
model_context_bytesModel context window in bytes (for size gate).
Version
1.8.5

Issue #15 (v2.1.4): also loads .gitignore + .explorerignore via the IgnoreMatcher member so glob/grep/read filter ignored paths.

Parameters
root_dirProject root directory.
configFilesystem configuration.
data_dirPath to bundled data directory.
model_context_bytesModel context window in bytes.

Definition at line 1332 of file filesystem.cpp.

Member Function Documentation

◆ config()

const FilesystemConfig & entropic::FilesystemServer::config ( ) const

Get the filesystem config.

Returns
Config reference.
Version
1.8.5
Returns
Config reference.

Definition at line 1468 of file filesystem.cpp.

◆ ignore()

const IgnoreMatcher & entropic::FilesystemServer::ignore ( ) const

Get the ignore matcher (#15, v2.1.4).

Loaded from .gitignore (recursive) + .explorerignore at server construction and on set_working_dir. Used by glob, grep, and read_file to filter results / refuse access.

Returns
Matcher reference.
Version
2.1.4
Returns
Read-only matcher reference.

Definition at line 1458 of file filesystem.cpp.

◆ max_read_bytes()

int entropic::FilesystemServer::max_read_bytes ( ) const

Get max read bytes (size gate).

Get max read bytes for size gate.

Returns
Max bytes, or 0 for unlimited.
Version
1.8.5
Returns
Max bytes, or 0 for unlimited.

Definition at line 1478 of file filesystem.cpp.

◆ resolve_path()

fs::path entropic::FilesystemServer::resolve_path ( const std::string &  requested) const

Resolve and validate a path against root.

Resolve and validate a path against root directory.

Parameters
requestedUser-requested path.
Returns
Resolved canonical path.
Exceptions
std::runtime_errorif path escapes root.
Version
1.8.5

Resolves relative paths against root_dir_, canonicalizes, and checks that the result does not escape root. Throws on escape unless allow_outside_root is configured.

Containment uses lexically_relative so that "/home/user/project" does not falsely contain "/home/user/projectile" via string-prefix.

Parameters
requestedUser-requested path string.
Returns
Resolved canonical path.
Exceptions
std::runtime_errorif path escapes root.

Definition at line 1498 of file filesystem.cpp.

◆ root_dir()

const fs::path & entropic::FilesystemServer::root_dir ( ) const

Get the root directory.

Returns
Root directory path.
Version
1.8.5
Returns
Root directory path reference.

Definition at line 1438 of file filesystem.cpp.

◆ set_working_dir()

bool entropic::FilesystemServer::set_working_dir ( const std::string &  path)
overridevirtual

Set working directory (changes root_dir).

Set working directory by updating root_dir.

Parameters
pathNew root directory.
Returns
true on success.
Version
1.8.5

Issue #15 (v2.1.4): also reloads IgnoreMatcher rules so the new root's .gitignore + .explorerignore take effect immediately.

Parameters
pathNew root directory.
Returns
true on success, false if path is not a directory.

Reimplemented from entropic::MCPServerBase.

Definition at line 1417 of file filesystem.cpp.

◆ skip_duplicate_check()

bool entropic::FilesystemServer::skip_duplicate_check ( const std::string &  tool_name) const
overridevirtual

read_file must always execute (updates FileAccessTracker).

read_file always executes (updates FileAccessTracker).

Parameters
tool_nameTool name.
Returns
true for read_file.
Version
1.8.5
Parameters
tool_nameTool name to check.
Returns
true for "read_file", false otherwise.

Reimplemented from entropic::MCPServerBase.

Definition at line 1401 of file filesystem.cpp.

◆ tracker()

FileAccessTracker & entropic::FilesystemServer::tracker ( )

Get the file access tracker.

Returns
Tracker reference.
Version
1.8.5
Returns
Mutable tracker reference.

Definition at line 1448 of file filesystem.cpp.


The documentation for this class was generated from the following files: