Skip to main content
Glama

Format Document

format-document
Destructive

Stages Roslyn formatting for a single document in the active transaction, optionally limited to a range, so changes can be reviewed before commit. Does not write files directly.

Instructions

Stages Roslyn formatting for one document in the active transaction, using its workspace formatting options. Use this for formatting; use rename-symbol or code actions for semantic transformations. Requires document and the current expectedSnapshot. Omit range to format the whole document, or provide a zero-based start and length within the document to select the region passed to the formatter. Already formatted text produces no change. Successful staging returns mutation details and a new snapshot for subsequent requests. Inspect transaction-preview, or transaction-review in approval-required mode, before transaction-commit; transaction-rollback discards the staged work. This tool does not write source files directly or create a Git commit.

Input Schema

NameRequiredDescriptionDefault
rangeNoThe optional range to format.
documentYesTarget document.
workspaceNoProvide workspaceId, alias, path, or any combination.
expectedSnapshotYesEcho the snapshot returned with the data or transaction state used to construct this request.

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Addedv1.0.6

TDQS

A4.8/5.0
Behavior5/5

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

Goes well beyond the annotations: it discloses that work is staged rather than written ("does not write source files directly or create a Git commit"), which reconciles the destructiveHint=true / readOnlyHint=false profile with a agent's expectations. It also states the no-op case ("Already formatted text produces no change") and that a successful call returns mutation details plus a new snapshot.

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?

Front-loaded with the purpose, and every sentence carries information (scope, alternatives, preconditions, range semantics, return contract, workflow, negative scope). Slightly long, and the return-value sentence partly duplicates the output schema, which keeps it out of the top band.

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?

For a mutating, transaction-scoped, nested-object tool with an output schema, the description covers preconditions, idempotent no-op behavior, transactional lifecycle, and what it explicitly does not do. Nothing an agent needs in order to call it safely is missing.

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 baseline would be 3; the description adds real meaning by explaining that omitting range formats the entire document and that a supplied range is a zero-based start/length selecting the region passed to the formatter. It also names document and expectedSnapshot as required, though it does not add much on the snapshot echo semantics beyond the schema text.

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?

Names a specific verb and resource ("Stages Roslyn formatting for one document") plus the scoping constraint ("in the active transaction") and the option source (workspace formatting options). It explicitly separates itself from rename-symbol and code actions, so an agent can route without opening a schema.

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 says when to use this tool ("Use this for formatting") and what to use instead for other needs ("rename-symbol or code actions for semantic transformations"). It also states the required preconditions (document, expectedSnapshot, active transaction) and the surrounding workflow: preview or review before commit, rollback discards.

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