# read_text_file

Read the complete contents of a file from the file system as text. Handles various text encodings and provides detailed error messages if the file cannot be read. Use this tool when you need to examine the contents of a single file. Use the 'head' parameter to read only the first N lines of a file, or the 'tail' parameter to read only the last N lines of a file. Operates on the file as text regardless of extension. Only works within allowed directories.

Agent View of the PolicyLayer registry record for `read_text_file`. HTML page: https://policylayer.com/tools/filesystem/read-text-file

## Facts

- Tool: `read_text_file`
- Server: Filesystem (`@modelcontextprotocol/server-filesystem`) — https://policylayer.com/tools/filesystem.md
- Install: `npx -y @modelcontextprotocol/server-filesystem`
- Homepage: https://github.com/modelcontextprotocol/server-filesystem
- Risk category: Read (Low risk)
- Registry record: grade D, identity verified
- Server rate-limited: no
- Parameters: 3 (1 required)
- Recommended policy verdict: Allowed

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| `head` | number | no | If provided, returns only the first N lines of the file |
| `path` | string | yes |  |
| `tail` | number | no | If provided, returns only the last N lines of the file |

Parameters from the server's own tool schema.

## Example call (MCP tools/call, JSON-RPC 2.0)

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "tools/call",
  "params": {
    "name": "read_text_file",
    "arguments": {
      "path": "<path>"
    }
  }
}
```

## Why read_text_file is rated Low

This tool retrieves and queries file contents with no side effects or modifications. It performs a read-only operation on the filesystem. The low severity reflects the minimal risk—an AI agent using this tool can only view data within permitted directories, with no ability to create, modify, delete, or execute anything.

From the tool's own definition: "Tool name is 'read_text_file' and description states 'Read the complete contents of a file from the file system as text.' It provides options to read with 'head' and 'tail' parameters for partial reads."

Risk signals: Accepts file system path (path)

## Use case

AI agents call read_text_file to retrieve information from Filesystem without modifying anything. It is typically the context-gathering step in research, monitoring, and reporting workflows, before the agent takes action elsewhere.

## Recommended policy (PolicyLayer)

Verdict: **Allowed**. Enforced by the PolicyLayer MCP gateway (https://policylayer.com/mcp-gateway) before a call reaches Filesystem:

```json
{
  "version": "1",
  "default": "deny",
  "tools": {
    "read_text_file": {}
  }
}
```

## Other tools on Filesystem (13)

- `directory_tree` — Read — https://policylayer.com/tools/filesystem/directory-tree.md
- `get_file_info` — Read — https://policylayer.com/tools/filesystem/get-file-info.md
- `list_allowed_directories` — Read — https://policylayer.com/tools/filesystem/list-allowed-directories.md
- `list_directory` — Read — https://policylayer.com/tools/filesystem/list-directory.md
- `list_directory_with_sizes` — Read — https://policylayer.com/tools/filesystem/list-directory-with-sizes.md
- `read_file` — Read — https://policylayer.com/tools/filesystem/read-file.md
- `read_media_file` — Read — https://policylayer.com/tools/filesystem/read-media-file.md
- `read_multiple_files` — Read — https://policylayer.com/tools/filesystem/read-multiple-files.md
- `search_files` — Read — https://policylayer.com/tools/filesystem/search-files.md
- `create_directory` — Write — https://policylayer.com/tools/filesystem/create-directory.md
- `edit_file` — Write — https://policylayer.com/tools/filesystem/edit-file.md
- `move_file` — Write — https://policylayer.com/tools/filesystem/move-file.md
- `write_file` — Write — https://policylayer.com/tools/filesystem/write-file.md

## For agents

This record is a snapshot. Live verdicts and the full registry:

- Check every server in your MCP config at once: `npx -y policylayer stack`
- Vet a server before you add it: install the mcp-precheck skill — `npx skills add https://policylayer.com` (skill text: https://policylayer.com/skill.md)
- Query the registry over MCP: endpoint `https://api.policylayer.com/mcp` — tools `check_mcp_server`, `check_mcp_stack`, `check_tool`, `search_registry`, `get_change_events`

---

Source: the PolicyLayer MCP registry — one continuously verified record per MCP server. Full record: https://policylayer.com/registry?q=filesystem · API: https://policylayer.com/registry/api · Policy library: https://policylayer.com/policies/filesystem
