MCPIgnore Filesystem MCP Server with .mcpignore Access Control
Protect sensitive data with an MCP server using .mcpignore access control to prevent MCP clients from accessing restricted files.
npx -y @CyberhavenInc/filesystem-mcpignoreOverview
The MCPIgnore Filesystem MCP Server is a file-backed Model Context Protocol (MCP) server that enforces access control using .mcpignore files placed alongside your filesystem content. It prevents MCP clients from reading or traversing files and directories that match deny patterns, enabling safer sharing of local or mounted data with models and AI tooling while keeping sensitive artifacts inaccessible.
This approach is useful when you need to expose a filesystem to models (for retrieval, context augmentation, or data-access tools) but must avoid leaking secrets, credentials, or private artifacts. By adopting a simple, gitignore-like syntax, .mcpignore provides a developer-friendly way to specify which paths are off-limits to MCP clients without changing your existing deployment or storage layout.
Features
- .mcpignore-based access control with a familiar pattern syntax
- Per-directory ignore files, resolved from the requested path upward
- Support for glob patterns, negation (!), and comments
- Configurable server root directory and runtime options
- Simple CLI for local testing and integration into CI/CD
- Logging and diagnostic output for auditing access decisions
Installation / Configuration
Clone the project and run the server. The repository includes a compiled binary for many platforms; you can also build from source.
Clone and build from source:
# If the project is Go-based:
Run the server (example):
# serve the /data directory on port 8080
Example configuration (JSON/YAML-style; server accepts CLI flags or a config file):
root: /data
port: 8080
log_level: info
follow_symlinks: false
max_file_size_bytes: 10485760 # 10 MB
Configuration options (summary):
| Option | Type | Default | Description |
|---|---|---|---|
| root | string | required | Filesystem root to expose to MCP clients |
| port | int | 8080 | TCP port for the MCP server |
| log_level | string | info | one of debug, info, warn, error |
| follow_symlinks | bool | false | whether to resolve symlinks outside root |
| max_file_size_bytes | int | 10485760 | max file bytes a client can request |
Note: Exact CLI flags and config keys may vary; consult the repo’s README or binary --help for authoritative details.
.mcpignore: Syntax and Semantics
.mcpignore files use a simple, familiar syntax similar to .gitignore:
- Blank lines and lines starting with
#are ignored (comments). foomatches files or directories namedfooanywhere in the same directory.build/matches a directory named build.*.keymatches any file with.keyextension.!important.keynegates a previous pattern (allows access).- Leading slash
/secretmatches paths relative to the directory containing the .mcpignore file.
Example .mcpignore:
# deny keys and environment files
*.key
.env
# deny the private config directory
private/
# allow special key needed by the model
!important.key
Precedence: the server resolves ignore files by walking from the requested path up to the root, combining patterns. Later rules can override earlier ones via negation.
Available Resources
- Project repository: https://github.com/CyberhavenInc/filesystem-mcpignore
- Issue tracker and feature requests: Use the repository Issues page
- Example content and test cases: see the
examples/ortests/directory in the repo - Binary help:
./mcp-server --helpfor runtime flags and usage
Use Cases
Protecting secrets in a codebase
- When providing a local code repository to a code-aware model, place
.mcpignoreat the repo root to deny access to.env,secrets/, or SSH keys while exposing source files.
- When providing a local code repository to a code-aware model, place
Multi-tenant data hosting
- Host a shared dataset directory for multiple models but use per-tenant
.mcpignorefiles to prevent clients from reading other tenants’ directories or metadata files.
- Host a shared dataset directory for multiple models but use per-tenant
CI/CD and safe evaluation
- Expose build artifacts to a model-based test runner but block access to credentials or internal tooling using
.mcpignore, ensuring test-time model queries cannot leak sensitive information.
- Expose build artifacts to a model-based test runner but block access to credentials or internal tooling using
Gradual rollout and auditing
- Start by ignoring highly sensitive patterns (e.g.,
*.pem,credentials.json), then iterate based on audit logs. The server logs access denials to help tune ignore rules.
- Start by ignoring highly sensitive patterns (e.g.,
Examples
Deny .pem files anywhere under the root:
*.pem
Deny everything under secrets/ but allow a specific file:
secrets/
!secrets/public.json
Place a .mcpignore in /data/project/ to restrict that project only:
# /data/project/.mcpignore
.env
build/
*.key
Security Notes
- .mcpignore patterns are evaluated before serving content. Files matched by deny patterns will not be readable by MCP clients.
- Avoid symlink escapes: set
follow_symlinks: falseunless you intentionally want symlink resolution; symlinks may allow access outside the root. - Combine server-level options (root, max file size) with .mcpignore to limit exposure.
For full implementation details, usage examples, and issues, see the repository at https://github.com/CyberhavenInc/filesystem-mcpignore.