mcp-google-drive
Version:
Advanced MCP server for Google Drive integration with full CRUD operations, file management, and sharing capabilities. Supports both OAuth2 and Service Account authentication.
34 lines • 1.05 kB
JavaScript
import { z } from "zod";
import { BaseToolHandler } from "./BaseToolHandler.js";
const GetFileContentSchema = z.object({
fileId: z.string(),
mimeType: z.string().optional(),
encoding: z.string().optional(),
});
export class GetFileContentHandler extends BaseToolHandler {
async runTool(args, drive) {
const validArgs = GetFileContentSchema.parse(args);
const content = await this.getFileContent(validArgs, drive);
return {
content: [{
type: "text",
text: content,
}],
isError: false,
};
}
async getFileContent(args, drive) {
try {
const response = await drive.files.get({
fileId: args.fileId,
alt: 'media',
supportsAllDrives: true,
});
return response.data.toString();
}
catch (error) {
throw this.handleGoogleApiError(error);
}
}
}
//# sourceMappingURL=GetFileContentHandler.js.map