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);
    }
Behavior2/5

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

No annotations are provided, so the description carries full burden. 'Manage comments' implies both read and write capabilities, but it doesn't disclose behavioral traits like authentication needs, rate limits, pagination behavior for list operations, or side effects of create operations. The description is minimal and fails to add meaningful context beyond the basic operation verbs.

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—a single phrase—and front-loaded with the core purpose. However, it's arguably too brief, bordering on under-specified rather than efficiently informative. It earns points for zero waste but loses one point for lacking necessary elaboration given the tool's complexity.

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?

Given no annotations, no output schema, and a multi-operation tool with four parameters, the description is incomplete. It doesn't cover return values, error conditions, or operational nuances. The agent must rely heavily on the input schema and trial-and-error, making this inadequate for a tool with moderate complexity.

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?

Schema description coverage is 100%, so the schema fully documents all parameters. The description adds no parameter semantics beyond what's in the schema—it doesn't explain relationships (e.g., content is only for create), constraints, or examples. Baseline 3 is appropriate as the schema does the heavy lifting, but the description doesn't compensate or enhance understanding.

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 'Manage comments on tasks' states the general purpose (verb+resource) but is vague about what 'manage' entails. It doesn't distinguish this tool from potential sibling comment tools (though none are listed), and 'manage' could encompass various operations beyond just list/create. The description provides basic orientation but lacks specificity.

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 guidance is provided on when to use this tool versus alternatives. The description doesn't mention prerequisites, context for choosing between list/create operations, or how it relates to sibling tools like motion_tasks. Usage is implied through parameter names but not explicitly stated, leaving the agent to infer from the schema alone.

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

Install Server

Other Tools

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/sergiolopez94/motion-mcp-server'

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