Skip to main content
Glama
aliyun

AlibabaCloud DevOps MCP Server

Official
by aliyun

create_change_request_comment

Add comments to code change requests in Alibaba Cloud DevOps for review, feedback, or issue tracking during development workflows.

Instructions

[Code Management] Create a comment on a change request

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
organizationIdYesOrganization ID, can be found in the basic information page of the organization admin console
repositoryIdYesRepository ID or a combination of organization ID and repository name, for example: 2835387 or organizationId%2Frepo-name (Note: slashes need to be URL encoded as %2F)
localIdYesLocal ID, represents the nth merge request in the repository
comment_typeNoComment type. Possible values: GLOBAL_COMMENT, INLINE_COMMENTGLOBAL_COMMENT
contentYesComment content, length must be between 1 and 65535
draftNoWhether it is a draft comment
resolvedNoWhether to mark as resolved
patchset_biz_idYesAssociated version ID, if it's INLINE_COMMENT, choose one from from_patchset_biz_id or to_patchset_biz_id
file_pathNoFile name, only for inline comments
line_numberNoLine number, only for inline comments
from_patchset_biz_idNoStart version ID for comparison, required for INLINE_COMMENT type
to_patchset_biz_idNoTarget version ID for comparison, required for INLINE_COMMENT type
parent_comment_biz_idNoParent comment ID

Implementation Reference

  • The MCP tool handler switch case that parses the input arguments with CreateChangeRequestCommentSchema and invokes the createChangeRequestCommentFunc to execute the API call for creating a change request comment, returning the result as formatted JSON.
    case "create_change_request_comment": {
      const args = types.CreateChangeRequestCommentSchema.parse(request.params.arguments);
      const comment = await changeRequestComments.createChangeRequestCommentFunc(
        args.organizationId,
        args.repositoryId,
        args.localId,
        args.comment_type,
        args.content,
        args.draft,
        args.resolved,
        args.patchset_biz_id,
        args.file_path ?? undefined,
        args.line_number ?? undefined,
        args.from_patchset_biz_id ?? undefined,
        args.to_patchset_biz_id ?? undefined,
        args.parent_comment_biz_id ?? undefined
      );
      return {
        content: [{ type: "text", text: JSON.stringify(comment, null, 2) }],
      };
    }
  • Zod schema defining the input validation for the create_change_request_comment tool parameters.
    export const CreateChangeRequestCommentSchema = z.object({
      organizationId: z.string().describe("Organization ID, can be found in the basic information page of the organization admin console"),
      repositoryId: z.string().describe("Repository ID or a combination of organization ID and repository name, for example: 2835387 or organizationId%2Frepo-name (Note: slashes need to be URL encoded as %2F)"),
      localId: z.string().describe("Local ID, represents the nth merge request in the repository"),
      comment_type: z.string().default("GLOBAL_COMMENT").describe("Comment type. Possible values: GLOBAL_COMMENT, INLINE_COMMENT"),
      content: z.string().describe("Comment content, length must be between 1 and 65535"),
      draft: z.boolean().default(false).describe("Whether it is a draft comment"),
      resolved: z.boolean().default(false).describe("Whether to mark as resolved"),
      patchset_biz_id: z.string().describe("Associated version ID, if it's INLINE_COMMENT, choose one from from_patchset_biz_id or to_patchset_biz_id"),
      file_path: z.string().nullable().optional().describe("File name, only for inline comments"),
      line_number: z.number().int().nullable().optional().describe("Line number, only for inline comments"),
      from_patchset_biz_id: z.string().nullable().optional().describe("Start version ID for comparison, required for INLINE_COMMENT type"),
      to_patchset_biz_id: z.string().nullable().optional().describe("Target version ID for comparison, required for INLINE_COMMENT type"),
      parent_comment_biz_id: z.string().nullable().optional().describe("Parent comment ID"),
    });
  • Tool registration entry in the code-management tool registry, defining the tool name, description, and input schema.
      name: "create_change_request_comment",
      description: "[Code Management] Create a comment on a change request",
      inputSchema: zodToJsonSchema(types.CreateChangeRequestCommentSchema),
    },
  • Supporting function that builds the API payload conditionally based on comment type (GLOBAL_COMMENT or INLINE_COMMENT), encodes repository ID, makes POST request to Codeup API to create the comment, and parses the response.
    export async function createChangeRequestCommentFunc(
      organizationId: string,
      repositoryId: string,
      localId: string,
      comment_type: string, // Possible values: GLOBAL_COMMENT, INLINE_COMMENT
      content: string,
      draft: boolean,
      resolved: boolean,
      patchset_biz_id: string,
      file_path?: string,
      line_number?: number,
      from_patchset_biz_id?: string,
      to_patchset_biz_id?: string,
      parent_comment_biz_id?: string
    ): Promise<z.infer<typeof ChangeRequestCommentSchema>> {
      const encodedRepoId = handleRepositoryIdEncoding(repositoryId);
    
      const url = `/oapi/v1/codeup/organizations/${organizationId}/repositories/${encodedRepoId}/changeRequests/${localId}/comments`;
    
      // 准备payload
      const payload: Record<string, any> = {
        comment_type: comment_type,
        content: content,
        draft: draft,
        resolved: resolved,
        patchset_biz_id: patchset_biz_id,
      };
    
      // 根据评论类型添加必要参数
      if (comment_type === "INLINE_COMMENT") {
        // 检查INLINE_COMMENT必需的参数
        if (!file_path || line_number === undefined || !from_patchset_biz_id || !to_patchset_biz_id) {
          throw new Error("For INLINE_COMMENT, file_path, line_number, from_patchset_biz_id, and to_patchset_biz_id are required");
        }
    
        payload.file_path = file_path;
        payload.line_number = line_number;
        payload.from_patchset_biz_id = from_patchset_biz_id;
        payload.to_patchset_biz_id = to_patchset_biz_id;
      }
    
      // 添加可选参数
      if (parent_comment_biz_id) {
        payload.parent_comment_biz_id = parent_comment_biz_id;
      }
    
      const response = await yunxiaoRequest(url, {
        method: "POST",
        body: payload,
      });
    
      return ChangeRequestCommentSchema.parse(response);
    }

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/aliyun/alibabacloud-devops-mcp-server'

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