@takashito/linode-mcp-server
Version:
MCP server for Linode API
347 lines • 17 kB
JavaScript
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || (function () {
var ownKeys = function(o) {
ownKeys = Object.getOwnPropertyNames || function (o) {
var ar = [];
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
return ar;
};
return ownKeys(o);
};
return function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
__setModuleDefault(result, mod);
return result;
};
})();
Object.defineProperty(exports, "__esModule", { value: true });
exports.registerImagesTools = registerImagesTools;
const client_1 = require("../../client");
const schemas_1 = require("../common/schemas");
const schemas = __importStar(require("./schemas"));
const errorHandler_1 = require("../common/errorHandler");
function registerImagesTools(server) {
// List all images
server.addTool({
name: 'list_images',
description: 'Get a list of all available Images',
parameters: (0, schemas_1.mcpInput)(schemas.listImagesSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
const paginationParams = {
page: params.page,
page_size: params.page_size
};
const result = await (0, client_1.createClient)(context).images.getImages(paginationParams);
return JSON.stringify(result, null, 2);
})
});
// Get a specific image
server.addTool({
name: 'get_image',
description: 'Get details for a specific Image',
parameters: (0, schemas_1.mcpInput)(schemas.getImageSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
const result = await (0, client_1.createClient)(context).images.getImage(params.imageId);
return JSON.stringify(result, null, 2);
})
});
// Create an image
server.addTool({
name: 'create_image',
description: 'Create a new Image from an existing Disk',
parameters: (0, schemas_1.mcpInput)(schemas.createImageSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
const result = await (0, client_1.createClient)(context).images.createImage({
disk_id: params.disk_id,
label: params.label,
description: params.description
});
return JSON.stringify(result, null, 2);
})
});
// Upload an image
server.addTool({
name: 'upload_image',
description: 'Initiate an Image upload',
parameters: (0, schemas_1.mcpInput)(schemas.uploadImageSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
const result = await (0, client_1.createClient)(context).images.uploadImage({
label: params.label,
description: params.description,
region: params.region
});
return JSON.stringify(result, null, 2);
})
});
// Update an image
server.addTool({
name: 'update_image',
description: 'Update an existing Image',
parameters: (0, schemas_1.mcpInput)(schemas.updateImageSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
const { imageId, ...updateData } = params;
const result = await (0, client_1.createClient)(context).images.updateImage(imageId, updateData);
return JSON.stringify(result, null, 2);
})
});
// Delete an image
server.addTool({
name: 'delete_image',
description: 'Delete an Image',
parameters: (0, schemas_1.mcpInput)(schemas.deleteImageSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
await (0, client_1.createClient)(context).images.deleteImage(params.imageId);
return JSON.stringify({ success: true }, null, 2);
})
});
// Replicate an image
server.addTool({
name: 'replicate_image',
description: 'Replicate an Image to other regions',
parameters: (0, schemas_1.mcpInput)(schemas.replicateImageSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
const { imageId, regions } = params;
await (0, client_1.createClient)(context).images.replicateImage(imageId, { regions });
return JSON.stringify({ success: true }, null, 2);
})
});
// --- Sharegroups CRUD ---
server.addTool({
name: 'list_image_sharegroups',
description: 'List all image share groups',
parameters: (0, schemas_1.mcpInput)(schemas.listImageSharegroupsSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
const result = await (0, client_1.createClient)(context).images.getSharegroups({
page: params.page,
page_size: params.page_size
});
return JSON.stringify(result, null, 2);
})
});
server.addTool({
name: 'get_image_sharegroup',
description: 'Get details for a specific image share group',
parameters: (0, schemas_1.mcpInput)(schemas.getImageSharegroupSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
const result = await (0, client_1.createClient)(context).images.getSharegroup(params.sharegroupId);
return JSON.stringify(result, null, 2);
})
});
server.addTool({
name: 'create_image_sharegroup',
description: 'Create a new image share group',
parameters: (0, schemas_1.mcpInput)(schemas.createImageSharegroupSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
const result = await (0, client_1.createClient)(context).images.createSharegroup({
label: params.label,
description: params.description
});
return JSON.stringify(result, null, 2);
})
});
server.addTool({
name: 'update_image_sharegroup',
description: 'Update an existing image share group',
parameters: (0, schemas_1.mcpInput)(schemas.updateImageSharegroupSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
const { sharegroupId, ...updateData } = params;
const result = await (0, client_1.createClient)(context).images.updateSharegroup(sharegroupId, updateData);
return JSON.stringify(result, null, 2);
})
});
server.addTool({
name: 'delete_image_sharegroup',
description: 'Delete an image share group',
parameters: (0, schemas_1.mcpInput)(schemas.deleteImageSharegroupSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
await (0, client_1.createClient)(context).images.deleteSharegroup(params.sharegroupId);
return JSON.stringify({ success: true }, null, 2);
})
});
// --- Sharegroup Images ---
server.addTool({
name: 'list_sharegroup_images',
description: 'List shared images in a share group',
parameters: (0, schemas_1.mcpInput)(schemas.listSharegroupImagesSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
const { sharegroupId, ...paginationParams } = params;
const result = await (0, client_1.createClient)(context).images.getSharegroupImages(sharegroupId, paginationParams);
return JSON.stringify(result, null, 2);
})
});
server.addTool({
name: 'add_sharegroup_images',
description: 'Add images to a share group',
parameters: (0, schemas_1.mcpInput)(schemas.addSharegroupImagesSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
const result = await (0, client_1.createClient)(context).images.addSharegroupImages(params.sharegroupId, {
images: params.images
});
return JSON.stringify(result, null, 2);
})
});
server.addTool({
name: 'update_sharegroup_image',
description: 'Update a shared image in a share group',
parameters: (0, schemas_1.mcpInput)(schemas.updateSharegroupImageSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
const result = await (0, client_1.createClient)(context).images.updateSharegroupImage(params.sharegroupId, params.imageId);
return JSON.stringify(result, null, 2);
})
});
server.addTool({
name: 'remove_sharegroup_image',
description: 'Revoke access to a shared image in a share group',
parameters: (0, schemas_1.mcpInput)(schemas.removeSharegroupImageSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
await (0, client_1.createClient)(context).images.removeSharegroupImage(params.sharegroupId, params.imageId);
return JSON.stringify({ success: true }, null, 2);
})
});
// --- Sharegroup Members ---
server.addTool({
name: 'list_sharegroup_members',
description: 'List members in a share group',
parameters: (0, schemas_1.mcpInput)(schemas.listSharegroupMembersSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
const { sharegroupId, ...paginationParams } = params;
const result = await (0, client_1.createClient)(context).images.getSharegroupMembers(sharegroupId, paginationParams);
return JSON.stringify(result, null, 2);
})
});
server.addTool({
name: 'get_sharegroup_member',
description: 'Get a membership token for a share group',
parameters: (0, schemas_1.mcpInput)(schemas.getSharegroupMemberSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
const result = await (0, client_1.createClient)(context).images.getSharegroupMember(params.sharegroupId, params.tokenUuid);
return JSON.stringify(result, null, 2);
})
});
server.addTool({
name: 'add_sharegroup_members',
description: 'Add members to a share group',
parameters: (0, schemas_1.mcpInput)(schemas.addSharegroupMembersSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
const result = await (0, client_1.createClient)(context).images.addSharegroupMembers(params.sharegroupId, params.data || {});
return JSON.stringify(result, null, 2);
})
});
server.addTool({
name: 'update_sharegroup_member',
description: 'Update a membership token in a share group',
parameters: (0, schemas_1.mcpInput)(schemas.updateSharegroupMemberSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
const result = await (0, client_1.createClient)(context).images.updateSharegroupMember(params.sharegroupId, params.tokenUuid, params.data || {});
return JSON.stringify(result, null, 2);
})
});
server.addTool({
name: 'remove_sharegroup_member',
description: 'Revoke a membership token from a share group',
parameters: (0, schemas_1.mcpInput)(schemas.removeSharegroupMemberSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
await (0, client_1.createClient)(context).images.removeSharegroupMember(params.sharegroupId, params.tokenUuid);
return JSON.stringify({ success: true }, null, 2);
})
});
// --- Sharegroup Tokens ---
server.addTool({
name: 'list_sharegroup_tokens',
description: 'List a user\'s sharegroup tokens',
parameters: (0, schemas_1.mcpInput)(schemas.listSharegroupTokensSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
const result = await (0, client_1.createClient)(context).images.getSharegroupTokens({
page: params.page,
page_size: params.page_size
});
return JSON.stringify(result, null, 2);
})
});
server.addTool({
name: 'get_sharegroup_token',
description: 'Get details for a specific sharegroup token',
parameters: (0, schemas_1.mcpInput)(schemas.getSharegroupTokenSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
const result = await (0, client_1.createClient)(context).images.getSharegroupToken(params.tokenUuid);
return JSON.stringify(result, null, 2);
})
});
server.addTool({
name: 'create_sharegroup_token',
description: 'Create a new sharegroup token',
parameters: (0, schemas_1.mcpInput)(schemas.createSharegroupTokenSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
const result = await (0, client_1.createClient)(context).images.createSharegroupToken(params.data || {});
return JSON.stringify(result, null, 2);
})
});
server.addTool({
name: 'update_sharegroup_token',
description: 'Update an existing sharegroup token',
parameters: (0, schemas_1.mcpInput)(schemas.updateSharegroupTokenSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
const result = await (0, client_1.createClient)(context).images.updateSharegroupToken(params.tokenUuid, params.data || {});
return JSON.stringify(result, null, 2);
})
});
server.addTool({
name: 'delete_sharegroup_token',
description: 'Delete a sharegroup token',
parameters: (0, schemas_1.mcpInput)(schemas.deleteSharegroupTokenSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
await (0, client_1.createClient)(context).images.deleteSharegroupToken(params.tokenUuid);
return JSON.stringify({ success: true }, null, 2);
})
});
// --- Token Lookups ---
server.addTool({
name: 'get_token_sharegroup',
description: 'Get the share group associated with a token',
parameters: (0, schemas_1.mcpInput)(schemas.getTokenSharegroupSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
const result = await (0, client_1.createClient)(context).images.getTokenSharegroup(params.tokenUuid);
return JSON.stringify(result, null, 2);
})
});
server.addTool({
name: 'list_token_sharegroup_images',
description: 'List images available through a token\'s share group',
parameters: (0, schemas_1.mcpInput)(schemas.listTokenSharegroupImagesSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
const { tokenUuid, ...paginationParams } = params;
const result = await (0, client_1.createClient)(context).images.getTokenSharegroupImages(tokenUuid, paginationParams);
return JSON.stringify(result, null, 2);
})
});
// --- Image-to-Sharegroups Lookup ---
server.addTool({
name: 'list_image_sharegroups_by_image',
description: 'List share groups that contain a specific image',
parameters: (0, schemas_1.mcpInput)(schemas.listImageSharegroupsByImageSchema),
execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => {
const { imageId, ...paginationParams } = params;
const result = await (0, client_1.createClient)(context).images.getImageSharegroups(imageId, paginationParams);
return JSON.stringify(result, null, 2);
})
});
}
//# sourceMappingURL=tools.js.map