modelcontextprotocol / modelcontextprotocol/servers

filesystem mcp: dot directories should be ignored

Open
#2,219 7 comments 3 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

bug server-filesystem
Dominant language
TypeScript
Stars
90.5k
Forks
11.7k
Avg merge
2d 2h
Merged PRs (30d)
5

Description

Describe the bug
Dot directories (eg .git, .terraform, etc) are included in the filesystem MCP search tools.

These directories, particularly .git can get enormous and thus massively inflate the token usage for the agent.

What's more, these directories generally don't add much value (they're "hidden" for a reason) for project analysis. And in the worst case scenarios, might even contain sensitive information.

Personally, I'd go further and say allowing filesystem to work against any dot-prefixed filesystem objects is a security risk, however, for the sake of wanting to keep this discussion focused on reducing token count rather than whether users should or should not be aware of what data they're sharing with the agent, this GH Issue is focused on dot-prefixed directories like .git.

To Reproduce
Run the MCP with the authorised path being the root of any project that is also a git repository.

Expected behavior
Dot-prefixed directories should be ignored by default. An environmental variable and/or command line flag can be used to optionally re-enable this behaviour.

Logs

Additional context
While the intended behaviour is to selectively include the files and/or directories you wish to authorise for use with this MCP, the benefit of using an MCP like this is for speed and convenience. Thus a typical use case might well be someone selecting the entire project directory. On the surface, this is a pragmatic approach -- so long as dot-prefixed directories (and arguably files too) are ignored by default.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the filesystem MCP search tools and reproduce the issue with an authorised project root containing .git or .terraform. Trace how directory entries are selected, then verify that dot-prefixed directories are excluded by default and that the chosen environment-variable or command-line opt-in restores them.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
security, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.