Skip to main content
Glama

Document QA MCP Server

by parikshith49
googleDriveService.ts1.17 kB
import { google } from 'googleapis'; import fs from 'fs'; import path from 'path'; const auth = new google.auth.GoogleAuth({ keyFile: process.env.SERVICE_ACCOUNT_PATH, scopes: ['https://www.googleapis.com/auth/drive.readonly'], }); const drive = google.drive({ version: 'v3', auth }); export async function listDriveFiles(folderId: string): Promise<{ id: string; name: string }[]> { const res = await drive.files.list({ q: `'${folderId}' in parents and mimeType='text/plain' and trashed=false`, fields: 'files(id, name)', }); const files = res.data.files ?? []; return files .filter((file): file is { id: string; name: string } => !!file.id && !!file.name) .map(file => ({ id: file.id, name: file.name })); } export async function downloadDriveFile(fileId: string, fileName: string): Promise<string> { const destPath = path.join('downloads', fileName); const dest = fs.createWriteStream(destPath); const response = await drive.files.get( { fileId, alt: 'media' }, { responseType: 'stream' } ); response.data.pipe(dest); await new Promise<void>((resolve) => dest.on('finish', () => resolve())); return destPath; }

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/parikshith49/document-qa-mcp12'

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