Spaces:
Sleeping
Sleeping
File size: 1,352 Bytes
7dc28be | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 | import type { FastMCP } from 'fastmcp';
import { UserError } from 'fastmcp';
import { z } from 'zod';
import { google } from 'googleapis';
import { getAuthClient } from '../../../clients.js';
export function register(server: FastMCP) {
server.addTool({
name: 'deleteSheetsComment',
description: 'Permanently deletes a comment and all its replies from a Google Spreadsheet.',
parameters: z.strictObject({
spreadsheetId: z
.string()
.describe(
'The spreadsheet ID — the long string between /d/ and /edit in a Google Sheets URL.'
),
commentId: z.string().describe('The ID of the comment to delete.'),
}),
execute: async (args, { log }) => {
log.info(`Deleting comment ${args.commentId} from spreadsheet ${args.spreadsheetId}`);
try {
const authClient = await getAuthClient();
const drive = google.drive({ version: 'v3', auth: authClient });
await drive.comments.delete({
fileId: args.spreadsheetId,
commentId: args.commentId,
});
return `Comment ${args.commentId} has been deleted.`;
} catch (error: any) {
log.error(`Error deleting sheets comment: ${error.message || error}`);
throw new UserError(`Failed to delete comment: ${error.message || 'Unknown error'}`);
}
},
});
}
|