Skip to main content
Glama

typst_find_and_replace

Find and replace text or regex in one Typst file or project-wide, using batch rules, dry-run previews and per-file saves.

Instructions

Find and replace text or regex in one file or project-wide. Use replacements to batch mappings (e.g. Sep → September, Oct → October) in one call with one save per file. Rules run sequentially; later rules see earlier results. Batch output defaults to compact summary; request output='diff' or 'full' for previews. Supports dryRun and per-file mutation serialization. Project-wide changes are not atomic across files.

Input Schema

NameRequiredDescriptionDefault
globNoOptional glob pattern to filter target files when searching project-wide (e.g. '*.typ')
limitNoMaximum number of replacements per file (default: replace all occurrences)
regexNoWhether pattern is a regular expression (default: false)
dryRunNoIf true, returns unified diffs and match counts without saving changes (default: false)
outputNosummary: counts and first changed line; diff: also display diff; full: also unified patch. Defaults to summary for batches, full for legacy pattern/replacement calls. Applies to dry runs too.
patternNoSearch pattern to replace (literal substring or regex)
filePathNoOptional file path/name (e.g. 'main.typ'). If omitted, searches and replaces across all text files in the project.
projectIdYesThe Typst project ID
ignoreCaseNoCase-insensitive search (default: false)
replacementNoReplacement text (supports $1, $2 capture groups if regex is true)
replacementsNoOrdered replacement rules instead of pattern/replacement. Each rule runs on the previous result. Set regex, ignoreCase, and limit per rule. All rules are validated before any writes; each changed file is saved once.
preferWebSocketNoPush real-time TextUpdate over /editing/v3 WebSocket before REST persistence (default: true)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.3.1

TDQS

A3.9/5.0
Behavior4/5

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

With no annotations, the description carries real weight and delivers: sequential rule ordering where later rules see earlier results, one save per changed file, per-file mutation serialization, and the important caveat that project-wide changes are not atomic across files. Missing are reversibility/undo guarantees and any permission or locking requirements, so it is strong but not exhaustive.

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?

Six compact sentences, front-loaded with the core action and scope, then escalating to batch semantics, output modes, and the atomicity caveat. Slightly dense but no sentence is filler; it could be tightened marginally.

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 12-parameter mutating tool with a oneOf schema and no output schema, the description covers the highest-risk behaviors: save granularity, rule sequencing, dry-run preview, and non-atomicity across files. Given the schema fully documents parameters, the remaining gap is only around return-value shape and rollback, which is minor.

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

Parameters3/5

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

Schema description coverage is 100%, so all 12 parameters are already documented. The description adds only marginal meaning, mostly restating ordering semantics that the schema's 'replacements' description already states and the output default behavior that the 'output' field already explains. Baseline 3 is appropriate.

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?

Opens with a specific verb+resource ('Find and replace text or regex') and states the two scopes (single file vs project-wide). It is clearly distinguishable from typst_edit_file and typst_grep_project in substance, but never names or contrasts those siblings explicitly, which keeps it short of 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 Guidelines4/5

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

Gives concrete usage context: use the 'replacements' array to batch mappings in one call with one save per file, and preview with dryRun or output='diff'. It does not state when to prefer typst_edit_file for arbitrary rewrites or typst_grep_project for search-only, so no explicit exclusions or alternatives are provided.

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