UNPKG

@takashito/linode-mcp-server

Version:

MCP server for Linode API

364 lines 19.1 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.registerDatabaseTools = registerDatabaseTools; const client_1 = require("../../client"); const schemas_1 = require("../common/schemas"); const schemas = __importStar(require("./schemas")); const errorHandler_1 = require("../common/errorHandler"); /** * Registers database tools with the MCP server */ function registerDatabaseTools(server) { // Engine operations server.addTool({ name: 'list_database_engines', description: 'Get a list of all available database engines', parameters: (0, schemas_1.mcpInput)(schemas.listEnginesSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).databases.getEngines(params); return JSON.stringify(result.data, null, 2); }) }); server.addTool({ name: 'get_database_engine', description: 'Get details for a specific database engine', parameters: (0, schemas_1.mcpInput)(schemas.getEngineSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).databases.getEngine(params.engineId); return JSON.stringify(result, null, 2); }) }); // Type operations server.addTool({ name: 'list_database_types', description: 'Get a list of all available database types', parameters: (0, schemas_1.mcpInput)(schemas.listTypesSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).databases.getTypes(params); return JSON.stringify(result.data, null, 2); }) }); server.addTool({ name: 'get_database_type', description: 'Get details for a specific database type', parameters: (0, schemas_1.mcpInput)(schemas.getTypeSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).databases.getType(params.typeId); return JSON.stringify(result, null, 2); }) }); // General database instances operations server.addTool({ name: 'list_database_instances', description: 'Get a list of all database instances', parameters: (0, schemas_1.mcpInput)(schemas.listDatabaseInstancesSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).databases.getDatabaseInstances(params); return JSON.stringify(result.data, null, 2); }) }); // MySQL specific operations server.addTool({ name: 'list_mysql_instances', description: 'Get a list of all MySQL database instances', parameters: (0, schemas_1.mcpInput)(schemas.listMySQLInstancesSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).databases.getMySQLInstances(params); return JSON.stringify(result.data, null, 2); }) }); server.addTool({ name: 'get_mysql_instance', description: 'Get details for a specific MySQL database instance', parameters: (0, schemas_1.mcpInput)(schemas.getMySQLInstanceSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).databases.getMySQLInstance(params.instanceId); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'create_mysql_instance', description: 'Create a new MySQL database instance', parameters: (0, schemas_1.mcpInput)(schemas.createMySQLInstanceSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).databases.createMySQLInstance(params); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'update_mysql_instance', description: 'Update an existing MySQL database instance', parameters: (0, schemas_1.mcpInput)(schemas.updateMySQLInstanceSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const { instanceId, ...data } = params; const result = await (0, client_1.createClient)(context).databases.updateMySQLInstance(instanceId, data); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'delete_mysql_instance', description: 'Delete a MySQL database instance', parameters: (0, schemas_1.mcpInput)(schemas.deleteMySQLInstanceSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { await (0, client_1.createClient)(context).databases.deleteMySQLInstance(params.instanceId); return JSON.stringify({ success: true }, null, 2); }) }); server.addTool({ name: 'get_mysql_credentials', description: 'Get credentials for a MySQL database instance', parameters: (0, schemas_1.mcpInput)(schemas.getMySQLCredentialsSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).databases.getMySQLCredentials(params.instanceId); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'reset_mysql_credentials', description: 'Reset credentials for a MySQL database instance', parameters: (0, schemas_1.mcpInput)(schemas.resetMySQLCredentialsSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).databases.resetMySQLCredentials(params.instanceId); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'get_mysql_ssl_certificate', description: 'Get the SSL certificate for a MySQL database instance', parameters: (0, schemas_1.mcpInput)(schemas.getMySQLSSLCertificateSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).databases.getMySQLSSLCertificate(params.instanceId); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'patch_mysql_instance', description: 'Apply the latest updates to a MySQL database instance', parameters: (0, schemas_1.mcpInput)(schemas.patchMySQLInstanceSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { await (0, client_1.createClient)(context).databases.patchMySQLInstance(params.instanceId); return JSON.stringify({ success: true }, null, 2); }) }); server.addTool({ name: 'suspend_mysql_instance', description: 'Suspend a MySQL database instance', parameters: (0, schemas_1.mcpInput)(schemas.suspendMySQLInstanceSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { await (0, client_1.createClient)(context).databases.suspendMySQLInstance(params.instanceId); return JSON.stringify({ success: true }, null, 2); }) }); server.addTool({ name: 'resume_mysql_instance', description: 'Resume a suspended MySQL database instance', parameters: (0, schemas_1.mcpInput)(schemas.resumeMySQLInstanceSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { await (0, client_1.createClient)(context).databases.resumeMySQLInstance(params.instanceId); return JSON.stringify({ success: true }, null, 2); }) }); // PostgreSQL specific operations server.addTool({ name: 'list_postgresql_instances', description: 'Get a list of all PostgreSQL database instances', parameters: (0, schemas_1.mcpInput)(schemas.listPostgreSQLInstancesSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).databases.getPostgreSQLInstances(params); return JSON.stringify(result.data, null, 2); }) }); server.addTool({ name: 'get_postgresql_instance', description: 'Get details for a specific PostgreSQL database instance', parameters: (0, schemas_1.mcpInput)(schemas.getPostgreSQLInstanceSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).databases.getPostgreSQLInstance(params.instanceId); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'create_postgresql_instance', description: 'Create a new PostgreSQL database instance', parameters: (0, schemas_1.mcpInput)(schemas.createPostgreSQLInstanceSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).databases.createPostgreSQLInstance(params); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'update_postgresql_instance', description: 'Update an existing PostgreSQL database instance', parameters: (0, schemas_1.mcpInput)(schemas.updatePostgreSQLInstanceSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const { instanceId, ...data } = params; const result = await (0, client_1.createClient)(context).databases.updatePostgreSQLInstance(instanceId, data); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'delete_postgresql_instance', description: 'Delete a PostgreSQL database instance', parameters: (0, schemas_1.mcpInput)(schemas.deletePostgreSQLInstanceSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { await (0, client_1.createClient)(context).databases.deletePostgreSQLInstance(params.instanceId); return JSON.stringify({ success: true }, null, 2); }) }); server.addTool({ name: 'get_postgresql_credentials', description: 'Get credentials for a PostgreSQL database instance', parameters: (0, schemas_1.mcpInput)(schemas.getPostgreSQLCredentialsSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).databases.getPostgreSQLCredentials(params.instanceId); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'reset_postgresql_credentials', description: 'Reset credentials for a PostgreSQL database instance', parameters: (0, schemas_1.mcpInput)(schemas.resetPostgreSQLCredentialsSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).databases.resetPostgreSQLCredentials(params.instanceId); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'get_postgresql_ssl_certificate', description: 'Get the SSL certificate for a PostgreSQL database instance', parameters: (0, schemas_1.mcpInput)(schemas.getPostgreSQLSSLCertificateSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).databases.getPostgreSQLSSLCertificate(params.instanceId); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'patch_postgresql_instance', description: 'Apply the latest updates to a PostgreSQL database instance', parameters: (0, schemas_1.mcpInput)(schemas.patchPostgreSQLInstanceSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { await (0, client_1.createClient)(context).databases.patchPostgreSQLInstance(params.instanceId); return JSON.stringify({ success: true }, null, 2); }) }); server.addTool({ name: 'suspend_postgresql_instance', description: 'Suspend a PostgreSQL database instance', parameters: (0, schemas_1.mcpInput)(schemas.suspendPostgreSQLInstanceSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { await (0, client_1.createClient)(context).databases.suspendPostgreSQLInstance(params.instanceId); return JSON.stringify({ success: true }, null, 2); }) }); server.addTool({ name: 'resume_postgresql_instance', description: 'Resume a suspended PostgreSQL database instance', parameters: (0, schemas_1.mcpInput)(schemas.resumePostgreSQLInstanceSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { await (0, client_1.createClient)(context).databases.resumePostgreSQLInstance(params.instanceId); return JSON.stringify({ success: true }, null, 2); }) }); // PostgreSQL Connection Pool operations server.addTool({ name: 'list_postgresql_connection_pools', description: 'List all connection pools for a PostgreSQL database instance', parameters: (0, schemas_1.mcpInput)(schemas.listPostgreSQLConnectionPoolsSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const { instanceId, page, page_size } = params; const result = await (0, client_1.createClient)(context).databases.getPostgreSQLConnectionPools(instanceId, { page, page_size }); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'get_postgresql_connection_pool', description: 'Get details for a specific connection pool of a PostgreSQL database instance', parameters: (0, schemas_1.mcpInput)(schemas.getPostgreSQLConnectionPoolSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).databases.getPostgreSQLConnectionPool(params.instanceId, params.poolName); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'create_postgresql_connection_pool', description: 'Create a new connection pool for a PostgreSQL database instance', parameters: (0, schemas_1.mcpInput)(schemas.createPostgreSQLConnectionPoolSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const { instanceId, ...data } = params; const result = await (0, client_1.createClient)(context).databases.createPostgreSQLConnectionPool(instanceId, data); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'update_postgresql_connection_pool', description: 'Update an existing connection pool for a PostgreSQL database instance', parameters: (0, schemas_1.mcpInput)(schemas.updatePostgreSQLConnectionPoolSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const { instanceId, poolName, ...data } = params; const result = await (0, client_1.createClient)(context).databases.updatePostgreSQLConnectionPool(instanceId, poolName, data); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'delete_postgresql_connection_pool', description: 'Delete a connection pool from a PostgreSQL database instance', parameters: (0, schemas_1.mcpInput)(schemas.deletePostgreSQLConnectionPoolSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { await (0, client_1.createClient)(context).databases.deletePostgreSQLConnectionPool(params.instanceId, params.poolName); return JSON.stringify({ success: true }, null, 2); }) }); // Database Config operations server.addTool({ name: 'get_mysql_config', description: 'List MySQL advanced configuration parameters', parameters: (0, schemas_1.mcpInput)(schemas.getMySQLConfigSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).databases.getMySQLConfig(); return JSON.stringify(result, null, 2); }) }); server.addTool({ name: 'get_postgresql_config', description: 'List PostgreSQL advanced configuration parameters', parameters: (0, schemas_1.mcpInput)(schemas.getPostgreSQLConfigSchema), execute: (0, errorHandler_1.withErrorHandling)(async (params, context) => { const result = await (0, client_1.createClient)(context).databases.getPostgreSQLConfig(); return JSON.stringify(result, null, 2); }) }); } //# sourceMappingURL=tools.js.map