filesystem, memory: descriptions don't say how to choose between list_directory / list_directory_with_sizes and delete_entities / delete_relations
Which server?
More than one server (filesystem and memory)
Protocol era
Both, or not era-specific
MCP client
Any. The issue is in the tool descriptions that every client shows the model.
The problem
Two pairs of tools have descriptions so alike that a model can't tell which one to call.
filesystem (2026.8.31): list_directory and list_directory_with_sizes
The descriptions are the same sentence for sentence. They differ only by ", including sizes" and "essential" vs "useful":
list_directory: Get a detailed listing of all files and directories in a specified path. Results clearly distinguish between files and directories with [FILE] and [DIR] prefixes. This tool is essential for understanding directory structure and finding specific files within a directory. Only works within allowed directories.
list_directory_with_sizes: Get a detailed listing of all files and directories in a specified path, including sizes. Results clearly distinguish between files and directories with [FILE] and [DIR] prefixes. This tool is useful for understanding directory structure and finding specific files within a directory. Only works within allowed directories.
Neither says when to pick it over the other, that list_directory_with_sizes can sort by size, or that it ends with totals.
memory (2026.8.31): delete_entities and delete_relations
delete_entities: Delete multiple entities and their associated relations from the knowledge graph
delete_relations: Delete multiple relations from the knowledge graph
Both are destructive. Asked to remove a link between two entities, a model that picks delete_entities deletes the entities themselves, with all their observations. Neither description says which one to use for that.
Solution you have in mind (optional)
Say in each description when to use the tool and when to use its sibling instead. Suggested text, written only from what the code does (I checked list_directory_with_sizes's sort and summary in dist/index.js):
list_directory: List the files and directories directly inside a path, each marked [FILE] or [DIR]. Use it to see what a directory contains; when you also need each entry's size or want entries sorted by size, use list_directory_with_sizes instead, and for a recursive view use directory_tree. Returns one line per entry. Only works within allowed directories.list_directory_with_sizes: List the files and directories directly inside a path with each file's size, marked [FILE] or [DIR], sorted by name or by size (sortBy). Use it when sizes matter, such as finding the largest files; for names only, use list_directory, which returns less text. Returns one line per entry, followed by the totals. Only works within allowed directories.delete_entities: Delete whole entities from the knowledge graph, together with every relation that points to or from them and all their observations. Use it only to remove an entity entirely; to remove a link between two entities and keep both, use delete_relations, and to remove facts from an entity, use delete_observations. Cannot be undone.delete_relations: Delete specific relations (from, to, relationType) from the knowledge graph and keep the entities they connect. Use it to remove a link between two entities; to remove an entity itself, use delete_entities. Cannot be undone.
Which MCP feature does it demonstrate? (optional)
Tool descriptions, and how clients use them to choose a tool. As reference servers, these are what many people copy when writing their own.
Alternatives or workarounds you have tried
None on the server side. A client can add its own instructions, but every client would have to do it.
Already built it locally?
No code. The prompt I'd use: "In src/filesystem and src/memory, rewrite the descriptions of list_directory, list_directory_with_sizes, delete_entities and delete_relations so each says when to use it and names the sibling tool to use instead, using only behavior the code implements; keep tool names and schemas unchanged."
For context: I found these pairs with Forecall, a static linter for MCP tool descriptions that I maintain. It flags tool pairs whose descriptions overlap heavily. With the text above, its scores go from 38 and 48 to 65 and 70 for the two filesystem tools, and from 51 and 39 to 61 and 61 for the two memory tools. The scores are only a guide; the point is the missing "use X instead".
Before you submit
- [x] I searched existing issues and this is not a duplicate.
- [x] This is a request for this repository or one of its servers, not a new server, the MCP specification or an SDK.
The suggested text matches what the code does. I read src/memory/index.ts on main and have two additions for the memory pair.
- Annotations can't carry the distinction. Both
delete_entitiesanddelete_relationsare registered withdestructiveHint: true, idempotentHint: true, so a client that gates on the hint sees two identical tools, and the description is the only place the difference lives. That supports putting the "use X instead" sentence in both, as proposed. deleteRelationsremoves a relation only whenfrom,toandrelationTypeall match exactly. A model that guesses the type ("works_at" for a stored "works at") getssuccess: truewith the message "Deleted 0 of 1 relations. The rest matched nothing." A short clause in thedelete_relationsdescription, "must match an existing relation exactly on all three fields; call read_graph or search_nodes first if unsure", would save the retry loop and keeps the model from falling back todelete_entitiesto make the link go away.
Also deleteEntities filters out every relation where the entity is from or to (line ~269), so "and all their observations" in the proposed text is right and "relations that point to or from them" is also right; that matches the code.
Source read via the API, not run.
Thanks, @arhancanli. I checked both points in src/memory/index.ts on main and they're right: deleteRelations removes a relation only when from, to and relationType all match (around line 299), and delete_entities and delete_relations are both registered with destructiveHint: true, idempotentHint: true, so the annotations can't tell them apart.
I also measured the issue's claim, and need to correct it. With four models (Claude Opus 5.5, Claude Sonnet 5.5, gpt-6-astra, gpt-6.1-sol), one turn each, 4 tasks per pair and 2 runs, every model picked the right tool with the current descriptions: 64 of 64 for each pair, and the same with the proposed text. So "a model can't tell which one to call" doesn't hold for one-step choices; the names and schemas (sortBy, relations[{from, to, relationType}] vs entityNames) carry the difference. I withdraw that part.
Your exact-match point did show up. In a task where the stored spelling of the relation type wasn't given, the models looked it up first in 11 of 12 runs with the current text; once, a model sent a single delete_relations call with 15 guessed spellings. With an exact-match clause, 12 of 12 looked first. Worded as "call read_graph or search_nodes first", it sent half of them to read_graph, which returns the whole graph, so I'd name open_nodes first. Updated suggestion for delete_relations:
Delete specific relations (from, to, relationType) from the knowledge graph and keep the entities they connect. Each relation must match an existing one exactly on all three fields; if unsure, call open_nodes (or search_nodes) first to read the stored relationType. Use it to remove a link between two entities; to remove an entity itself, use delete_entities. Cannot be undone.
The other three suggested descriptions stand as written. What's left as the reason for the change is documentation in a reference server that people copy, plus the exact-match rule, not a measured change in which tool models pick. Updated prompt, following CONTRIBUTING: "In src/filesystem and src/memory, rewrite the descriptions of list_directory, list_directory_with_sizes, delete_entities and delete_relations as proposed in #5071 and its comments, using only behavior the code implements; keep tool names and schemas unchanged."
Benchmark data on in-flight tools/list BM25 pruning (94.0%–99.4% token reduction):
Passing multiple overlapping tool schemas (like list_directory vs list_directory_with_sizes) floods the LLM context window with thousands of lines of confusing JSON definitions on every turn—spiking time-to-first-token (TTFT) and increasing multi-hop tool hallucination rates.
We solved this at the wire level inside our Go stdio proxy without requiring any upstream MCP server rewrites:
-
Stateful tools/list Interception: The proxy intercepts the upstream capability negotiation on the wire and strips irrelevant schemas before the LLM ever sees them.
-
Sub-Millisecond Okapi BM25 Ranking: Using a CamelCase/snake_case tokenizer, the router ranks tool schemas against active intent at 311,245 rankings/sec (0.08ms wire overhead), pruning 94.00% to 99.41% of context tokens across 100,000 concurrent queries.
-
Automatic readOnlyHint Stamping: Stamps verified read tools on the fly so IDEs (Claude Desktop, Cursor) execute safe reads silently while isolating state-mutating calls behind a Wasm micro-VM circuit breaker.
We published the pipeline specs and our 10-agent BFCL swarm telemetry here if you want to see the schema reduction metrics: https://getrcf.dev/product
Triage: Priority Low (total 3)
- Severity 2: The list_directory / list_directory_with_sizes and delete_entities / delete_relations descriptions still do not say when to use each tool over its sibling, and delete_relations does not say a relation must match on from, to and relationType exactly; the reporter's own measurements found models already choose correctly, so this is description quality rather than a demonstrated misfire.
- Urgency 1: no time pressure
- Bonuses: none
Still present on v2 (checked by reading the current code).
Board: Servers V2 (#43), Status Incoming, awaiting maintainer review (no milestone yet). Part of the backlog triage in #4875.
Root Cause Analysis & Runtime Consequence Mitigation for Sibling Tool Collisions (#5071) and Unconstrained Payloads (#3537)
The destructive confusion between delete_entities and delete_relations in src/memory and list_directory vs. list_directory_with_sizes in src/filesystem highlights a two-layer failure mode across multi-tool MCP deployments:
- Upstream Description Disambiguation: Explicitly stating precondition boundaries in
src/memory(specifying thatdelete_entitiescascades deletion across all attached observations and relations, whereasdelete_relationsonly unlinks graph edges while preserving node entities) reduces baseline LLM selection error. - Why Prompt/Description Edits Alone Cannot Prevent Destructive Execution: As shown in the #3537 empirical audit (where system-prompt restrictions reduced Attack Success Rate by only
0.65%andserver-filesystemscored0/12on refusal signals), indirect prompt injections embedded in retrieved graph observations or directory filenames routinely coerce the model into callingdelete_entitiesregardless of description wording. - Deterministic L7 Pre-Execution Interception: Wrapping
server-memoryandserver-filesystembehind an inline L7stdio/HTTP consequence proxy with pre-inference Okapi BM25tools/listpruning (Accenture/mcp-benchPR #43 —88.09%schema token reduction in0.64ms) strips destructive sibling tools (delete_entities) from thetools/listresponse whenever the user prompt specifies relation/edge modification, while enforcing JSON Schema 2020-12 normalization (#4772 / #4841) and hard byte ceilings (CVE-2026-109527) in<1ms.
Root Cause Analysis & Pre-Execution Mitigation for Sibling Tool Collisions (#5071)
The destructive confusion between delete_entities and delete_relations in src/memory (2026.8.31) and list_directory vs. list_directory_with_sizes in src/filesystem (2026.8.31) highlights two distinct protocol boundary requirements:
- Upstream Description Clarification: Rewriting the tool descriptions in
src/filesystemandsrc/memoryto explicitly state precondition boundaries (specifying thatdelete_entitiescascades deletion across all attached observations and relations, whereasdelete_relationsonly removes graph edges while preserving node entities) reduces baseline LLM selection ambiguity. - Why Prompt/Description Wording Alone Cannot Prevent Accidental or Injected State Wipes: As demonstrated in the
#3537audit (where system-prompt restrictions reduced Attack Success Rate by only0.65%andfilesystemscored0/12on refusal signals), indirect prompt injections embedded in retrieved graph observations or directory filenames routinely coerce the model into callingdelete_entitiesregardless of description wording. - Deterministic L7 Pre-Execution Interception (
DT-03_SIBLING_COLLISION): In ourAccenture/mcp-bench(#43) andFINOS AIGF(#409) evaluations, applying pre-inference Okapi BM25 lexical scoring overtools/listdynamically prunesdelete_entitiesout of the active schema catalog whenever the signed user prompt specifies relationship/edge unlinking (88.09%schema token reduction in0.64msP50), while enforcing an out-of-band step-up confirmation gate (T2 -> T1_HITL_GATED) before any cascading entity deletion executes.