mcp-gdrive-enhanced-markov
Version:
MCP server for Google Drive and Sheets with write capabilities, AI-powered PDF analysis, SQLite document indexing, and advanced directory exploration tools
59 lines (58 loc) • 2.06 kB
JavaScript
import { z } from 'zod';
import { dbV2 } from './database_v2.js';
export const name = 'gdrive_create_index';
export const description = 'Create or reset the SQLite index database for Google Drive documents';
export const inputSchema = z.object({
reset: z.boolean().optional().default(false).describe('If true, completely reset the database (delete all data)')
});
export const schema = {
name,
description,
inputSchema: {
type: 'object',
properties: {
reset: {
type: 'boolean',
description: 'If true, completely reset the database (delete all data)',
default: false
}
},
required: []
}
};
export async function gdrive_create_index(args) {
try {
if (args.reset) {
console.log('Resetting database...');
await dbV2.resetDatabase();
return {
content: [{
type: 'text',
text: 'Database reset successfully. All data has been cleared and schema recreated.'
}],
isError: false
};
}
else {
// Just ensure the database exists with proper schema
// This happens automatically when accessing dbV2
const stats = await dbV2.getStats();
return {
content: [{
type: 'text',
text: `Index database is ready.\nCurrent stats:\n- Total documents: ${stats.total_documents}\n- Documents by type: ${JSON.stringify(stats.by_type, null, 2)}\n- Documents indexed in last 7 days: ${stats.documents_last_7_days}`
}],
isError: false
};
}
}
catch (error) {
return {
content: [{
type: 'text',
text: `Error creating/resetting index: ${error instanceof Error ? error.message : 'Unknown error'}`
}],
isError: true
};
}
}