mcp-readonly-fs
This server does not currently have a deployable release on Glama. Follow the repository's setup instructions to install and configure it for your MCP client, including any required credentials and local dependencies.
mcp-readonly-fs
Read-only MCP filesystem server over allowlisted roots with realpath containment, deny globs on real paths, size and binary caps, and readOnlyHint tools
Problem
Giving an agent file access through a general filesystem server exposes write tools, secrets such as .env files, and paths outside the intended folders, reachable through traversal, symlinks or Windows path quirks. Many setups only need read access to a few directories. This package exposes four read-only MCP tools (list_directory, read_file, search_files, stat) over allowlisted roots. Path resolution is pure and tested separately from the MCP layer. The threat model is in docs/SECURITY.md.
Related MCP server: chatgpt-file-mcp
Install
npm install @trysac/mcp-readonly-fsRequires Node.js 20 or newer. The package ships ES modules with TypeScript declarations. Runtime dependencies are @modelcontextprotocol/sdk (^1.23.0) and zod (^4.1.0).
Usage
import { createPolicy, createReadonlyFsServer } from "@trysac/mcp-readonly-fs";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
const policy = await createPolicy({ roots: ["./docs"] });
const server = createReadonlyFsServer(policy, {
onEvent: (e) => console.error(e.tool, e.ok, e.code),
});
await server.connect(new StdioServerTransport());createPolicy throws PolicyError when a root does not exist or is not a directory.
Command line
src/cli.ts exports run(argv, io), which parses the flags below and serves over stdio. It is not re-exported by the package entry point and the package declares no bin entry.
--root DIR # repeatable, required
--deny GLOB # extra deny glob, added to the defaults
--max-file-bytes N # default 1 MiB
--max-results N # default 200Exit codes: 0 success, 1 runtime server failure, 2 usage, IO or parse errors.
API
Export | Signature | Description |
|
| Builds a frozen policy with realpath-resolved roots. Throws |
|
| Returns |
|
| Matches deny globs against a root-relative POSIX path. Inputs longer than 8192 characters are denied. |
|
| Creates an MCP server with the four read-only tools. |
|
| Stable code: |
Tool error codes returned by the tools: OUTSIDE_ROOT, DENIED, NOT_FOUND, TOO_LARGE, BINARY, INVALID_PATH, NOT_A_FILE, NOT_A_DIRECTORY. An error result has isError: true and text ERROR <CODE>: <requested path>, truncated to 200 characters. It never contains the resolved real path.
Tools
Tool | Arguments | Result |
|
| JSON with |
|
| UTF-8 text. Invalid bytes become U+FFFD and a leading BOM is removed. |
|
| JSON with |
|
| JSON with |
All tools are annotated readOnlyHint: true and openWorldHint: false.
Limits and options
Option | Default | Limit |
| 1 MiB | 1 to 2^28 bytes |
| 200 | 1 to 100000 |
| 10000 | 1 to 1000000 entries examined |
| 32 | 1 to 256 |
|
| At most 256 globs of 1 to 256 characters |
Paths are limited to 4096 characters. Roots: 1 to 64 directories. createPolicy replaces the default deny list when deny is given; the CLI --deny option adds to the defaults. Content search reads at most 64 MiB in total per call.
Why not server-filesystem
The reference server-filesystem MCP server ships write tools and has no deny list. This package exposes only read operations and hides secret-like paths by default.
Development
npm install
npm run check # lint, format, types, tests with coverage, docs, secretsSee AGENTS.md for the full command list and CONTRIBUTING.md for the workflow.
Security
The threat model, the defended and undefended cases, and the limits are described in docs/SECURITY.md.
License
MIT © 2026 Miguel Gomez
This server cannot be deployed
Maintenance
Related MCP Connectors
Read-only MCP access to a documented IT fleet: state, changes, posture. 15 tools.
Audit, pin and diff agent tool lists; preflight and watch remote MCP servers. Free tier; x402.
Read-only verifier for 25 ProofRelay MCP tools and non-confidential evidence bundles.
Read-only MCP tools for AI agent discovery, structured resources, and NIULAI information.
Related MCP Servers
- AlicenseNot gradedqualityDmaintenanceEnables safe, read-only browsing of allowlisted local directories through MCP, providing tools to list roots, read files, and search text.MIT
- FlicenseNot gradedqualityCmaintenanceEnables local ChatGPT/OpenAI MCP clients to read files and search within explicitly authorized directories using read-only, policy-constrained tools.1-
- AlicenseNot gradedqualityAmaintenanceEnables AI agents to securely list, find, search, read, and stat files in selected Linux directories via read-only MCP tools, with no write, execute, or escape capabilities.6MIT
- AlicenseNot gradedqualityBmaintenanceExposes tools for listing files and reading their contents over stdio, allowing MCP clients to inspect local filesystem paths during agent runs.MIT