all2md.mcp.document_tools

Document manipulation tool implementation for MCP server.

This module implements the edit_document tool that applies a batch of edits to a document at the AST level and writes the result back to disk in place.

Functions

  • edit_document_impl: Implementation of edit_document tool

all2md.mcp.document_tools.edit_document_impl(input_data: EditDocumentInput, config: MCPConfig) EditDocumentOutput

Implement the edit_document tool (batch, atomic, in-place).

Applies the batch of edits to a single parse of the document. The batch is atomic: if any edit fails, none are persisted. When the batch contains a mutating action, the modified document is written back to disk in its original format (the file must be within the write allowlist). Mutating results echo only the edited region, not the whole document.

Parameters:
  • input_data (EditDocumentInput) – Tool input (document path and ordered edits).

  • config (MCPConfig) – Server configuration (allowlists, flavor).

Returns:

Per-edit results, write confirmation, and any warnings.

Return type:

EditDocumentOutput