lokalise_get_comment
Retrieve the complete text and metadata of a comment when the list view shows truncated content. Returns author details and exact timestamps for accurate comment management.
Instructions
Gets full details of a single comment including complete text and metadata. Required: projectId, keyId, commentId. Use when comment text was truncated in list view or to get exact timestamps. Returns: Complete comment data with author details and creation time. Pairs with: lokalise_delete_comment for comment management.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| projectId | Yes | Project ID containing the comment | |
| keyId | Yes | Key ID containing the comment | |
| commentId | Yes | Comment ID to get details for |
Implementation Reference
- src/domains/comments/comments.tool.ts:240-245 (registration)Registration of the 'lokalise_get_comment' MCP tool, binding the tool name to its Zod schema (GetCommentToolArgs.shape) and handler function (handleGetComment).
server.tool( "lokalise_get_comment", "Gets full details of a single comment including complete text and metadata. Required: projectId, keyId, commentId. Use when comment text was truncated in list view or to get exact timestamps. Returns: Complete comment data with author details and creation time. Pairs with: lokalise_delete_comment for comment management.", GetCommentToolArgs.shape, handleGetComment, ); - Handler function for the lokalise_get_comment tool. Calls commentsController.getComment() and formats the result as MCP text content.
async function handleGetComment(args: GetCommentToolArgsType) { const methodLogger = Logger.forContext( "comments.tool.ts", "handleGetComment", ); methodLogger.debug("Getting comment details...", args); try { const result = await commentsController.getComment(args); methodLogger.debug("Got the response from the controller", result); return { content: [ { type: "text" as const, text: result.content, }, ], }; } catch (error) { methodLogger.error("Tool failed", { error: (error as Error).message, args, }); return formatErrorForMcpTool(error); } } - Zod schema for the lokalise_get_comment tool arguments: projectId (string), keyId (number), and commentId (number).
export const GetCommentToolArgs = z .object({ projectId: z.string().describe("Project ID containing the comment"), keyId: z.number().describe("Key ID containing the comment"), commentId: z.number().describe("Comment ID to get details for"), }) .strict(); export type GetCommentToolArgsType = z.infer<typeof GetCommentToolArgs>; - Controller for getComment. Validates inputs (projectId, keyId, commentId), calls commentsService.getComment(), and formats the result via formatCommentDetails().
async function getComment( args: GetCommentToolArgsType, ): Promise<ControllerResponse> { const methodLogger = Logger.forContext( "comments.controller.ts", "getComment", ); methodLogger.debug("Getting comment details...", args); try { // Validate inputs if (!args.projectId || typeof args.projectId !== "string") { throw new McpError( "Project ID is required and must be a string.", ErrorType.API_ERROR, ); } if (!args.keyId || typeof args.keyId !== "number") { throw new McpError( "Key ID is required and must be a number.", ErrorType.API_ERROR, ); } if (!args.commentId || typeof args.commentId !== "number") { throw new McpError( "Comment ID is required and must be a number.", ErrorType.API_ERROR, ); } // Call service layer const result = await commentsService.getComment(args); // Format response const formattedContent = formatCommentDetails(result); methodLogger.debug("Comment details fetched successfully", { projectId: args.projectId, keyId: args.keyId, commentId: args.commentId, }); return { content: formattedContent, }; } catch (error: unknown) { throw handleControllerError(error, { source: "CommentsController.getComment", entityType: "Comment", entityId: { project: args.projectId, key: String(args.keyId), comment: String(args.commentId), }, operation: "retrieving", }); } } /** * @function createComments * @description Creates one or more comments on a key. * @memberof CommentsController - Service layer - calls Lokalise API's comments().get() with commentId, project_id, and key_id to retrieve a single comment.
async getComment(args: GetCommentToolArgsType): Promise<Comment> { const methodLogger = logger.forMethod("getComment"); methodLogger.info("Getting comment", { projectId: args.projectId, keyId: args.keyId, commentId: args.commentId, }); try { const api = getLokaliseApi(); const result = await api.comments().get(args.commentId, { project_id: args.projectId, key_id: args.keyId, }); methodLogger.info("Retrieved comment successfully", { projectId: args.projectId, keyId: args.keyId, commentId: args.commentId, }); return result; } catch (error) { methodLogger.error("Failed to get comment", { error, args }); throw createUnexpectedError( `Failed to get comment ${args.commentId} from key ${args.keyId} in project ${args.projectId}`, error, ); } },