UNPKG

@takashito/linode-mcp-server

Version:

MCP server for Linode API

489 lines 24.4 kB
"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.registerNetworkingTools = registerNetworkingTools; const client_1 = require("../../client"); const schemas_1 = require("../common/schemas"); const schemas = __importStar(require("./schemas")); const errorHandler_1 = require("../common/errorHandler"); function registerNetworkingTools(server) { // IP Address operations server.addTool({ name: 'list_ip_addresses', description: 'list all IP addresses', parameters: (0, schemas_1.mcpInput)(schemas.getIPAddressesSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.getIPAddresses(); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'get_ip_address', description: 'Get details for a specific IP address', parameters: (0, schemas_1.mcpInput)(schemas.getIPAddressSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.getIPAddress(params.address); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'update_ip_address', description: 'Update reverse DNS for an IP address', parameters: (0, schemas_1.mcpInput)(schemas.updateIPSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.updateIPAddress(params.address, { rdns: params.rdns }); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'allocate_ip', description: 'Allocate a new IP address', parameters: (0, schemas_1.mcpInput)(schemas.allocateIPSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.allocateIPAddress(params); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'share_ips', description: 'Share IP addresses between Linodes', parameters: (0, schemas_1.mcpInput)(schemas.shareIPsSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.shareIPAddresses(params); return JSON.stringify(result, null, 2); }) }); // IPv6 operations server.addTool({ name: 'list_ipv6_ranges', description: 'List all IPv6 ranges', parameters: (0, schemas_1.mcpInput)(schemas.getIPv6RangesSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.getIPv6Ranges(); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'get_ipv6_range', description: 'Get a specific IPv6 range', parameters: (0, schemas_1.mcpInput)(schemas.getIPv6RangeSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.getIPv6Range(params.range); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'list_ipv6_pools', description: 'List all IPv6 pools', parameters: (0, schemas_1.mcpInput)(schemas.getIPv6PoolsSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.getIPv6Pools(); return JSON.stringify(result, null, 2); }) }); // Firewall operations server.addTool({ name: 'list_firewalls', description: 'List all firewalls', parameters: (0, schemas_1.mcpInput)(schemas.getFirewallsSchema), 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).networking.getFirewalls(paginationParams); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'get_firewall', description: 'Get details for a specific firewall', parameters: (0, schemas_1.mcpInput)(schemas.getFirewallSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.getFirewall(params.id); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'create_firewall', description: 'Create a new firewall', parameters: (0, schemas_1.mcpInput)(schemas.createFirewallSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { // Create FirewallRequest with correct structure const firewall = { label: params.label, rules: { inbound_policy: params.rules?.inbound_policy || 'DROP', outbound_policy: params.rules?.outbound_policy || 'ACCEPT', inbound: params.rules?.inbound || [], outbound: params.rules?.outbound || [] } }; // Add optional fields if provided if (params.tags) { firewall.tags = params.tags; } if (params.devices) { firewall.devices = params.devices; } const result = await (0, client_1.createClient)(context).networking.createFirewall(firewall); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'update_firewall', description: 'Update a firewall', parameters: (0, schemas_1.mcpInput)(schemas.updateFirewallSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const { id, ...updateData } = params; const result = await (0, client_1.createClient)(context).networking.updateFirewall(id, updateData); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'delete_firewall', description: 'Delete a firewall', parameters: (0, schemas_1.mcpInput)(schemas.deleteFirewallSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.deleteFirewall(params.id); return JSON.stringify(result, null, 2); }) }); // Firewall rules operations server.addTool({ name: 'list_firewall_rules', description: 'List all rules for a specific firewall', parameters: (0, schemas_1.mcpInput)(schemas.getFirewallRulesSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.getFirewallRules(params.firewallId); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'update_firewall_rules', description: 'Update rules for a specific firewall', parameters: (0, schemas_1.mcpInput)(schemas.updateFirewallRulesSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const { firewallId, ...ruleData } = params; const result = await (0, client_1.createClient)(context).networking.updateFirewallRules(firewallId, ruleData); return JSON.stringify(result, null, 2); }) }); // Firewall device operations server.addTool({ name: 'list_firewall_devices', description: 'List all devices for a specific firewall', parameters: (0, schemas_1.mcpInput)(schemas.getFirewallDevicesSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const { firewallId, page, page_size } = params; // The client doesn't accept pagination for this endpoint based on the interface const result = await (0, client_1.createClient)(context).networking.getFirewallDevices(firewallId); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'create_firewall_device', description: 'Create a new device for a specific firewall', parameters: (0, schemas_1.mcpInput)(schemas.createFirewallDeviceSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const { firewallId, ...deviceData } = params; const result = await (0, client_1.createClient)(context).networking.createFirewallDevice(firewallId, deviceData); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'delete_firewall_device', description: 'Delete a device from a specific firewall', parameters: (0, schemas_1.mcpInput)(schemas.deleteFirewallDeviceSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.deleteFirewallDevice(params.firewallId, params.deviceId); return JSON.stringify(result, null, 2); }) }); // Get a specific firewall device server.addTool({ name: 'get_firewall_device', description: 'Get a specific device for a firewall', parameters: (0, schemas_1.mcpInput)(schemas.getFirewallDeviceSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.getFirewallDevice(params.firewallId, params.deviceId); return JSON.stringify(result, null, 2); }) }); // Firewall history operations server.addTool({ name: 'list_firewall_history', description: 'List firewall rule versions', parameters: (0, schemas_1.mcpInput)(schemas.listFirewallHistorySchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const { firewallId, page, page_size } = params; const result = await (0, client_1.createClient)(context).networking.getFirewallHistory(firewallId, { page, page_size }); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'get_firewall_rule_version', description: 'Get a specific firewall rule version', parameters: (0, schemas_1.mcpInput)(schemas.getFirewallRuleVersionSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.getFirewallRuleVersion(params.firewallId, params.version); return JSON.stringify(result, null, 2); }) }); // Firewall settings operations server.addTool({ name: 'get_firewall_settings', description: 'List default firewalls settings', parameters: (0, schemas_1.mcpInput)(schemas.getFirewallSettingsSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.getFirewallSettings(); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'update_firewall_settings', description: 'Update default firewalls settings', parameters: (0, schemas_1.mcpInput)(schemas.updateFirewallSettingsSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.updateFirewallSettings(params.settings); return JSON.stringify(result, null, 2); }) }); // Firewall template operations server.addTool({ name: 'list_firewall_templates', description: 'List firewall templates', parameters: (0, schemas_1.mcpInput)(schemas.listFirewallTemplatesSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.getFirewallTemplates(); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'get_firewall_template', description: 'Get a firewall template by slug', parameters: (0, schemas_1.mcpInput)(schemas.getFirewallTemplateSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.getFirewallTemplate(params.slug); return JSON.stringify(result, null, 2); }) }); // IP assignment operations server.addTool({ name: 'assign_ips', description: 'Assign IP addresses to Linodes', parameters: (0, schemas_1.mcpInput)(schemas.assignIPsSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.assignIPs({ assignments: params.assignments }); return JSON.stringify(result, null, 2); }) }); // IPv4 operations server.addTool({ name: 'assign_ipv4_addresses', description: 'Assign IPv4 addresses to Linodes', parameters: (0, schemas_1.mcpInput)(schemas.assignIPv4AddressesSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.assignIPv4Addresses({ assignments: params.assignments }); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'share_ipv4_addresses', description: 'Configure IPv4 address sharing', parameters: (0, schemas_1.mcpInput)(schemas.shareIPv4AddressesSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.shareIPv4Addresses({ ips: params.ips, linode_id: params.linode_id }); return JSON.stringify(result, null, 2); }) }); // IPv6 range operations server.addTool({ name: 'create_ipv6_range', description: 'Create an IPv6 range', parameters: (0, schemas_1.mcpInput)(schemas.createIPv6RangeSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.createIPv6Range({ linode_id: params.linode_id, prefix_length: params.prefix_length }); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'delete_ipv6_range', description: 'Delete an IPv6 range', parameters: (0, schemas_1.mcpInput)(schemas.deleteIPv6RangeSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.deleteIPv6Range(params.range); return JSON.stringify(result, null, 2); }) }); // VLAN operations server.addTool({ name: 'delete_vlan', description: 'Delete a VLAN', parameters: (0, schemas_1.mcpInput)(schemas.deleteVLANSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.deleteVLAN(params.regionId, params.label); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'list_vlans', description: 'List all VLANs', parameters: (0, schemas_1.mcpInput)(schemas.getVLANsSchema), 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).networking.getVLANs(paginationParams); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'get_vlan', description: 'Get a specific VLAN', parameters: (0, schemas_1.mcpInput)(schemas.getVLANSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.getVLAN(params.regionId, params.label); return JSON.stringify(result, null, 2); }) }); // Network Transfer Prices operations server.addTool({ name: 'list_network_transfer_prices', description: 'List network transfer prices', parameters: (0, schemas_1.mcpInput)(schemas.listNetworkTransferPricesSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.getNetworkTransferPrices(); return JSON.stringify(result, null, 2); }) }); // Linode Interface operations server.addTool({ name: 'list_linode_interfaces', description: 'List all interfaces for a Linode', parameters: (0, schemas_1.mcpInput)(schemas.listLinodeInterfacesSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.getLinodeInterfaces(params.linodeId); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'get_linode_interface', description: 'Get a specific interface for a Linode', parameters: (0, schemas_1.mcpInput)(schemas.getLinodeInterfaceSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.getLinodeInterface(params.linodeId, params.interfaceId); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'create_linode_interface', description: 'Add an interface to a Linode', parameters: (0, schemas_1.mcpInput)(schemas.createLinodeInterfaceSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const { linodeId, ...interfaceData } = params; const result = await (0, client_1.createClient)(context).networking.createLinodeInterface(linodeId, interfaceData); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'update_linode_interface', description: 'Update an interface for a Linode', parameters: (0, schemas_1.mcpInput)(schemas.updateLinodeInterfaceSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const { linodeId, interfaceId, ...interfaceData } = params; const result = await (0, client_1.createClient)(context).networking.updateLinodeInterface(linodeId, interfaceId, interfaceData); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'delete_linode_interface', description: 'Delete an interface from a Linode', parameters: (0, schemas_1.mcpInput)(schemas.deleteLinodeInterfaceSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.deleteLinodeInterface(params.linodeId, params.interfaceId); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'list_linode_interface_history', description: 'List a Linode\'s network interface history', parameters: (0, schemas_1.mcpInput)(schemas.listLinodeInterfaceHistorySchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const { linodeId, page, page_size } = params; const result = await (0, client_1.createClient)(context).networking.getLinodeInterfaceHistory(linodeId, { page, page_size }); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'get_linode_interface_settings', description: 'List interface settings for a Linode', parameters: (0, schemas_1.mcpInput)(schemas.getLinodeInterfaceSettingsSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.getLinodeInterfaceSettings(params.linodeId); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'update_linode_interface_settings', description: 'Update interface settings for a Linode', parameters: (0, schemas_1.mcpInput)(schemas.updateLinodeInterfaceSettingsSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const { linodeId, settings } = params; const result = await (0, client_1.createClient)(context).networking.updateLinodeInterfaceSettings(linodeId, settings); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'list_linode_interface_firewalls', description: 'List firewalls for a Linode interface', parameters: (0, schemas_1.mcpInput)(schemas.listLinodeInterfaceFirewallsSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.getLinodeInterfaceFirewalls(params.linodeId, params.interfaceId); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'upgrade_linode_interfaces', description: 'Upgrade a Linode to use the new interfaces', parameters: (0, schemas_1.mcpInput)(schemas.upgradeLinodeInterfacesSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).networking.upgradeLinodeInterfaces(params.linodeId); return JSON.stringify(result, null, 2); }) }); } //# sourceMappingURL=tools.js.map