@azure-devops/mcp 2.5.0-nightly.20260324 → 2.5.0-nightly.20260325
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/tools/work-items.js +56 -0
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/tools/work-items.js
CHANGED
|
@@ -26,6 +26,7 @@ const WORKITEM_TOOLS = {
|
|
|
26
26
|
work_items_link: "wit_work_items_link",
|
|
27
27
|
work_item_unlink: "wit_work_item_unlink",
|
|
28
28
|
add_artifact_link: "wit_add_artifact_link",
|
|
29
|
+
get_work_item_attachment: "wit_get_work_item_attachment",
|
|
29
30
|
};
|
|
30
31
|
function getLinkTypeFromName(name) {
|
|
31
32
|
switch (name.toLowerCase()) {
|
|
@@ -1033,5 +1034,60 @@ function configureWorkItemTools(server, tokenProvider, connectionProvider, userA
|
|
|
1033
1034
|
};
|
|
1034
1035
|
}
|
|
1035
1036
|
});
|
|
1037
|
+
server.tool(WORKITEM_TOOLS.get_work_item_attachment, "Download a work item attachment by its ID and return the content as a base64-encoded resource. Useful for viewing images (e.g. screenshots) attached to work items such as bugs.", {
|
|
1038
|
+
project: z.string().describe("The name or ID of the Azure DevOps project."),
|
|
1039
|
+
attachmentId: z.string().describe("The GUID of the attachment. Found in the attachment URL: https://dev.azure.com/{org}/{project}/_apis/wit/attachments/{attachmentId}"),
|
|
1040
|
+
fileName: z.string().optional().describe("The file name of the attachment, e.g. 'screenshot.png'. Used to determine the MIME type for the returned resource."),
|
|
1041
|
+
}, async ({ project, attachmentId, fileName }) => {
|
|
1042
|
+
try {
|
|
1043
|
+
const connection = await connectionProvider();
|
|
1044
|
+
const workItemApi = await connection.getWorkItemTrackingApi();
|
|
1045
|
+
const stream = await workItemApi.getAttachmentContent(attachmentId, fileName, project);
|
|
1046
|
+
const chunks = [];
|
|
1047
|
+
await new Promise((resolve, reject) => {
|
|
1048
|
+
stream.on("data", (chunk) => chunks.push(Buffer.from(chunk)));
|
|
1049
|
+
stream.on("end", resolve);
|
|
1050
|
+
stream.on("error", reject);
|
|
1051
|
+
});
|
|
1052
|
+
const buffer = Buffer.concat(chunks);
|
|
1053
|
+
const base64Data = buffer.toString("base64");
|
|
1054
|
+
const mimeType = getMimeType(fileName);
|
|
1055
|
+
return {
|
|
1056
|
+
content: [
|
|
1057
|
+
{
|
|
1058
|
+
type: "resource",
|
|
1059
|
+
resource: {
|
|
1060
|
+
uri: `data:${mimeType};base64,${base64Data}`,
|
|
1061
|
+
mimeType,
|
|
1062
|
+
blob: base64Data,
|
|
1063
|
+
},
|
|
1064
|
+
},
|
|
1065
|
+
],
|
|
1066
|
+
};
|
|
1067
|
+
}
|
|
1068
|
+
catch (error) {
|
|
1069
|
+
const errorMessage = error instanceof Error ? error.message : "Unknown error occurred";
|
|
1070
|
+
return {
|
|
1071
|
+
content: [{ type: "text", text: `Error retrieving work item attachment: ${errorMessage}` }],
|
|
1072
|
+
isError: true,
|
|
1073
|
+
};
|
|
1074
|
+
}
|
|
1075
|
+
});
|
|
1076
|
+
}
|
|
1077
|
+
function getMimeType(fileName) {
|
|
1078
|
+
const ext = fileName?.split(".").pop()?.toLowerCase();
|
|
1079
|
+
const mimeTypes = {
|
|
1080
|
+
png: "image/png",
|
|
1081
|
+
jpg: "image/jpeg",
|
|
1082
|
+
jpeg: "image/jpeg",
|
|
1083
|
+
gif: "image/gif",
|
|
1084
|
+
bmp: "image/bmp",
|
|
1085
|
+
svg: "image/svg+xml",
|
|
1086
|
+
webp: "image/webp",
|
|
1087
|
+
pdf: "application/pdf",
|
|
1088
|
+
txt: "text/plain",
|
|
1089
|
+
zip: "application/zip",
|
|
1090
|
+
};
|
|
1091
|
+
return (ext && mimeTypes[ext]) ?? "application/octet-stream";
|
|
1036
1092
|
}
|
|
1037
1093
|
export { WORKITEM_TOOLS, configureWorkItemTools };
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const packageVersion = "2.5.0-nightly.
|
|
1
|
+
export const packageVersion = "2.5.0-nightly.20260325";
|