ASTra

v0.4.1
com.attentionform/astra-mcp-server Checked 5 hours ago Published 20 days ago

Lets AI agents edit Word (.docx) files.

These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.

open_document

Open a .docx file into a session (Map sessionId->DocHandle, LRU 10 docs / 200MB / 30min idle evict). Returns {ok:true,sessionId,revision,summary,evicted} where evicted:string[] lists sessions dropped by the capacity cap to make room (re-open them if needed; later calls with an evicted id fail with E_SESSION plus a close_document remedy). The default summary is compact: palette, counts, header/footer text, chart ids and pending-revision flag. Pass {"summaryOnly":false} for the full structural summary including styles XML. Example input {"path":"documents/report.docx"} -> {"ok":true,"sessionId":…

ParameterTypeDescription
path *string
allowMacrosboolean
authorstring
sessionIdDEPRECATED: session ids are server-minted (sess_<uuid>); omit sessionId and use the returned id. Client-supplied values are rejected with E_VALIDATION (deterministic ids are test-only via --allow-clie…
stripMacrosboolean
summaryOnlyboolean
validationTimeoutMsinteger

inspect_document

Inspect a session: standard TOON outline (fidelity compact|standard|full, default standard) plus style palette passthrough {availableStyles,brandColors,primaryFont} parsed from word/styles.xml, plus document core properties `metadata` {title,creator,subject,description,keywords,category,lastModifiedBy,revision,created,modified} read from docProps/core.xml (absent when the docx has no core part). Use include:["comments","revisions"] for review records paged by reviewOffset/reviewLimit (max 50; offset/limit page nodes only); commentId or revisionId reads full detail and needs its include. Render…

ParameterTypeDescription
sessionId *string
aroundNodestring
commentIdinteger
fidelitystring
includearray
limitinteger
maxTextLengthinteger
maxTokensinteger
offsetinteger
reviewLimitinteger
reviewOffsetinteger
revisionIdinteger
sectionIdstring
windowinteger

search_content

Search live paragraph/table w:t text; returns [{id,preview}] node hits for anchors/targets. Use scope:"comments" or scope:"all" to search comment text; the default scope is body. At most 50 matches come back; truncated:true says more exist. A table hit also lists `cells` (up to 5 addresses such as t_001:r3c1) for the cells that hold the match; pass one as the target of replace/style/namedStyle/clearFormat/hyperlink/bookmark/comment. Chart titles/series are NOT matched by search (they live in the chart part, not w:t); discover them in inspect TOON chart rows, then anchor by the chart node id. I…

ParameterTypeDescription
query *string
sessionId *string
regexboolean
scopestring

execute_batch

Apply 1..500 strictly-typed operations atomically (strict discriminatedUnion per action; sequential:true default preserves document order; Tracked edits return revisionIds; trackedChange accept/reject selects by ids, author or target and reports revisionResolution {resolved,unresolved,removedBookmarks,removedComments,staleLinks}. Comment operations include resolve, unresolve and delete and take an id as 3 or comment:3. single edit = 1-item batch). Caps 500 ops / 200MB throw E_QUOTA with remedy (maxSteps is an optional positive integer, unbounded when omitted). Client-supplied op ids are honore…

save_document

Validate then persist the session docx; the default policy permits pre-existing validation errors when no new normalized error signatures are detected. Save-blocked remedies are xpath-specific (drawing docPr/id, table tbl/tr/tc, relationships, header/footer parts, session tracking-attribute leaks each name their own fix). Optional commit params: message (commit subject, single-line, max 500 chars; newlines become spaces; blank/omitted falls back to `save_document: rev <n> (<k> ops since last save)`); author (max 100 chars; blank/omitted falls back to ASTra Agent). Over-long message/author fail…

ParameterTypeDescription
sessionId *string
allowMacrosboolean
authorstring
messagestring
outPathstring
strictboolean
stripMacrosboolean

close_document

Evict a session and release its lock/memory. Returns {ok:true,sessionId,dirty,discardedRevisions,warning?}: a dirty close warns (dirty:true + warning naming the discarded unsaved revision count) instead of silently discarding; save first when the warning matters. Example {"sessionId":"sess_abc"} -> {"ok":true,"dirty":false,"discardedRevisions":0}. Close when finished; expired sessions (30min idle) must be re-opened.

ParameterTypeDescription
sessionId *string

new_document

Create a new .docx from a template (report|memo|blank, default blank) at outPath inside an allowed folder (the folders named with --allowed-dir or ASTRA_EXTRA_DOC_ROOTS; only when none are named, ./documents and the system temp folder). Validates the fresh package before writing (E_VALIDATION when invalid, never writes corruption); refuses to overwrite without {force:true} (E_CONFLICT). Success returns {ok:true,path,sessionId,revision,template,bytes} with the file opened into a session (use sessionId for inspect/execute_batch/save). Example {"outPath":"documents/new-report.docx","template":"re…

ParameterTypeDescription
outPath *string
authorstring
forceboolean
sessionIdDEPRECATED: session ids are server-minted (sess_<uuid>); omit sessionId and use the returned id. Client-supplied values are rejected with E_VALIDATION (deterministic ids are test-only via --allow-clie…
styleGuidestring
templatestring

compose_document

Compose a Markdown string into the open session document (appends after existing content, or at anchor with position before|after; an unchanged built-in template created in this session has its sample content replaced). A document can be built in several compose calls: the first call of a session mints ids md_0001..., later calls mint md2_0001..., md3_0001..., so ids never collide; pass anchor (a node id, start or end) and position to add a section in the middle without another tool. Runs the engine compose path, then applies the resulting operations through the same execute_batch path (strict…

ParameterTypeDescription
markdown *string
sessionId *string
allowedDirstring
anchorstring
dollarMathboolean
positionstring
styleGuidestring
templatestring

export_document

Export the active document to HTML, Markdown, or PDF format with sandbox security gating. Renders the in-memory session state (includes unsaved execute_batch edits, not the last saved file); success returns {ok:true,format,path|content,bytes,dirty,revision,imageMode,assetPrefix,assets,assetCount} (dirty:true = unsaved edits present). For Markdown exports, images default to extracted files in a unique generation within a sibling <doc_basename>_assets/ directory when outPath is specified; in-memory exports default to embedded base64 data URIs. PDF renders via headless LibreOffice: a ~11s first-r…

ParameterTypeDescription
format *stringTarget export format: "html", "markdown", "md", or "pdf"
sessionId *stringActive document session ID returned by open_document
assetPrefixMarkdown only: relative directory prefix for extracted image assets (default: "<doc_basename>_assets")
imageModeMarkdown only: "file" requires outPath and writes image assets under a unique generation in sibling <doc_basename>_assets/; "embed" uses base64 data URIs. Default is "file" with outPath and "embed" ot…
outPathOptional output destination path (must reside inside allowed directory)
strictPDF only: fail closed on preflight blockers (default false, warn-only)
taggedAlias of tagged_pdf
tagged_pdfPDF only: tagged (accessible) render (default true)

visual_inspect

Inspect document visually with 2D spatial layout telemetry (ASCII wireframe, page breakdown, margins, defects) and optional headless rendered images (withVisual: true; add outputDir to write them to a folder inside the allowed directories, for example next to the document, instead of the server temp folder). Renders the in-memory session state (includes unsaved execute_batch edits, not the last saved file); success returns {ok:true,sessionId,revision,dirty,telemetry,...} (dirty:true = unsaved edits present).

ParameterTypeDescription
sessionId *string
dpiinteger
formatstring
jpegQualityinteger
outputDirstring
pagesarray
withVisualboolean

get_document_history

List the saved git history for a session (newest first, read-only: never mutates, never flips dirty). Paginate with limit (1-100, default 20) and offset (default 0). Returns {ok:true,sessionId,documentPath,currentCommit,totalCommits,history:[{oid,message,author,timestamp,timestampMs,opCount,affectedNodeIds,resultingHeadOid}]} (timestampMs = ms-precision epoch millis; commit-time clock for tracked commits, git seconds for older ones; opCount is always present (0 for pre-tracking commits and heals-only saves: it folds operations, not normalizer rewrites); affectedNodeIds is always present ([] wh…

ParameterTypeDescription
sessionId *string
limitinteger
offsetinteger

preview_revert

Read-only WOULD-restore preview for revert_document (never mutates: no revision bump, no disk write, no redo-stack change). Target one commit: {steps:N} walks back N saved commits from the head (1 = the previous saved commit, must be < totalCommits) OR {commitOid:"<40-hex>"} jumps to that commit (mutually exclusive). Returns {ok:true,sessionId,targetOid,targetMessage,targetAuthor,stepsBack,affectedFiles,changedValues,changedValuesTruncated,changedValuesPositional,dirty,dirtyHandling,currentHeadOid,totalCommits} where affectedFiles lists package paths that differ from the target (word/document.…

ParameterTypeDescription
sessionId *string
commitOidstring
stepsinteger

revert_document

Restore an earlier SAVED state as a new head commit (history is append-only; refs never move). Target one commit: {steps:N} walks back N saved commits from the head (1 = the previous saved commit, must be < totalCommits) OR {commitOid:"<40-hex>"} jumps to that commit (mutually exclusive). Bare reverts fail closed: unsaved execute_batch edits refuse with E_CONFLICT unless discardUnsaved:true, which discards them. The conflict remedy names net-zero edits (pending revisions count as dirty even when content matches) and carries dirtyReason with the pending count. Discarded unsaved edits are echoed…

ParameterTypeDescription
sessionId *string
authorstring
commitOidstring
discardUnsavedboolean
messagestring
reasonstring
stepsinteger

redo_document

Re-apply the state undone by the last revert_document (pops the per-session redo stack, restores it, commits as new head). Success carries advisory changedValues [{nodeId,before,after}] (pre-redo live text -> restored text, same bounds as save/preview). Empty stack fails with E_NOT_FOUND plus atLatestState:true (a fresh execute_batch edit clears redo, and each redo consumes one entry). Optional author (<=100 chars, default ASTra Agent) + reason (<=500 chars, preferred over message) with the same hygiene as save/revert. Example {"sessionId":"sess_abc"} -> {ok:true,revision,dirty:false}. A succe…

ParameterTypeDescription
sessionId *string
authorstring
messagestring
reasonstring

validate_document

Preflight read-only OOXML audit for a session: runs the same validator gate save_document enforces, before anything is written. Detects schema violations while they are still cheap to fix. Strictly read-only: zero session mutation (revision and dirty flag untouched), zero disk writes, zero history commits. Returns {ok:true,sessionId,revision,dirty,validation:{valid,errorCount,errors}} where errors carry description + xPath (first 10, same shape as the save-blocked envelope). The verdict is on the document as a save would write it (children put in schema order first); when that save would repai…

ParameterTypeDescription
sessionId *string

get_stats

Token-cheap document census for a session: words, paragraphs, tables, callouts, images, and an estimated editorial page budget (layout-weighted by words, tables, images, and explicit page breaks) in a single small envelope. Counters are the exact engine counters behind CLI stats, so both surfaces always agree. Physical pagination is finalized when exporting to PDF via LibreOffice. Read-only: never mutates, never bumps the revision. Returns {ok:true,sessionId,revision,dirty,words,paragraphs,tables,callouts,images,pages}. A callout (a "> [!NOTE]" alert or a callout op: a one-cell table with a fi…

ParameterTypeDescription
sessionId *string

sanitize_document

Scrub an open session document. By default it removes revision ids, authorship, embedded EXIF and hidden text PII. Tracked changes and comments are kept, with the text of every tracked deletion, unless you ask: acceptAllRevisions:true accepts all tracked changes (deleted text is removed) and stripComments:true removes comments. The CLI presets (bare sanitize, --client-safe, --metadata-only, --redact-pii) turn both on; this tool does not. Macro/active parts are removed on request. It uses the same engine scrub path as CLI sanitize. Body text is kept. Options mirror the engine scrub keys 1:1 (ze…

ParameterTypeDescription
sessionId *string
acceptAllRevisionsboolean
allowMacrosboolean
purgeAuthorsboolean
purgeExifboolean
purgePIIboolean
purgeRSIDsboolean
replacementAuthorstring
stripCommentsboolean
stripMacrosboolean
zeroRetentionboolean

normalize_document

Canonical repair for an open session document: runs the same allowlist normalizer CLI normalize calls (verified tag renames, whitelisted default infills, schema-sequence sorts) over the live package, then refreshes the session view and proves the result with a read-only validation verdict. Output bytes match CLI normalize on the same input. When the package is still invalid afterwards, the session is restored untouched and the call fails with E_VALIDATION plus a fix-and-retry remedy (same contract as CLI normalize writing nothing on failure). After the normalizer it repairs known validator err…

ParameterTypeDescription
sessionId *string

import_document

Ingest an on-disk Markdown file into the OPEN session (the file-ingress half compose_document lacks: compose takes an inline string only). Reads the file under the workspace jail, then runs the identical compose pipeline (strict compile gate, quotas, template-seed check, inline-span splitting), so the result is byte-equal to composing the same Markdown inline. sessionId is strictly required: the tool never auto-creates sessions (fresh templated document: new_document first, then import; existing file: open_document first, then import). Accepts .md/.markdown/.txt; .html/.htm refuse with E_VALID…

ParameterTypeDescription
path *string
sessionId *string
allowedDirstring
dollarMathboolean
styleGuidestring
templatestring