Skip to main content
Glama

file

file

Read, write, generate, edit, and convert Office documents, PDFs, and text or code content, including downloading remote sources and rendering pages for visual review.

Instructions

Read existing PDFs, Word documents, spreadsheets and presentations with readContent(artifactId OR attachmentId). For a remote PDF/document URL: download(urlOrPath) → readContent(returned artifactId). Use contentPages for PDF text pages and offset/limit for text chunks; reading needs no plan/render or codeSandbox parser installation. Use visualRead for scanned pages or layout-dependent evidence when available. File workflow: readSource(documentId) reads editable HTML/Python/JavaScript; readContent(artifactId OR attachmentId) reads file text/data, NOT source. To repair layout: readSource → edit → render → visualRead using render.visualIndex.nextRead → visualReport. render includes screenshot IDs; call visualIndex only for missing index entries. list discovers drafts; plan selects engine; generate creates source; download fetches assets; convert changes file format; unoApi/jsApi describe the planned engine. Never substitute IDs or infer behavior from reason. For text/code/config files use write(fileName, content): publishes exact UTF-8 content immediately, including empty files, without plan, Office engines or rendering. Markdown, TXT, HTML, JS, CSS, JSON, YAML, CSV and custom text extensions use the same write action. Saved code is not executed. Office design: original/high-design work starts with plan.design (bespoke audience, objective, distinct directions, selection and rhythm), then body for content/layout or program for complete-source control. Consistent visual rules do not mean identical page layouts. Edit is atomic: prefer exact replacements, uniquely matched on one pre-edit snapshot; any conflict saves nothing. Preserve indentation; never rely on fuzzy matching. After saved=true, inspect validation separately and use the returned patchBaseDigest. Only an identical request confirmed by a saved edit receipt is deduplicated. unoApi exact module IDs return only that module. Recovery: readSource/list return saved diagnostics, not a new execution. Check validationEvidence freshness. Do not infer bridge failure from NoneType or source correctness from a runtime blocker. Respect retryable/retryAfter; no unchanged retry loops.

Tool call template

Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {
      "action": "<action>"
    },
    "name": "file"
  }
}

Input Schema

NameRequiredDescriptionDefault
urlNoFor download: verified direct file URL, not a search result, preview webpage, artifactId or source-unit path.
bodyNoPreferred custom generate input. UNO: Python content operations using the provided deck (presentation), document (Word/flowing PDF), or workbook (Excel) variable. ExcelJS: JavaScript using provided workbook; await is allowed. HTML: a fragment, with section[data-slide] for PPTX. The SDK creates the document and adds entrypoint/save/close or HTML shell. Do not include those yourself. Follow plan.sourceGuidance. Choose exactly one of body or program. Repairs use edit on the complete source returned by readSource.
pathNoFor readSource/edit: exact source-unit path returned by readSource, not draft.py, an Office filename or filesystem path. For download: legacy alias of urlOrPath, accepting an HTTP(S) URL or page-relative URL path; local filesystem paths are unsupported.
limitNoreadContent: maximum text characters (default 8000, max 40000), NOT source lines. visualIndex: maximum index entries (default 100, max 200). readSource uses startLine/endLine instead.
pagesNoOnly for readContent(includeVisuals=true): one-based rendered/printed page numbers, at most six. A worksheet may span multiple pages. visualRead instead uses screenshotIds.
patchNoFor edit, use patch OR replacements. Codex patch: Begin Patch, Update File: draft.py, @@ hunks, End Patch. Literal -old/+new markers are separate from ALL source indentation. Every target must match uniquely and exactly in the current source. Any conflict rejects the WHOLE call; no partial saves or fuzzy matching. Prefer replacements for small fixes.
queryNoFor an API lookup: omit to list modules, then pass an exact module id returned by that index.
rangeNoreadContent: A1 cell/range, for example A1:D20; specify sheet for multi-sheet files.
sheetNoreadContent: exact spreadsheet worksheet name.
actionYesRequired. write + fileName + content publishes text/code files immediately. readSource + documentId = editable Office generation code; readContent + artifactId/attachmentId = file text/data; visualIndex/visualRead/visualReport = rendered-page QA. generate/edit validate Office source; render publishes it.
designNoFor initial plan: template for conventional fast files; bespoke for original art direction. Bespoke records audience/objective, 2–3 distinct directions (or one grounded user reference), selectedDirection, selectionReason and page rhythm. This is not a visual pass or permission to delete requested content.
intentNoFor plan: concise description of the document to create or modify.
offsetNoreadContent: zero-based character offset. visualIndex: zero-based screenshot-list offset. Never a source line number.
reasonNoUser-visible explanation only. Saying "read source" here does NOT select source reading; action and identity fields control behavior.
renderNoLegacy generate/edit flag; use a separate action=render to publish. generate/edit create or validate source, not a deliverable download.
contentNoFor write only: exact UTF-8 text to save as a downloadable file (Markdown, HTML, code, configuration, CSV, etc.). Preserves whitespace and empty strings. No Markdown fences unless part of the requested file. Does not execute code or render Office documents.
endLineNoFor readSource only: inclusive last code line, at least startLine. This is not a worksheet row or PDF page number.
programNoAdvanced generate input: complete HTML, or complete Python/JavaScript source with the engine entrypoint. UNO requires def create_document(job): and exactly one document save/close. Prefer body to omit this boilerplate. Choose exactly one of body or program. readSource returns the complete stored source; use edit for repairs.
reviewsNoFor visualReport: conclusions for pages actually seen via visualRead on this artifact. passed requires no failed checks and no issues; failed requires a failed check and concrete issues. Reporting does not modify source.
sectionNoreadContent: exact, unique Word document heading; reads through the next heading of the same or higher level.
fileNameNoFor write/plan/download/convert: output name with extension. Required for write; optional for plan, which derives it from the intent/title and documentType when omitted. A name is not an artifactId or documentId. The bundled convert outputs PDF only.
fileTypeNoFor download: expected extension without a dot.
operationNoFor plan: create a new document or modify an attached existing Office document.
startLineNoFor readSource only: one-based first code line; use the returned coordinateSpace when a source-unit path is selected. Maximum 80 lines per response.
urlOrPathNoFor download: real HTTP(S) file URL or page-relative URL path resolved against sourcePageUrl. Not an operating-system path. Local assets must be uploaded/host-bound attachments. Supply exactly one of urlOrPath/url/path.
artifactIdNoFor readContent/visualIndex/visualRead/visualReport: exact finished-file artifact id from render/download/convert. Reading an .xlsx artifact returns spreadsheet content, NOT Python source.
deckReviewNoComplete-document consistency review submitted after every page has been read and reviewed.
documentIdNoRequired for readSource/generate/edit/render; copy from plan/list. Optional for a new plan (generated automatically) and unoApi/jsApi (unbound documentation reads). Re-plan an existing document using its returned id. New ids use 1-96 ASCII letters/numbers/dot/underscore/hyphen.
attachmentIdNoFor readContent: exact uploaded attachment id. Not a draft id and not usable to read generation source.
contentPagesNoreadContent: PDF text pages or presentation slides in actual document order, one-based. Independent from visual-preview pages.
documentTypeNoRequired for plan. Optional for unoApi/jsApi: choose word/spreadsheet/presentation to read that API without a documentId; omit both to get the document-type index. Common Office extension aliases are normalized before validation.
replacementsNoPreferred for small/indentation repairs: unique exact oldText/newText pairs on the current source. All pairs commit together or NONE do; combine helper and caller changes in one call. No whitespace guessing. Missing oldText is a conflict, not proof of previous success. Use documentId; inspect saved and validation separately.
screenshotIdsNoFor visualRead: one to eight exact screenshot ids from render.visualIndex or action=visualIndex. Prefer render.visualIndex.nextRead without repeating the index call.
includeVisualsNoFor readContent only: false by default; true explicitly attaches rendered pages. Text reading is not visual QA. For page inspection, use visualRead with render.visualIndex; request visualIndex only if no current index is available.
sourceArtifactIdNoFor convert: exact artifact id of the existing Office file to export as PDF. Does not read or modify generation source.
includeDiagnosticsNoreadSource only, default false: include saved diagnostic details, NOT a new validation run. Check validationEvidence source/worker freshness before treating old errors as current blockers. Ordinary reads return counts, not full warnings.
sourceAttachmentIdNoFor operation=modify: exact attachment id of the existing Office file.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.3.10

TDQS

A4.2/5.0
Behavior5/5

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

With no annotations, the description carries the full burden and discloses critical behavior: write publishes exact UTF-8 immediately even for empty files, saved code is not executed, edit is atomic with all-or-nothing conflict handling, and deduplication only occurs for identical confirmed requests. It also warns that readSource/list return saved diagnostics rather than a new execution and advises respecting retryable/retryAfter.

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

Conciseness2/5

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

The description is a single dense paragraph mixing reading, writing, design planning, edit atomicity, deduplication, and recovery advice. It is front-loaded with the reading workflow, but the remainder is hard to scan and includes repeated operational warnings that obscure the main routing information.

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

Completeness4/5

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

For a 15-action, 37-parameter tool with nested objects and no output schema, the description covers the major workflows and several return-handling details such as render.visualIndex.nextRead, saved validation evidence, and patchBaseDigest. It still cannot fully document every action's behavior in one paragraph, so a 4 rather than 5 is appropriate.

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?

Schema coverage is 100%, so the baseline is 3, but the description adds useful cross-parameter meaning: action-specific use of body vs program, artifactId vs attachmentId vs documentId, contentPages vs offset/limit, and patch vs replacements. It stops short of a 5 because much of the parameter detail already lives in the exhaustive schema descriptions.

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

Purpose4/5

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

The description names specific resources (PDFs, Word documents, spreadsheets, presentations) and verbs (readContent, download, write, edit, render), so an agent can tell it is a file/document tool. It sharply distinguishes readContent from readSource and write, though the generic 'file' umbrella and lack of sibling differentiation keep it from a 5.

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?

It gives explicit routing rules: use readContent for file text/data, readSource for editable HTML/Python/JavaScript, write for text/code/config, visualRead for scanned pages, and download-then-readContent for remote URLs. It also sequences the repair workflow (readSource → edit → render → visualRead → visualReport) and explains when to skip plan/render for writing.

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