Skip to main content
Glama

motion_comments

Add or view comments on Motion tasks to track updates and collaborate within the task management platform.

Instructions

Manage comments on tasks

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
operationYesOperation to perform
taskIdYesTask ID to comment on or fetch comments from (required)
contentNoComment content (required for create operation)
cursorNoPagination cursor for list operation (optional)

Implementation Reference

  • Main handler for motion_comments tool. Implements two operations: 'list' (retrieves comments with pagination) and 'create' (creates new comments with content sanitization and validation). Extends BaseHandler and uses MotionService for API calls.
    import { BaseHandler } from './base/BaseHandler';
    import { McpToolResponse } from '../types/mcp';
    import { MotionCommentsArgs } from '../types/mcp-tool-args';
    import { CreateCommentData } from '../types/motion';
    import { formatCommentList, formatCommentDetail, LIMITS } from '../utils';
    import { sanitizeCommentContent } from '../utils/sanitize';
    
    export class CommentHandler extends BaseHandler {
      async handle(args: MotionCommentsArgs): Promise<McpToolResponse> {
        try {
          const { operation, taskId, content, cursor } = args;
    
          switch(operation) {
            case 'list':
              return await this.handleList(taskId, cursor);
            case 'create':
              return await this.handleCreate(taskId, content);
            default:
              return this.handleUnknownOperation(operation);
          }
        } catch (error: unknown) {
          return this.handleError(error);
        }
      }
    
      private async handleList(taskId?: string, cursor?: string): Promise<McpToolResponse> {
        if (!taskId) {
          return this.handleError(new Error('taskId is required for list operation'));
        }
    
        const commentsResponse = await this.motionService.getComments(taskId, cursor);
        const commentsResult = formatCommentList(commentsResponse.data);
    
        // Add pagination info if there's more data
        if (commentsResponse.meta.nextCursor && commentsResult.content[0]) {
          const firstContent = commentsResult.content[0];
          if ('text' in firstContent && typeof firstContent.text === 'string') {
            firstContent.text += `\n\nšŸ“„ More comments available. Use cursor: ${commentsResponse.meta.nextCursor}`;
          }
        }
    
        return commentsResult;
      }
    
      private async handleCreate(taskId?: string, content?: string): Promise<McpToolResponse> {
        if (!taskId) {
          return this.handleError(new Error('taskId is required for create operation'));
        }
        if (!content) {
          return this.handleError(new Error('content is required for create operation'));
        }
    
        // Reject oversized content before sanitization so the check is never dead code
        if (content.length > LIMITS.COMMENT_MAX_LENGTH) {
          return this.handleError(new Error(`Comment content exceeds maximum length of ${LIMITS.COMMENT_MAX_LENGTH} characters`));
        }
    
        // Sanitize and validate comment content
        const sanitizationResult = sanitizeCommentContent(content);
        if (!sanitizationResult.isValid) {
          return this.handleError(new Error(sanitizationResult.error || 'Invalid comment content'));
        }
    
        const sanitizedContent = sanitizationResult.sanitized;
    
        const commentData: CreateCommentData = {
          taskId,
          content: sanitizedContent
        };
    
        const newComment = await this.motionService.createComment(commentData);
        return formatCommentDetail(newComment);
      }
    }
  • Tool definition for motion_comments. Defines the tool name, description, and input schema with properties: operation (enum: list/create), taskId (required), content (for create), and cursor (for pagination).
    export const commentsToolDefinition: McpToolDefinition = {
      name: TOOL_NAMES.COMMENTS,
      description: "Manage comments on tasks",
      inputSchema: {
        type: "object",
        properties: {
          operation: {
            type: "string",
            enum: ["list", "create"],
            description: "Operation to perform"
          },
          taskId: {
            type: "string",
            description: "Task ID to comment on or fetch comments from (required)"
          },
          content: {
            type: "string",
            description: "Comment content (required for create operation)"
          },
          cursor: {
            type: "string",
            description: "Pagination cursor for list operation (optional)"
          }
        },
        required: ["operation", "taskId"]
      }
    };
  • Registers CommentHandler with the TOOL_NAMES.COMMENTS key ('motion_comments') in the handler factory, mapping the tool name to its handler class.
    private registerHandlers(): void {
      this.handlers.set(TOOL_NAMES.TASKS, TaskHandler);
      this.handlers.set(TOOL_NAMES.PROJECTS, ProjectHandler);
      this.handlers.set(TOOL_NAMES.WORKSPACES, WorkspaceHandler);
      this.handlers.set(TOOL_NAMES.USERS, UserHandler);
      this.handlers.set(TOOL_NAMES.SEARCH, SearchHandler);
      this.handlers.set(TOOL_NAMES.COMMENTS, CommentHandler);
      this.handlers.set(TOOL_NAMES.CUSTOM_FIELDS, CustomFieldHandler);
      this.handlers.set(TOOL_NAMES.RECURRING_TASKS, RecurringTaskHandler);
      this.handlers.set(TOOL_NAMES.SCHEDULES, ScheduleHandler);
      this.handlers.set(TOOL_NAMES.STATUSES, StatusHandler);
    }
  • TypeScript interface for MotionCommentsArgs defining the operation type ('list' | 'create'), required taskId string, optional content string, and optional cursor for pagination.
    export type CommentsOperation = 'list' | 'create';
    
    export interface MotionCommentsArgs {
      operation: CommentsOperation;
      taskId: string;
      content?: string;
      cursor?: string;
    }
  • Helper functions for formatting comment responses: formatCommentList formats multiple comments with truncation and display limits, formatCommentDetail formats single comment creation responses with metadata.
    export function formatCommentList(comments: MotionComment[]): CallToolResult {
      if (comments.length === 0) {
        return formatMcpSuccess("No comments found.");
      }
      
      const commentFormatter = (comment: MotionComment) => {
        const location = `Task ${comment.taskId}`;
        const timestamp = comment.createdAt;
        const author = comment.creator.name || comment.creator.email || comment.creator.id;
        // Truncate long comments for display
        const displayContent = comment.content.length > LIMITS.COMMENT_DISPLAY_LENGTH 
          ? comment.content.substring(0, LIMITS.COMMENT_DISPLAY_LENGTH) + '...'
          : comment.content;
        // Keep as single line for proper list formatting
        return `- [${comment.id}] ${location} | Author: ${author} | ${timestamp} | "${displayContent}"`;
      };
      
      return formatListResponse(
        comments, 
        `Found ${comments.length} comment${comments.length === 1 ? '' : 's'}`,
        commentFormatter
      );
    }
    
    /**
     * Format single comment response  
     */
    export function formatCommentDetail(comment: MotionComment): CallToolResult {
      const location = `Task ${comment.taskId}`;
      const timestamp = comment.createdAt;
      const author = comment.creator.name || comment.creator.email || comment.creator.id;
      
      const details = [
        `Comment created successfully:`,
        `- ID: ${comment.id}`,
        `- Location: ${location}`,
        `- Author: ${author}`,
        `- Created: ${timestamp}`,
        `- Content: "${comment.content}"`
      ].join('\n');
      
      return formatMcpSuccess(details);
    }

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv2.6.0

TDQS

C2.6/5.0
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description must fully disclose behavior, but it only says 'manage comments.' It doesn't mention side effects of creating comments, permission requirements, or return formats. This is a significant gap for a tool with mutating and listing capabilities.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is extremely concise at four words, front-loaded, and free of unnecessary words. However, the brevity sacrifices specificity, making it less helpful than a slightly longer, more informative description.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

The tool supports two operations (list and create) with pagination, but the description doesn't explain how the operation parameter controls behavior or what the response contains. No output schema exists to compensate, so the description is insufficient for an agent to use the tool correctly.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The schema provides descriptions for all four parameters (operation, taskId, content, cursor), achieving 100% coverage. The description adds no extra parameter meaning beyond the schema, so the baseline of 3 applies.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose3/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description states the tool deals with comments on tasks, which is a clear resource, but uses the vague verb 'manage' instead of specifying concrete operations like list or create. It doesn't explicitly distinguish from sibling tools, though the name and resource imply a unique focus on comments.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

No usage guidance is provided. The description doesn't indicate when to use this tool instead of other motion_* tools, nor when to choose the 'list' operation versus 'create'. This leaves the agent without context for selecting this tool.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.