Skip to main content
Glama
wonderwhy-er

Claude Desktop Commander MCP

read_file

Read-only

Read file contents and URLs with offset/length pagination. Supports PDF, Excel, images, and DOCX formats for efficient content retrieval.

Instructions

                    Read contents from files and URLs.
                    Read PDF files and extract content as markdown and images.
                    
                    Prefer this over 'execute_command' with cat/type for viewing files.
                    
                    Supports partial file reading with:
                    - 'offset' (start line, default: 0)
                      * Positive: Start from line N (0-based indexing)
                      * Negative: Read last N lines from end (tail behavior)
                    - 'length' (max lines to read, default: configurable via 'fileReadLineLimit' setting, initially 1000)
                      * Used with positive offsets for range reading
                      * Ignored when offset is negative (reads all requested tail lines)
                    
                    Examples:
                    - offset: 0, length: 10     → First 10 lines
                    - offset: 100, length: 5    → Lines 100-104
                    - offset: -20               → Last 20 lines  
                    - offset: -5, length: 10    → Last 5 lines (length ignored)
                    
                    Performance optimizations:
                    - Large files with negative offsets use reverse reading for efficiency
                    - Large files with deep positive offsets use byte estimation
                    - Small files use fast readline streaming
                    
                    When reading from the file system, only works within allowed directories.
                    Can fetch content from URLs when isUrl parameter is set to true
                    (URLs are always read in full regardless of offset/length).
                    
                    FORMAT HANDLING (by extension):
                    - Text: Uses offset/length for line-based pagination
                    - Excel (.xlsx, .xls, .xlsm): Returns JSON 2D array
                      * sheet: "Sheet1" (name) or "0" (index as string, 0-based)
                      * range: ALWAYS use FROM:TO format (e.g., "A1:D100", "C1:C1", "B2:B50")
                      * offset/length work as row pagination (optional fallback)
                    - Images (PNG, JPEG, GIF, WebP): Base64 encoded viewable content
                    - PDF: Extracts text content as markdown with page structure
                      * offset/length work as page pagination (0-based)
                      * Includes embedded images when available
                    - DOCX (.docx): Two modes depending on parameters:
                      * DEFAULT (no offset/length): Returns a text-bearing outline — shows paragraphs with text,
                        tables with cell content, styles, image refs. Skips shapes/drawings/SVG noise.
                        Each element shows its body index [0], [1], etc.
                      * WITH offset/length: Returns raw pretty-printed XML with line pagination.
                        Use this to drill into specific sections or see the actual XML for editing.
                      * EDITING WORKFLOW: 1) read_file to get outline, 2) read_file with offset/length
                        to see raw XML around what you want to edit, 3) edit_block with old_string/new_string
                        using XML fragments copied from the read output.
                      * IMPORTANT: offset MUST be non-zero to get raw XML (use offset=1 to start from line 1).
                        offset=0 always returns the outline regardless of length.
                      * For BULK changes (translation, mass replacements): use start_process with Python
                        zipfile module to find/replace all <w:t> elements at once.

                    IMPORTANT: Always use absolute paths for reliability. Paths are automatically normalized regardless of slash direction. Relative paths may fail as they depend on the current working directory. Tilde paths (~/...) might not work in all contexts. Unless the user explicitly asks for relative paths, use absolute paths.
                    This command can be referenced as "DC: ..." or "use Desktop Commander to ..." in your instructions.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pathYes
isUrlNo
offsetNo
lengthNo
sheetNo
rangeNo
optionsNo
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations (readOnlyHint: true, openWorldHint: true) are consistent. The description adds rich behavioral context: performance optimizations for large files, supported directories, URL full-read behavior, and format-specific handling (e.g., Excel range format, DOCX modes, PDF page pagination). No contradictions.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is well-structured with sections for partial reading, performance, format handling, and important notes. It front-loads the core purpose, but the DOCX editing workflow is lengthy and could be condensed or moved. Overall, every sentence adds value but slightly verbose.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (7 params, nested objects, multiple formats, no output schema), the description is remarkably complete. It covers all major usage scenarios, edge cases, and format behaviors. The only minor gap is the lack of explicit return format documentation, but the description already states key return characteristics (e.g., base64 images, markdown from PDF).

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

With 0% schema description coverage, the description compensates effectively. It explains offset and length in detail with examples, covers Excel range/sheet parameters, and advises absolute paths for reliability. The 'options' object parameter is minimally described but is an open object. Some parameter details like isUrl are mentioned but could be more explicit.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states 'Read contents from files and URLs' and specifies that it can extract PDF content as markdown and images. It distinguishes itself from sibling tools like execute_command with cat/type for viewing files.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Explicitly recommends preferring this over execute_command for file viewing. Provides detailed when-to-use guidance for different file types (Excel, PDF, DOCX, images) and explains partial reading with offset/length. Includes when to use alternative tools like start_process for bulk DOCX edits.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/wonderwhy-er/DesktopCommanderMCP'

If you have feedback or need assistance with the MCP directory API, please join our Discord server