Skip to main content
Glama

ado_upload_attachment

Upload files as attachments to Azure DevOps work items and retrieve attachment URLs to link documents directly to tasks, bugs, or features.

Instructions

Sube un archivo como adjunto a Azure DevOps y devuelve la URL del adjunto

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
filePathYesRuta completa del archivo a subir
fileNameNoNombre del archivo (opcional, se usa el nombre del archivo si no se especifica)

Implementation Reference

  • Handler for ado_upload_attachment tool.
    async ({ filePath, fileName }) => {
      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 name = fileName || path.basename(filePath);
      const attachment = await uploadAttachmentRest(filePath, name);
    
      return {
        content: [
          {
            type: "text",
            text: `Archivo subido exitosamente:\n- Nombre: ${name}\n- URL: ${attachment.url}\n- ID: ${attachment.id}\n\nUsa esta URL con ado_add_attachment para vincular el adjunto a un Work Item.`,
          },
        ],
      };
    }
  • src/index.ts:781-809 (registration)
    Tool registration for ado_upload_attachment.
    server.tool(
      "ado_upload_attachment",
      "Sube un archivo como adjunto a Azure DevOps y devuelve la URL del adjunto",
      {
        filePath: z.string().describe("Ruta completa del archivo a subir"),
        fileName: z.string().optional().describe("Nombre del archivo (opcional, se usa el nombre del archivo si no se especifica)"),
      },
      async ({ filePath, fileName }) => {
        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 name = fileName || path.basename(filePath);
        const attachment = await uploadAttachmentRest(filePath, name);
    
        return {
          content: [
            {
              type: "text",
              text: `Archivo subido exitosamente:\n- Nombre: ${name}\n- URL: ${attachment.url}\n- ID: ${attachment.id}\n\nUsa esta URL con ado_add_attachment para vincular el adjunto a un Work Item.`,
            },
          ],
        };
      }
    );
  • Helper function that performs the actual REST API call to upload the attachment.
    async function uploadAttachmentRest(
      filePath: string,
      fileName: string
    ): Promise<{ url: string; id: string }> {
      const fileContent = fs.readFileSync(filePath);
    
      // Construir URL del API - asegurar que no haya doble slash
      const baseUrl = currentOrg.endsWith("/") ? currentOrg.slice(0, -1) : currentOrg;
      const encodedProject = encodeURIComponent(currentProject);
      const encodedFileName = encodeURIComponent(fileName);
      const fullUrl = `${baseUrl}/${encodedProject}/_apis/wit/attachments?fileName=${encodedFileName}&api-version=7.0`;
    
      const urlObj = new URL(fullUrl);
    
      const options: https.RequestOptions = {
        hostname: urlObj.hostname,
        path: urlObj.pathname + urlObj.search,
        method: "POST",
        headers: {
          "Content-Type": "application/octet-stream",
          "Content-Length": fileContent.length,
          "Authorization": `Basic ${Buffer.from(`:${currentPat}`).toString("base64")}`,
        },
      };
    
      return new Promise((resolve, reject) => {
        const req = https.request(options, (res) => {
          let data = "";
          res.on("data", (chunk) => (data += chunk));
          res.on("end", () => {
            if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
              try {
                const result = JSON.parse(data);
                resolve({ url: result.url, id: result.id });
              } catch (e) {
                reject(new Error(`Error parsing response: ${data}`));
              }
            } else {
              reject(new Error(`Error uploading attachment: ${res.statusCode} - ${data}`));
            }
Behavior2/5

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

With no annotations provided, the description carries the full burden of behavioral disclosure. It mentions that the tool returns a URL, which is useful, but fails to cover critical aspects like authentication requirements, rate limits, error handling, or whether the operation is idempotent. For a file upload tool, this leaves significant gaps in understanding its behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness5/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single, efficient sentence that front-loads the core action and outcome. There is no wasted verbiage, and it directly communicates the tool's function without unnecessary details.

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 the complexity of a file upload operation with no annotations and no output schema, the description is insufficient. It doesn't explain the return value beyond mentioning a URL, nor does it cover error cases, permissions, or integration with other tools like work items. This leaves the agent with incomplete context for proper usage.

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?

The schema description coverage is 100%, so the schema already documents both parameters thoroughly. The description adds no additional meaning beyond what the schema provides, such as file size limits or supported formats. This meets the baseline for high schema coverage but doesn't enhance parameter understanding.

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

Purpose4/5

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

The description clearly states the action ('Sube un archivo') and the target resource ('como adjunto a Azure DevOps'), making the purpose evident. However, it doesn't explicitly differentiate from sibling tools like 'ado_add_attachment' or 'ado_get_attachments', which reduces clarity about when to use this specific tool versus alternatives.

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?

The description provides no guidance on when to use this tool versus alternatives like 'ado_add_attachment' or 'ado_get_attachments'. It lacks context about prerequisites, such as whether a work item must exist first, or any exclusions for usage scenarios.

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

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