voyage-and-consumption-mcp-server
Version:
Voyage and consumption management server handling vessel position tracking, ETA monitoring, fuel consumption, lube oil consumption, fresh water production and weather data
53 lines • 2.63 kB
JavaScript
import { getTypesenseClient, combined_mongotools_with_grouped_category_mapping } from "../../utils/index.js";
import { logger } from "../../index.js";
// interface getTankDistributionInformationArgs {
// imo: string;
// questionNo: number;
// }
export class MongodbToolsHandler {
constructor() {
this.typesenseClient = getTypesenseClient();
}
async getVesselVoyageOperationsInformation(args) {
logger.info("getVesselVoyageOperationsInformation called", args);
try {
// Support both imo and imo_number parameters, with imo taking precedence
const imo = args.imo || args.imo_number;
if (!imo) {
throw new Error("imo is required. Only the following properties are allowed: imo, imo_number, category, question_no. Please check the tool schema for get_vessel_voyage_operations_information for the allowed properties.");
}
// Initialize database connection - support both UPPER_SNAKE_CASE and camelCase
const qaDbName = process.env.QA_DB_NAME || process.env.qaDbName || '';
const qaMongoUri = process.env.QA_MONGO_URI || process.env.qaMongoUri || '';
// Map question_no to questionNo for the helper function
const argsWithQuestionNo = {
...args,
questionNo: args.question_no
};
// Use the combined helper function for grouped category mapping
const result = await combined_mongotools_with_grouped_category_mapping(argsWithQuestionNo, [
"voyage_planning_operations",
"fuel_oil_management",
"lubricating_oil_management",
"fresh_water_management",
"environmental_emissions_compliance"
], {
"voyage_planning_operations": [31, 32, 33],
"fuel_oil_management": [34, 86],
"lubricating_oil_management": [35, 36, 104],
"fresh_water_management": [37],
"environmental_emissions_compliance": [61, 63]
}, "get_vessel_voyage_operations_information", qaDbName, qaMongoUri);
return result;
}
catch (error) {
logger.error("Error in getVesselVoyageOperationsInformation", { error });
const errorResponse = {
type: "text",
text: `Error retrieving vessel voyage operations information: ${error instanceof Error ? error.message : String(error)}`
};
return [errorResponse];
}
}
}
//# sourceMappingURL=mongofetchTools.js.map