Skip to main content
Glama
asachs01

Autotask MCP Server

get_ticket_attachment

Retrieve a specific attachment from an Autotask PSA ticket using ticket ID and attachment ID, with optional base64 file data inclusion.

Instructions

Get a specific ticket attachment by ticket ID and attachment ID

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
ticketIdYesThe ticket ID
attachmentIdYesThe attachment ID to retrieve
includeDataNoWhether to include base64 encoded file data (default: false)

Implementation Reference

  • Core implementation of get_ticket_attachment: queries Autotask attachments endpoint filtered by ticketId (parentId) and attachmentId.
    async getTicketAttachment(ticketId: number, attachmentId: number, includeData: boolean = false): Promise<AutotaskTicketAttachment | null> {
      const client = await this.ensureClient();
      
      try {
        this.logger.debug(`Getting ticket attachment - TicketID: ${ticketId}, AttachmentID: ${attachmentId}, includeData: ${includeData}`);
        
        // Search for attachment by parent ID and attachment ID
        const result = await client.attachments.list({
          filter: [
            { field: 'parentId', op: 'eq', value: ticketId },
            { field: 'id', op: 'eq', value: attachmentId }
          ]
        });
        
        const attachments = (result.data as any[]) || [];
        return attachments.length > 0 ? attachments[0] as AutotaskTicketAttachment : null;
      } catch (error) {
        this.logger.error(`Failed to get ticket attachment ${attachmentId} for ticket ${ticketId}:`, error);
        throw error;
      }
    }
  • Input schema definition for the get_ticket_attachment tool, defining parameters ticketId, attachmentId, and optional includeData.
    {
      name: 'get_ticket_attachment',
      description: 'Get a specific ticket attachment by ticket ID and attachment ID',
      inputSchema: {
        type: 'object',
        properties: {
          ticketId: {
            type: 'number',
            description: 'The ticket ID'
          },
          attachmentId: {
            type: 'number',
            description: 'The attachment ID to retrieve'
          },
          includeData: {
            type: 'boolean',
            description: 'Whether to include base64 encoded file data (default: false)',
            default: false
          }
        },
        required: ['ticketId', 'attachmentId']
      }
  • Tool registration in listTools(): adds get_ticket_attachment to the available MCP tools list.
    {
      name: 'get_ticket_attachment',
      description: 'Get a specific ticket attachment by ticket ID and attachment ID',
      inputSchema: {
        type: 'object',
        properties: {
          ticketId: {
            type: 'number',
            description: 'The ticket ID'
          },
          attachmentId: {
            type: 'number',
            description: 'The attachment ID to retrieve'
          },
          includeData: {
            type: 'boolean',
            description: 'Whether to include base64 encoded file data (default: false)',
            default: false
          }
        },
        required: ['ticketId', 'attachmentId']
      }
    },
  • Handler dispatch in callTool(): routes get_ticket_attachment calls to autotaskService.getTicketAttachment.
    case 'get_ticket_attachment':
      result = await this.autotaskService.getTicketAttachment(args.ticketId, args.attachmentId, args.includeData);
      message = `Ticket attachment retrieved successfully`;

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/asachs01/autotask-mcp'

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