bigread-mcp

bigread-mcp

Calculates optimal chunk offsets for large files to bypass Claude Code's 50K character truncation limit while maintaining native Read/Edit/Write compatibility. It allows the AI to seamlessly re-read files in correctly-sized pieces by providing a specific reading plan.

Category
访问服务器

README

bigread-mcp

Fixes Claude Code's "Output too large" file truncation problem.

When Claude Code reads a file larger than ~50K characters, the persisted-output mechanism truncates the result to a 2KB preview — the AI loses access to the full content. bigread calculates optimal chunk offsets so Claude can re-read the file in correctly-sized pieces using its built-in Read tool, preserving full Read/Edit/Write compatibility.

No file content is returned — just the reading plan (offsets, limits, chunk count). Claude's own Read tool does the actual reading, so you keep full editing capabilities on the file.

Install

claude mcp add --transport stdio --scope user bigread -- npx -y github:r3xsean/bigread-mcp

One command. Works on Windows, macOS, and Linux.

Setup

Add this to your CLAUDE.md so the AI uses it automatically when truncation occurs:

# File Reading

When using the Read tool, do NOT pass a `limit` parameter unless the file is known to be
extremely large (10,000+ lines). Omitting `limit` reads the entire file, which is almost
always what the user wants.

When a Read tool result shows `Output too large` with a `persisted-output` tag, the full
content was NOT loaded into your context — you only received a ~2KB preview. To get the full
file, call the `bigread` MCP tool with the file path — it returns pre-calculated chunk offsets
and limits sized to fit under the truncation threshold. Then read all chunks in parallel using
the Read tool with the returned `offset` and `limit` values. Do NOT tell the user the file was
truncated or ask them to split it — just seamlessly call bigread and re-read in chunks.

Recommended environment variables

Add these to ~/.claude/settings.json alongside bigread for complete coverage:

{
  "env": {
    "CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS": "500000",
    "MAX_MCP_OUTPUT_TOKENS": "500000",
    "BASH_MAX_OUTPUT_LENGTH": "200000"
  }
}

These raise separate, earlier limits (token cap and bash output cap) that can also cause truncation. bigread fixes the persisted-output character cap — the one that's not configurable via env vars.

The Problem

Claude Code has a hardcoded 50,000 character per-tool output cap. Any tool result exceeding this triggers persisted-output:

  • Full content is saved to a temp file on disk
  • The AI receives only a 2KB preview (2,000 characters)
  • The AI cannot see the rest of the file in its context
  • Reading the temp file triggers the same cap — infinite loop

Setting CLAUDE_CODE_FILE_READ_MAX_OUTPUT_TOKENS does not fix this — that controls a separate, earlier token limit. The 50K character cap is a different system entirely and has no env var override.

How It Works

AI tries to read large-file.md → gets "Output too large" with 2KB preview
                                    ↓
AI calls bigread({ filePath: "/path/to/large-file.md" })
                                    ↓
bigread returns: {
  totalLines: 756,
  totalChars: 60428,
  charsPerLine: 80,
  linesPerChunk: 500,
  chunks: [
    { offset: 1, limit: 500 },
    { offset: 501, limit: 256 }
  ]
}
                                    ↓
AI reads all chunks in parallel using built-in Read tool with those offsets
                                    ↓
Full file in context. No truncation. Full edit/write capability preserved.
  1. Reads the file to get total character count and line count
  2. Calculates average characters-per-line for that specific file
  3. Computes how many lines fit in 40K characters (safe margin under the 50K threshold)
  4. Returns chunk definitions with 1-based offset and limit matching the Read tool's API

If the file is small enough to fit in one read (<40K chars), it says so — no unnecessary chunking.

Why Not Just Use offset/limit Manually?

You could instruct the AI to run wc, calculate chunk sizes, and build offset/limit pairs itself. But that's 4 steps the AI has to execute and get right every time, burning context and tool calls on arithmetic. bigread does it in one call and returns exactly what the Read tool needs.

Why Not Return File Content Directly?

Claude Code only tracks files for editing when they're read through the built-in Read tool. If an MCP server returns file content directly, Claude can read it but can't Edit or Write to it afterward. By returning only the reading plan, Claude uses its own Read tool for the actual reading — keeping full read/edit/write compatibility intact.

Technical Details

Constant Value What it controls
Persisted-output threshold 50,000 chars When tool results get truncated to 2KB preview
Preview size 2,000 chars How much of the truncated result the AI can see
bigread chunk target 40,000 chars Safe size per chunk (10K margin under threshold)
Token estimation ~4 chars/token How Claude Code estimates tokens from character count

License

MIT

推荐服务器

Baidu Map

Baidu Map

百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。

官方
精选
JavaScript
Playwright MCP Server

Playwright MCP Server

一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。

官方
精选
TypeScript
Magic Component Platform (MCP)

Magic Component Platform (MCP)

一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。

官方
精选
本地
TypeScript
Audiense Insights MCP Server

Audiense Insights MCP Server

通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。

官方
精选
本地
TypeScript
VeyraX

VeyraX

一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。

官方
精选
本地
graphlit-mcp-server

graphlit-mcp-server

模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。

官方
精选
TypeScript
Kagi MCP Server

Kagi MCP Server

一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。

官方
精选
Python
e2b-mcp-server

e2b-mcp-server

使用 MCP 通过 e2b 运行代码。

官方
精选
Neon MCP Server

Neon MCP Server

用于与 Neon 管理 API 和数据库交互的 MCP 服务器

官方
精选
Exa MCP Server

Exa MCP Server

模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。

官方
精选