Entropic 2.14.3
Local-first agentic inference engine
Loading...
Searching...
No Matches
filesystem.cpp File Reference

Filesystem MCP server — read/write/edit/glob/grep/list_directory. More...

#include <entropic/mcp/servers/filesystem.h>
#include <entropic/mcp/tool_base.h>
#include <entropic/mcp/server_base.h>
#include <entropic/types/logging.h>
#include <entropic/types/run_scope.h>
#include <nlohmann/json.hpp>
#include <algorithm>
#include <cstring>
#include <filesystem>
#include <fstream>
#include <functional>
#include <optional>
#include <regex>
#include <sstream>
Include dependency graph for filesystem.cpp:

Go to the source code of this file.

Classes

class  entropic::ReadFileTool
 Tool for reading file contents with line numbering. More...
 
class  entropic::WriteFileTool
 Tool for writing file contents with read-before-write. More...
 
class  entropic::EditFileTool
 Tool for in-place file editing (string replace or insert). More...
 
class  entropic::GlobTool
 Tool for recursive file pattern matching. More...
 
class  entropic::GrepTool
 Tool for regex content search across files. More...
 
class  entropic::ListDirectoryTool
 Tool for listing directory contents. More...
 

Namespaces

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

Typedefs

using json = nlohmann::json
 

Functions

std::string entropic::check_read_gates (FilesystemServer &server, const fs::path &resolved, const std::string &display)
 Execute read_file: resolve, size-check, read, hash, track.
 
std::string entropic::read_window (const json &args, long budget, ReadWindow &w)
 The window a read_file call asks for, validated.
 
json entropic::read_and_track (FilesystemServer &server, const fs::path &resolved, const std::string &display, const json &args, std::string &err)
 Read the requested window and record the read for the session.
 
std::regex entropic::compile_grep_or_error (const std::string &pattern, std::string &err)
 Compile a regex or return a structured tool error.
 
static void entropic::grep_search (const fs::path &root, const fs::path &start, const std::vector< std::string > &file_patterns, const std::regex &re, const IgnoreMatcher &ignore, WalkBudget &budget, PagedResult &page)
 Execute grep: brace-expand the file glob, compile the content regex (error-safe), iterate the tree applying the same classify_glob_entry filter glob uses.
 
static void entropic::grep_target (FilesystemServer &server, const fs::path &start, const json &args, const std::regex &re, WalkBudget &budget, PagedResult &page)
 Search start — one file, or a tree under the glob filter.
 
static std::string entropic::grep_preflight (const json &args, const fs::path &start, const fs::path &root, Page &requested, std::regex &re)
 Validate a grep call: paging, regex, and that path exists.
 
static void entropic::list_page (const fs::path &dir, const json &args, Page requested, int max_walk, json &result)
 Collect one page of a directory listing into result.
 
static int entropic::compute_max_read_bytes (const FilesystemConfig &config, int model_context_bytes)
 Compute max read bytes from config and model context.
 

Variables

static auto logger = entropic::log::get("mcp.filesystem")
 

Detailed Description

Filesystem MCP server — read/write/edit/glob/grep/list_directory.

Implements 6 tools as ToolBase subclasses, a FileAccessTracker for read-before-write enforcement, and the FilesystemServer that owns and registers all tools.

Version
1.8.5

Definition in file filesystem.cpp.

Typedef Documentation

◆ json

using json = nlohmann::json

Definition at line 31 of file filesystem.cpp.

Variable Documentation

◆ budget

long budget = 0

Max content bytes; <= 0 = unbounded.

Definition at line 596 of file filesystem.cpp.

◆ bytes

long bytes = 0

Content bytes taken.

Definition at line 607 of file filesystem.cpp.

◆ err

std::string err

size_exceeded, when set

Definition at line 609 of file filesystem.cpp.

◆ limit

long limit = 0

Results to keep.

Max lines; 0 = until the byte budget is spent.

Definition at line 461 of file filesystem.cpp.

◆ lines

json lines = json::array()

Lines taken so far.

Definition at line 606 of file filesystem.cpp.

◆ logger

auto logger = entropic::log::get("mcp.filesystem")
static

Definition at line 33 of file filesystem.cpp.

◆ max_entries

int max_entries = 0

<= 0 means unbounded

Definition at line 360 of file filesystem.cpp.

◆ more

bool more = false

A line past the window exists.

Definition at line 608 of file filesystem.cpp.

◆ offset

long offset = 0

Results to skip (from a previous next_offset)

First line, 1-based.

Definition at line 460 of file filesystem.cpp.

◆ truncated

bool truncated = false

Walk stopped on the cap.

Definition at line 362 of file filesystem.cpp.

◆ visited

long visited = 0

Entries visited so far.

Definition at line 361 of file filesystem.cpp.

◆ w

const ReadWindow& w

Requested window.

Definition at line 605 of file filesystem.cpp.