Skip to main content
Glama
aliyun

AlibabaCloud DevOps MCP Server

Official
by aliyun

create_workitem_attachment

Attach a local file to a work item using its absolute path. Supports any file type.

Instructions

[Project Management] Upload a local file as an attachment to a specific work item. The MCP Server reads the file from the given local absolute path and uploads it. Supports any file type.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
organizationIdYesOrganization ID, can be found in the basic information page of the organization admin console
workItemIdYes工作项唯一标识
filePathYes本地文件的绝对路径,MCP Server 将读取该文件并上传为工作项附件
operatorIdNo操作者的userId,个人token时该参数无效

Implementation Reference

  • Core handler function that uploads a local file as an attachment to a work item. Reads the file from disk, constructs a multipart/form-data request using fetch(), and sends it to the Yunxiao API. Handles both region and non-region editions via URL path selection.
    export async function createWorkitemAttachmentFunc(
      organizationId: string | undefined,
      workItemId: string,
      filePath: string,
      operatorId?: string
    ): Promise<WorkitemFile> {
      // 验证文件存在
      if (!existsSync(filePath)) {
        throw new Error(`File not found: ${filePath}`);
      }
    
      // 读取文件内容
      const fileBuffer = await readFile(filePath);
      const fileName = path.basename(filePath);
    
      const finalOrgId = await resolveOrganizationId(organizationId);
      const urlPath = isRegionEdition()
        ? `/oapi/v1/projex/workitems/${workItemId}/attachments`
        : `/oapi/v1/projex/organizations/${finalOrgId}/workitems/${workItemId}/attachments`;
    
      const fullUrl = `${getYunxiaoApiBaseUrl()}${urlPath}`;
    
      // 构造 FormData(Node.js 18+ 原生支持)
      const formData = new FormData();
      const blob = new Blob([fileBuffer]);
      formData.append("file", blob, fileName);
      if (operatorId) {
        formData.append("operatorId", operatorId);
      }
    
      // 直接用 fetch 发送 multipart/form-data(不走 yunxiaoRequest,因为它强制 JSON content-type)
      const requestHeaders: Record<string, string> = {
        "Accept": "application/json",
        "User-Agent": `modelcontextprotocol/servers/alibabacloud-devops-mcp-server/v${VERSION} ${getUserAgent()}`,
      };
    
      const token = getCurrentSessionToken();
      if (token) {
        requestHeaders["x-yunxiao-token"] = token;
      }
    
      const response = await fetch(fullUrl, {
        method: "POST",
        headers: requestHeaders,
        body: formData,
      } as RequestInit);
    
      const contentType = response.headers.get("content-type");
      const responseBody = contentType?.includes("application/json")
        ? await response.json()
        : await response.text();
    
      if (!response.ok) {
        throw createYunxiaoError(
          response.status,
          responseBody,
          fullUrl,
          "POST",
          requestHeaders,
          { filePath, fileName }
        );
      }
    
      return WorkitemFileSchema.parse(responseBody);
    }
  • Zod schema defining the input parameters: organizationId (required), workItemId (required), filePath (required local absolute path), and operatorId (optional).
    export const CreateWorkitemAttachmentSchema = z.object({
      organizationId: z.string().describe("Organization ID, can be found in the basic information page of the organization admin console"),
      workItemId: z.string().describe("工作项唯一标识"),
      filePath: z.string().describe("本地文件的绝对路径,MCP Server 将读取该文件并上传为工作项附件"),
      operatorId: z.string().optional().describe("操作者的userId,个人token时该参数无效"),
    });
  • Tool registration in the project management tool registry, defining the tool name, description, and input schema.
      name: "create_workitem_attachment",
      description: "[Project Management] Upload a local file as an attachment to a specific work item. The MCP Server reads the file from the given local absolute path and uploads it. Supports any file type.",
      inputSchema: zodToJsonSchema(types.CreateWorkitemAttachmentSchema),
    },
  • Tool handler dispatch case that parses arguments using the Zod schema and delegates to createWorkitemAttachmentFunc.
    case "create_workitem_attachment": {
      const args = types.CreateWorkitemAttachmentSchema.parse(request.params.arguments);
      const result = await attachment.createWorkitemAttachmentFunc(
        args.organizationId,
        args.workItemId,
        args.filePath,
        args.operatorId
      );
      return {
        content: [{ type: "text", text: JSON.stringify(result, null, 2) }],
      };
    }
  • Re-export of CreateWorkitemAttachmentSchema from operations/projex/types.ts via the common types barrel file.
    // Attachment schemas
    ListWorkitemAttachmentsSchema,
    GetWorkitemFileSchema,
    CreateWorkitemAttachmentSchema,
Behavior3/5

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

States that the server reads a local file and uploads it, supporting any file type. Lacks disclosure on failure modes (e.g., missing file), idempotency, or side effects. With no annotations, more transparency would be beneficial.

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?

Two sentences with all essential information. The '[Project Management]' prefix is slightly redundant but not harmful. Efficient for a 4-parameter tool.

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?

No output schema and no annotations. Description lacks details on return values, error conditions, and effects (e.g., overwriting or appending). More context needed for a write operation.

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 covers all 4 parameters with descriptions. The description adds no extra meaning beyond what the schema provides, baseline 3 is appropriate.

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

Purpose5/5

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

Clearly identifies the action: uploading a local file as an attachment to a work item. Distinguishes from sibling tools like list_workitem_attachments (listing) and get_workitem_file (downloading).

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

Usage Guidelines3/5

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

Implied usage: attaching files to work items. No explicit guidance on when to use vs. alternatives, or constraints like file size, permissions, or prerequisites.

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

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