batch_create_documents
Create multiple documents simultaneously in Outline wiki to save time when adding content to collections or organizing information.
Instructions
Create multiple documents at once.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| documents | Yes |
Implementation Reference
- src/lib/handlers/batch.ts:35-54 (handler)The core handler function for batch_create_documents. It checks access, then uses runBatch to create multiple documents via the Outline API's /documents.create endpoint, handling errors for each.async batch_create_documents(args: BatchCreateDocumentsInput) { checkAccess(config, 'batch_create_documents'); return runBatch(args.documents, async (doc) => { try { const { data } = await apiCall(() => apiClient.post<OutlineDocument>('/documents.create', { title: doc.title, text: doc.text, collectionId: doc.collectionId, parentDocumentId: doc.parentDocumentId, publish: doc.publish, }) ); return { success: true, id: data.id, title: data.title }; } catch (error) { return { success: false, title: doc.title, error: getErrorMessage(error) }; } }); },
- src/lib/schemas.ts:112-120 (schema)Zod input schema for batch_create_documents defining an array of document objects to create.export const batchCreateDocumentsSchema = z.object({ documents: z.array(z.object({ title: z.string().min(1), text: z.string().default(''), collectionId, parentDocumentId: z.string().uuid().optional(), publish: z.boolean().default(true), })).min(1, 'At least one document is required'), });
- src/lib/tools.ts:173-177 (registration)Tool registration in the allTools array, creating the MCP tool definition from the schema with name and description.createTool( 'batch_create_documents', 'Create multiple documents at once.', 'batch_create_documents' ),
- src/lib/schemas.ts:195-195 (schema)TypeScript type definition inferred from the batchCreateDocumentsSchema for type safety.export type BatchCreateDocumentsInput = z.infer<typeof batchCreateDocumentsSchema>;
- src/lib/handlers/batch.ts:21-31 (helper)Helper function used by batch_create_documents (and other batch ops) to execute operations in sequence and summarize results.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 }; }