Skip to main content
Glama
jakedx6
by jakedx6

bulk_document_operations

Process multiple documents simultaneously to update metadata, add tags, change visibility, archive, or analyze content in bulk.

Instructions

Perform bulk operations on multiple documents

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
document_idsYesArray of document IDs
operationYesOperation to perform
operation_dataNoData for the operation

Implementation Reference

  • Main handler function that executes bulk operations (update_metadata, add_tags, change_visibility, archive, analyze) on multiple documents using a loop and switch statement.
    export const bulkDocumentOperations = requireAuth(async (args: any) => { const { document_ids, operation, operation_data } = BulkDocumentOperationsSchema.parse(args) logger.info('Performing bulk document operations', { document_count: document_ids.length, operation }) const results = [] const now = new Date().toISOString() for (const document_id of document_ids) { try { let result switch (operation) { case 'update_metadata': // metadata field doesn't exist in the database schema result = await supabaseService.updateDocument(document_id, { updated_at: now }) break case 'add_tags': const doc = await supabaseService.getDocument(document_id) const existingTags = [] // metadata doesn't exist in the database schema const newTags = operation_data?.tags || [] // metadata field doesn't exist in the database schema result = await supabaseService.updateDocument(document_id, { updated_at: now }) break case 'change_visibility': // visibility field doesn't exist in the database schema result = await supabaseService.updateDocument(document_id, { updated_at: now }) break case 'archive': // status and metadata fields don't exist in the database schema result = await supabaseService.updateDocument(document_id, { updated_at: now }) break case 'analyze': result = await analyzeDocumentContent({ document_id, analysis_types: operation_data?.analysis_types || ['readability', 'completeness'], include_suggestions: true }) break default: throw new Error(`Unknown operation: ${operation}`) } results.push({ document_id, success: true, result }) } catch (error) { logger.error(`Failed operation ${operation} on document ${document_id}:`, error) results.push({ document_id, success: false, error: error instanceof Error ? error.message : 'Unknown error' }) } } return { operation, summary: { total_documents: document_ids.length, successful_operations: results.filter(r => r.success).length, failed_operations: results.filter(r => !r.success).length }, results } })
  • Zod schema for validating input parameters: document_ids (array of strings), operation (enum), operation_data (optional object).
    const BulkDocumentOperationsSchema = z.object({ document_ids: z.array(z.string().min(1)).min(1), operation: z.enum(['update_metadata', 'add_tags', 'change_visibility', 'archive', 'analyze']), operation_data: z.record(z.any()).optional() })
  • MCPTool registration object defining name, description, and inputSchema for the bulk_document_operations tool.
    export const bulkDocumentOperationsTool: MCPTool = { name: 'bulk_document_operations', description: 'Perform bulk operations on multiple documents', inputSchema: { type: 'object', properties: { document_ids: { type: 'array', items: { type: 'string' }, description: 'Array of document IDs' }, operation: { type: 'string', enum: ['update_metadata', 'add_tags', 'change_visibility', 'archive', 'analyze'], description: 'Operation to perform' }, operation_data: { type: 'object', description: 'Data for the operation' } }, required: ['document_ids', 'operation'] } }
  • Registration of the bulkDocumentOperations handler in the documentHandlers object, mapping tool names to their handler functions.
    export const documentHandlers = { list_documents: listDocuments, create_document: createDocument, get_document: getDocument, update_document: updateDocument, search_documents: searchDocuments, get_document_context: getDocumentContext, add_document_collaborator: addDocumentCollaborator, analyze_document_content: analyzeDocumentContent, get_document_collaboration: getDocumentCollaboration, generate_document_template: generateDocumentTemplate, bulk_document_operations: bulkDocumentOperations }
  • Export of all document tools including bulkDocumentOperationsTool for use elsewhere.
    export const documentTools = { listDocumentsTool, createDocumentTool, getDocumentTool, updateDocumentTool, searchDocumentsTool, getDocumentContextTool, addDocumentCollaboratorTool, analyzeDocumentContentTool, getDocumentCollaborationTool, generateDocumentTemplateTool, bulkDocumentOperationsTool }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/jakedx6/helios9-MCP-Server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server