/
PETPO
/
google-docs-mcp
Обзор
Документация
Войти
/
PETPO
/
google-docs-mcp
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
src/tools/docs/comments/replyToComment.ts
40 строк
1 KB
David Thor
Fixed formatting
12 фев 2026, 17:10
12 фев 2026, 17:10
18f1fed
Код
Авторство
О чём код?
import type { FastMCP } from 'fastmcp'; import { UserError } from 'fastmcp'; import { z } from 'zod'; import { google } from 'googleapis'; import { getAuthClient } from '../../../clients.js'; import { DocumentIdParameter } from '../../../types.js'; export function register(server: FastMCP) { server.addTool({ name: 'replyToComment', description: 'Adds a reply to an existing comment thread. Use listComments or getComment to find the comment ID.', parameters: DocumentIdParameter.extend({ commentId: z.string().describe('The ID of the comment to reply to'), content: z.string().min(1).describe('The text content of the reply.'), }), execute: async (args, { log }) => { log.info(`Adding reply to comment ${args.commentId} in doc ${args.documentId}`); try { const authClient = await getAuthClient(); const drive = google.drive({ version: 'v3', auth: authClient }); const response = await drive.replies.create({ fileId: args.documentId, commentId: args.commentId, fields: 'id,content,author,createdTime', requestBody: { content: args.content, }, }); return `Reply added successfully. Reply ID: ${response.data.id}`; } catch (error: any) { log.error(`Error adding reply: ${error.message || error}`); throw new UserError(`Failed to add reply: ${error.message || 'Unknown error'}`); } }, }); }