Skip to main content
Glama

ado_add_attachment

Add attachments to Azure DevOps work items by uploading new files or linking existing ones to track documentation and related assets.

Instructions

Agrega un adjunto a un Work Item existente. Puede subir un archivo nuevo o vincular uno ya subido.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
workItemIdYesID del Work Item
filePathNoRuta del archivo a subir (opcional si se usa attachmentUrl)
attachmentUrlNoURL de un adjunto ya subido (opcional si se usa filePath)
commentNoComentario para el adjunto

Implementation Reference

  • Implementation of the 'ado_add_attachment' tool in src/index.ts, handling both raw file uploads and linking pre-existing attachment URLs to Azure DevOps Work Items.
    server.tool(
      "ado_add_attachment",
      "Agrega un adjunto a un Work Item existente. Puede subir un archivo nuevo o vincular uno ya subido.",
      {
        workItemId: z.number().describe("ID del Work Item"),
        filePath: z.string().optional().describe("Ruta del archivo a subir (opcional si se usa attachmentUrl)"),
        attachmentUrl: z.string().optional().describe("URL de un adjunto ya subido (opcional si se usa filePath)"),
        comment: z.string().optional().describe("Comentario para el adjunto"),
      },
      async ({ workItemId, filePath, attachmentUrl, comment }) => {
        const api = await getWitApi();
    
        let url = attachmentUrl;
    
        // Si se proporciona un archivo, subirlo primero usando REST API
        if (filePath) {
          if (!currentPat || !currentOrg) {
            throw new Error("No hay conexión configurada. Usa ado_configure primero.");
          }
    
          if (!fs.existsSync(filePath)) {
            throw new Error(`El archivo no existe: ${filePath}`);
          }
    
          const fileName = path.basename(filePath);
          const attachment = await uploadAttachmentRest(filePath, fileName);
          url = attachment.url;
        }
    
        if (!url) {
          throw new Error("Debe proporcionar filePath o attachmentUrl");
        }
    
        // Vincular el adjunto al Work Item
        const patchDocument: VSSInterfaces.JsonPatchOperation[] = [
          {
            op: VSSInterfaces.Operation.Add,
            path: "/relations/-",
            value: {
              rel: "AttachedFile",
              url: url,
              attributes: {
                comment: comment || "",
              },
            },
          },
        ];
    
        await api.updateWorkItem(null, patchDocument, workItemId);
    
        return {
          content: [
            {
              type: "text",
              text: `Adjunto agregado exitosamente al Work Item #${workItemId}\n- URL: ${url}`,
            },
          ],
        };
      }

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/soulberto/mcp-azure'

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