batch_update_documents
Update multiple Outline wiki documents simultaneously to modify titles, content, or append text in bulk operations.
Instructions
Update multiple documents at once.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| updates | Yes |
Implementation Reference
- src/lib/handlers/batch.ts:56-81 (handler)The primary handler function for the 'batch_update_documents' tool. It processes a list of document updates, handles optional text appending by fetching existing content, constructs the API payload, calls the Outline API's documents.update endpoint for each, and returns batch results with success/failure status.async batch_update_documents(args: BatchUpdateDocumentsInput) { checkAccess(config, 'batch_update_documents'); return runBatch(args.updates, async (update) => { try { let text = update.text; if (update.append && update.text) { const { data: existing } = await apiCall(() => apiClient.post<OutlineDocument>('/documents.info', { id: update.documentId }) ); text = (existing.text || '') + '\n\n' + update.text; } const payload: Record<string, unknown> = { id: update.documentId }; if (update.title) payload.title = update.title; if (text !== undefined) payload.text = text; const { data } = await apiCall(() => apiClient.post<OutlineDocument>('/documents.update', payload) ); return { success: true, id: data.id, title: data.title }; } catch (error) { return { success: false, documentId: update.documentId, error: getErrorMessage(error) }; } }); },
- src/lib/schemas.ts:122-129 (schema)Zod schema definition for the batch_update_documents tool input, validating an array of updates each containing documentId, optional title/text, and append flag.export const batchUpdateDocumentsSchema = z.object({ updates: z.array(z.object({ documentId, title: z.string().min(1).optional(), text: z.string().optional(), append: z.boolean().default(false), })).min(1, 'At least one update is required'), });
- src/lib/tools.ts:178-182 (registration)Registration of the 'batch_update_documents' tool in the allTools array, creating its JSON schema definition from the Zod schema for MCP protocol.createTool( 'batch_update_documents', 'Update multiple documents at once.', 'batch_update_documents' ),
- src/lib/handlers/batch.ts:21-31 (helper)Generic helper function runBatch used by batch_update_documents (and other batch handlers) to execute operations on an array of items and aggregate results into a BatchSummary.async function runBatch<TItem>( items: TItem[], operation: (item: TItem) => Promise<BatchResult> ): Promise<BatchSummary> { const results: BatchResult[] = []; for (const item of items) { results.push(await operation(item)); } const succeeded = results.filter((r) => r.success).length; return { total: results.length, succeeded, failed: results.length - succeeded, results }; }
- src/lib/schemas.ts:239-239 (schema)Mapping of the batch_update_documents tool name to its Zod schema in the central toolSchemas record.batch_update_documents: batchUpdateDocumentsSchema,