Skip to main content
Glama
aliyun

AlibabaCloud DevOps MCP Server

Official
by aliyun

update_work_item

Modify work item details like status, assignee, priority, and custom fields in Alibaba Cloud DevOps projects to track progress and manage tasks.

Instructions

[Project Management] Update a work item

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
organizationIdYesOrganization ID
workItemIdYesWork item ID
updateWorkItemFieldsYes

Implementation Reference

  • Handler for the update_work_item tool. Parses input arguments using UpdateWorkItemSchema and delegates to workitem.updateWorkItemFunc.
    case "update_work_item": {
      const args = types.UpdateWorkItemSchema.parse(request.params.arguments);
      await workitem.updateWorkItemFunc(
        args.organizationId,
        args.workItemId,
        args.updateWorkItemFields
      );
      return {
        content: [{ type: "text", text: "" }],
      };
    }
  • Zod schemas defining the input structure for update_work_item: UpdateWorkItemFieldSchema (fields to update) and UpdateWorkItemSchema (including organizationId and workItemId).
    export const UpdateWorkItemFieldSchema = z.object({
      subject: z.string().optional().describe("工作项标题"),
      description: z.string().optional().describe("工作项描述"),
      status: z.string().optional().describe("状态Id"),
      assignedTo: z.string().optional().describe("指派人userId"),
      priority: z.string().optional().describe("优先级Id"),
      labels: z.array(z.string()).optional().describe("关联的标签id列表"),
      sprint: z.string().optional().describe("关联的迭代Id"),
      trackers: z.array(z.string()).optional().describe("抄送人userId列表"),
      verifier: z.string().optional().describe("验证人userId"),
      participants: z.array(z.string()).optional().describe("参与人userId列表"),
      versions: z.array(z.string()).optional().describe("关联的版本Id列表"),
      customFieldValues: z.record(z.string(), z.any()).optional().describe("自定义字段值,格式为 {\"fieldId\": \"value\"} 或 {\"fieldId\": [\"value1\", \"value2\"]}"),
    });
    
    export const UpdateWorkItemSchema = z.object({
      organizationId: z.string().describe("Organization ID"),
      workItemId: z.string().describe("Work item ID"),
      updateWorkItemFields: UpdateWorkItemFieldSchema
    });
  • Registration of the update_work_item tool in the project-management tool registry, including name, description, and input schema reference.
      name: "update_work_item",
      description: "[Project Management] Update a work item",
      inputSchema: zodToJsonSchema(types.UpdateWorkItemSchema),
    },
  • Core helper function that implements the update logic: builds the request body from provided fields (including custom fields) and performs PUT request to the Yunxiao API endpoint.
    export async function updateWorkItemFunc(
        organizationId: string,
        workItemId: string,
        updateWorkItemFields: UpdateWorkItemField
    ): Promise<void> {
      const url = `/oapi/v1/projex/organizations/${organizationId}/workitems/${workItemId}`;
    
      // 构建请求体,将自定义字段合并到主对象中
      const requestBody: Record<string, any> = {};
    
      // 复制所有标准字段
      if (updateWorkItemFields.subject !== undefined) {
        requestBody.subject = updateWorkItemFields.subject;
      }
      if (updateWorkItemFields.description !== undefined) {
        requestBody.description = updateWorkItemFields.description;
      }
      if (updateWorkItemFields.status !== undefined) {
        requestBody.status = updateWorkItemFields.status;
      }
      if (updateWorkItemFields.assignedTo !== undefined) {
        requestBody.assignedTo = updateWorkItemFields.assignedTo;
      }
      if (updateWorkItemFields.priority !== undefined) {
        requestBody.priority = updateWorkItemFields.priority;
      }
      if (updateWorkItemFields.labels !== undefined) {
        requestBody.labels = updateWorkItemFields.labels;
      }
      if (updateWorkItemFields.sprint !== undefined) {
        requestBody.sprint = updateWorkItemFields.sprint;
      }
      if (updateWorkItemFields.trackers !== undefined) {
        requestBody.trackers = updateWorkItemFields.trackers;
      }
      if (updateWorkItemFields.verifier !== undefined) {
        requestBody.verifier = updateWorkItemFields.verifier;
      }
      if (updateWorkItemFields.participants !== undefined) {
        requestBody.participants = updateWorkItemFields.participants;
      }
      if (updateWorkItemFields.versions !== undefined) {
        requestBody.versions = updateWorkItemFields.versions;
      }
    
      // 处理自定义字段
      if (updateWorkItemFields.customFieldValues !== undefined) {
        // 将自定义字段合并到请求体中
        Object.entries(updateWorkItemFields.customFieldValues).forEach(([fieldId, value]) => {
          requestBody[fieldId] = value;
        });
      }
    
      const response = await yunxiaoRequest(url, {
        method: "PUT",
        body: requestBody,
      });
    }

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