Skip to main content
Glama
zqushair
by zqushair
addComment.ts2.33 kB
import { BaseRequestHandler } from '../base.js'; import { AddCommentArguments, ToolResponse } from '../../../models/mcp.js'; import { frontappClient } from '../../../clients/frontapp/index.js'; /** * Handler for the add_comment tool * Adds a comment to a conversation in Frontapp */ export class AddCommentHandler extends BaseRequestHandler<AddCommentArguments> { /** * Validate the arguments passed to the tool * @param args The arguments to validate * @throws Error if the arguments are invalid */ protected validateArgs(args: AddCommentArguments): void { // Validate conversation_id if (!args.conversation_id) { throw new Error('conversation_id is required'); } if (typeof args.conversation_id !== 'string') { throw new Error('conversation_id must be a string'); } // Validate body if (!args.body) { throw new Error('body is required'); } if (typeof args.body !== 'string') { throw new Error('body must be a string'); } // Validate author_id if (!args.author_id) { throw new Error('author_id is required'); } if (typeof args.author_id !== 'string') { throw new Error('author_id must be a string'); } } /** * Execute the request to add a comment * @param args The validated arguments * @returns A response containing the result of adding the comment */ protected async execute(args: AddCommentArguments): Promise<ToolResponse> { try { // Call the Frontapp API to add a comment const response = await frontappClient.addComment(args.conversation_id, { author_id: args.author_id, body: args.body, }); // Create a success response return this.createSuccessResponse({ message: `Comment added to conversation ${args.conversation_id} successfully`, comment: { id: response.data.id, body: response.data.body, author: response.data.author, created_at: new Date(response.data.created_at * 1000).toISOString(), }, }); } catch (error: any) { // Create an error response return this.createErrorResponse(`Failed to add comment: ${error.message}`); } } } // Export a singleton instance of the handler export const addCommentHandler = new AddCommentHandler();

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/zqushair/Frontapp-MCP'

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