feat(filesystem): add streaming get_file_hash
tool for cryptographic digests (md5/sha1/sha256)
#2516
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Add a streaming file-hash tool to the filesystem server with Zod-validated
inputs, allowed-roots enforcement, and optional digest encoding.
Description
This PR adds a new tool,
get_file_hash
, to the filesystem MCP server.crypto.createHash
+ streamingfs.createReadStream
(efficient on large files)md5
,sha1
,sha256
(default:sha256
)"hex"
(default) or"base64"
(optional)ListTools
registrationServer Details
Motivation and Context
I’m a computer forensics expert; verifying file integrity is critical to chain of
custody. Standards (e.g., ISO/IEC 27037, SWGDE) emphasize hashing digital evidence.
NIST recommends collision-resistant hashes (SHA-2); SHA-1/MD5 remain for legacy
identification but not for collision-sensitive uses. This tool defaults to SHA-256
while retaining MD5/SHA-1 for interoperability. Keeping the algorithm set small
improves DFIR compatibility and simplifies model prompts.
Providing
get_file_hash
inside the filesystem server lets LLM-driven workflowscompute/compare hashes under the same allowed-roots and realpath/symlink controls
as other file operations—no external copying, consistent and auditable results.
How Has This Been Tested?
MCP server; tool discovered via
ListTools
)"abc"
,"ForensicShark"
), small binary snippet,encodings (hex/base64), non-regular paths rejected (dir/symlink/device), and
unsupported algorithms (e.g.,
sha512
,crc32
,whirlpool
) rejected by policyclear error on unavailable algorithms (FIPS/build)
Breaking Changes
None. Additive only.
Types of changes
Checklist
Additional context
list_directory
) when calling the tool from clients.only the digest string.
md5
,sha1
,sha256
are supported by design; no extended algorithmsor env toggles in this PR.