AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
TypeScript ai-agentai-agent-toolsai-agentsai-agents-frameworkmcpmcp-servermcp-toolsmcpsn8n-alternativeno-code-automationworkflowworkflow-automationworkflows
import { createAction, Property } from "@activepieces/pieces-framework";
import { jiraCloudAuth } from "../../auth";
import { jiraApiCall } from "../common";
import { AuthenticationType, httpClient, HttpMethod } from "@activepieces/pieces-common";
import { legacyGetAttachmentOutputSchema } from '../output-schemas';
export const getIssueAttachmentAction = createAction({
auth: jiraCloudAuth,
name: 'get-issue-attachment',
classification: 'READ',
displayName: 'Get Issue Attachment',
description: "Gets an attachment's details and downloads its file.",
audience: 'human',
aiMetadata: {
description:
'Download a Jira attachment by its attachment ID, fetching both its metadata and the file content itself for use in later steps. Use when you already have the attachment ID (e.g. from Get Issue) and need the actual file, not just a link. Read-only and idempotent.',
idempotent: true,
},
outputSchema: legacyGetAttachmentOutputSchema,
props: {
attachmentId: Property.ShortText({
displayName: 'Attachment ID',
description: "Found in a Get Issue step's output, under fields → attachment.",
placeholder: '10001',
required: true
})
},
async run(context) {
const { attachmentId } = context.propsValue;
// https://community.developer.atlassian.com/t/download-attachment-from-rest-api/40860/2
const attachmentResponse = await jiraApiCall<{ filename: string, content: string }>({
method: HttpMethod.GET,
resourceUri: `/attachment/${attachmentId}`,
auth: context.auth,
})
const { filename, content } = attachmentResponse;
const response = await httpClient.sendRequest({
url: content,
method: HttpMethod.GET,
authentication: {
type: AuthenticationType.BASIC,
username: context.auth.props.email,
password: context.auth.props.apiToken,
},
responseType: 'arraybuffer',
followRedirects: true,
})
return {
...attachmentResponse,
file: await context.files.write({
fileName: filename,
data: Buffer.from(response.body)
})
}
}
})