UNPKG

@takashito/linode-mcp-server

Version:

MCP server for Linode API

78 lines 3.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.VERSION = void 0; exports.startServer = startServer; const fastmcp_1 = require("fastmcp"); const tools_1 = require("./tools"); exports.VERSION = '0.2.4'; /** * Creates and starts a Linode MCP Server * @param options Server configuration options * @returns Configured and running MCP server instance */ async function startServer(options) { console.error('Starting Linode MCP server...'); try { // Initialize FastMCP server const server = new fastmcp_1.FastMCP({ name: 'linode-mcp-server', version: exports.VERSION, authenticate: async (request) => { return { headers: request.headers }; } }); // Save token in server options server.options.token = options.token; console.error('Server initialized successfully'); // Register tools with direct client access (only enabled categories) try { console.error(`Registering tool categories: ${options.enabledCategories?.join(', ') || 'all'}`); (0, tools_1.registerAllTools)(server, options.enabledCategories); // Show debugging info console.error(`Successfully registered tools`); } catch (error) { console.error(`Failed to register tools: ${error instanceof Error ? error.message : String(error)}`); throw error; } // Start the server with the specified transport const transport = options.transport || 'stdio'; console.error(`Starting server with transport: ${transport}`); if (transport === 'http') { const port = options.port || 8080; const host = options.host || '127.0.0.1'; const endpoint = (options.endpoint || '/mcp'); console.error(`Starting HTTP server on ${host}:${port}${endpoint}`); server.start({ transportType: 'httpStream', httpStream: { port, endpoint } }); } else if (transport === 'sse') { const port = options.port || 3000; const host = options.host || '127.0.0.1'; const endpoint = (options.endpoint || '/sse'); console.error(`Starting SSE server on ${host}:${port}${endpoint}`); server.start({ transportType: 'sse', sse: { port, endpoint } }); } else { // Default to stdio console.error('Starting stdio server'); server.start({ transportType: 'stdio' }); } console.error('Server started successfully'); return server; } catch (error) { console.error(`Failed to initialize MCP server: ${error instanceof Error ? error.message : String(error)}`); throw error; } } //# sourceMappingURL=server.js.map