Skip to main content
Glama

createComment

Add comments to resources like tasks, milestones, or files in Teamwork projects. Specify content, privacy, notifications, and attachments to streamline communication within projects.

Instructions

Creates a new comment for a specific resource (tasks, milestones, notebooks, links, fileversions) in Teamwork

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
authorIdNoID of the user to post as (only for admins)
bodyYesThe content of the comment
contentTypeNoContent type of the comment (html or plain text)plaintext
isPrivateNoWhether the comment should be private
notifyNoWho to notify ('all' to notify all project users, 'true' to notify followers, specific user IDs, or empty for no notification)
pendingFileAttachmentsNoComma-separated list of pending file references to attach to the comment
resourceYesThe resource type (tasks, milestones, notebooks, links, fileversions)
resourceIdYesThe ID of the resource to add a comment to

Implementation Reference

  • The handler function that implements the core logic of the 'createComment' tool. It processes the input, prepares the comment data, calls the teamwork service, and returns the result or error.
    export async function handleCreateComment(input: any) { logger.info('Calling teamworkService.createComment()'); logger.info(`Resource: ${input?.resource}, Resource ID: ${input?.resourceId}`); try { const resource = input.resource; const resourceId = input.resourceId; const commentData: any = {}; // Set required fields commentData.body = input.body; // Set optional fields if provided if (input.notify !== undefined) commentData.notify = input.notify; if (input.isPrivate !== undefined) commentData['isprivate'] = input.isPrivate; if (input.pendingFileAttachments) commentData.pendingFileAttachments = input.pendingFileAttachments; if (input.contentType === 'html') commentData['content-type'] = 'html'; if (input.authorId) commentData['author-id'] = input.authorId; const result = await teamworkService.createComment(resource, resourceId, commentData); return { content: [{ type: "text", text: JSON.stringify(result, null, 2) }] }; } catch (error: any) { logger.error(`Error in createComment handler: ${error.message}`); return { content: [{ type: "text", text: `Error creating comment: ${error.message}` }] }; } }
  • The tool schema definition for 'createComment', including input schema, description, and annotations.
    export const createCommentDefinition = { name: "createComment", description: "Creates a new comment for a specific resource (tasks, milestones, notebooks, links, fileversions) in Teamwork", inputSchema: { type: "object", properties: { resource: { type: "string", description: "The resource type (tasks, milestones, notebooks, links, fileversions)", enum: ["tasks", "milestones", "notebooks", "links", "fileversions"] }, resourceId: { type: "string", description: "The ID of the resource to add a comment to" }, body: { type: "string", description: "The content of the comment" }, notify: { type: "string", description: "Who to notify ('all' to notify all project users, 'true' to notify followers, specific user IDs, or empty for no notification)", default: "" }, isPrivate: { type: "boolean", description: "Whether the comment should be private", default: false }, pendingFileAttachments: { type: "string", description: "Comma-separated list of pending file references to attach to the comment" }, contentType: { type: "string", description: "Content type of the comment (html or plain text)", enum: ["html", "plaintext"], default: "plaintext" }, authorId: { type: "string", description: "ID of the user to post as (only for admins)" } }, required: ["resource", "resourceId", "body"] }, annotations: { title: "Create Comment", readOnlyHint: false, destructiveHint: false, openWorldHint: false } };
  • Registration of the createComment tool in the central toolPairs array used for tool definitions and handlers mapping.
    { definition: createComment, handler: handleCreateComment },
  • Helper service function that performs the actual API call to create a comment in Teamwork, called by the tool handler.
    export const createComment = async (resource: string, resourceId: string, commentData: any) => { try { // Validate resource type const validResources = ['tasks', 'milestones', 'notebooks', 'links', 'fileversions']; if (!validResources.includes(resource)) { throw new Error(`Invalid resource type. Must be one of: ${validResources.join(', ')}`); } // For API v1, we need the proper client const api = getApiClientForVersion('v1'); // We're using the v1 API which has a different format for the request const payload = { comment: commentData }; // The API v1 endpoint doesn't include the base path const response = await api.post(`/${resource}/${resourceId}/comments.json`, payload); return response.data; } catch (error: any) { logger.error(`Error creating comment for ${resource}/${resourceId}: ${error.message}`); throw new Error(`Failed to create comment for ${resource}/${resourceId}: ${error.message}`); } };
  • Import of the createComment tool definition and handler in the tools index file.
    import { createCommentDefinition as createComment, handleCreateComment } from './comments/createComment.js';

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/Vizioz/Teamwork-MCP'

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