UNPKG

mcp-vessel-accounts

Version:

MCP server for vessel account management including EyeShare API integration, vessel expenses, and purchase orders

87 lines 3.43 kB
import { logger } from "../utils/logger.js"; import * as fs from 'fs'; import * as path from 'path'; import { fileURLToPath } from 'url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); export class ResourceHandler { constructor(server) { this.server = server; } // List of available resources getResourceList() { return [ { uri: "committed-cost://basic-processor", name: "Basic PO Processor Script", description: "Python script for basic purchase order and vessel expenses integration", mimeType: "text/x-python" }, { uri: "committed-cost://eyeshare-extractor", name: "EyeShare ID Extractor Script", description: "Python script to extract unique EyeShare IDs from PO expenses report", mimeType: "text/x-python" }, { uri: "committed-cost://po-lines-processor", name: "PO Lines Processor Script", description: "Python script for comprehensive PO lines data processing and integration", mimeType: "text/x-python" }, { uri: "committed-cost://cost-calculator", name: "Committed Cost Calculator Script", description: "Python script for advanced committed cost calculations with quantity analysis", mimeType: "text/x-python" } ]; } async handleReadResource(uri) { try { logger.info("Reading resource", { uri }); const parsedUri = new URL(uri); const resourceType = parsedUri.hostname; const identifier = parsedUri.pathname.substring(1); // remove leading '/' switch (parsedUri.protocol) { case "committed-cost:": return await this.handleCommittedCostResource(resourceType, uri); default: throw new Error(`Unsupported resource protocol: ${parsedUri.protocol}`); } } catch (error) { logger.error(`Error reading resource ${uri}:`, error); throw error; } } async handleCommittedCostResource(resourceType, uri) { const scriptFiles = { "basic-processor": "basic_processor.py", "eyeshare-extractor": "eyeshare_extractor.py", "po-lines-processor": "po_lines_processor.py", "cost-calculator": "committed_cost_calculator.py" }; const scriptFile = scriptFiles[resourceType]; if (!scriptFile) { throw new Error(`Unknown committed cost resource type: ${resourceType}`); } const scriptPath = path.join(__dirname, 'scripts', scriptFile); try { const scriptContent = fs.readFileSync(scriptPath, 'utf-8'); return { contents: [ { uri: uri, text: scriptContent, mimeType: "text/x-python" } ] }; } catch (error) { logger.error(`Error reading script file ${scriptPath}:`, error); throw new Error(`Failed to read script file: ${scriptFile}`); } } } //# sourceMappingURL=index.js.map