UNPKG

crew-management-mcp-server

Version:

Crew management server handling crew records, certifications, scheduling, payroll, and vessel assignments with ERP access for data extraction

341 lines (340 loc) 8.33 kB
import { TextContent, ImageContent, EmbeddedResource } from "@modelcontextprotocol/sdk/types.js"; import { ObjectId } from "mongodb"; export interface ToolArguments { session_id?: string; imo?: string; user_id?: string; questionNo?: string; query?: string; crewId?: string; vesselId?: string; vesselName?: string; employeeId?: string; firstName?: string; lastName?: string; rank?: string; department?: string; status?: string; nationality?: string; certificationType?: string; certificationStatus?: string; contractStatus?: string; start_date?: string; end_date?: string; startDate?: string; endDate?: string; dateFrom?: string; dateTo?: string; daysAgo?: number; lookbackHours?: number; lookback_hours?: number; joiningDate_range?: { start_date?: string; end_date?: string; }; contractExpiry_range?: { start_date?: string; end_date?: string; }; certificateExpiry_range?: { start_date?: string; end_date?: string; }; min_importance?: number; page_size?: number; pagination?: number; num_results?: number; filters?: Record<string, any>; sort_by?: string; sort_order?: string; max_results?: number; limit?: number; skip?: number; per_page?: number; collection?: string; projection?: Record<string, any>; group?: string; period?: string; year?: number; query_keyword?: string; tag?: string; category?: string; operation?: string; query_by?: string; filter_by?: string; crew_id?: string[]; seafarer_id?: string | string[]; required_fields?: string; vessel_imo?: string; imoNumber?: string; sql_query?: string; select_fields?: string; distinct?: boolean; where_conditions?: string; group_by?: string; having?: string; order_by?: string; limit_results?: number; get_latest_records?: boolean; expiry_within_days?: number; status_filter?: string; include_vessel_requirements?: boolean; casefile_url?: string; casefileName?: string; casefileSummary?: string; currentStatus?: string; importance?: number; role?: string; summary?: string; topic?: string; facts?: string; detailed_report?: string; links?: string[]; tags?: string[]; mailId?: string; document_link?: string; download_path?: string; json_output?: string; md_output?: string; parsing_instruction?: string; format?: string; extract_only?: boolean; delete_downloads?: boolean; } export interface CrewMember { _id?: ObjectId; employeeId: string; firstName: string; lastName: string; fullName: string; rank: string; department: string; nationality: string; dateOfBirth: Date; joiningDate: Date; contractStartDate: Date; contractEndDate: Date; status: 'ACTIVE' | 'ON_LEAVE' | 'TERMINATED' | 'RETIRED'; vesselAssignment?: { vesselId: string; vesselName: string; imo: string; assignedDate: Date; }; contactInfo: { email?: string; phone?: string; address?: string; emergencyContact?: { name: string; relationship: string; phone: string; }; }; createdAt: Date; updatedAt: Date; } export interface CrewCertification { _id?: ObjectId; crewId: string; employeeId: string; certificationType: string; certificateNumber: string; issuingAuthority: string; issueDate: Date; expiryDate: Date; status: 'VALID' | 'EXPIRED' | 'SUSPENDED' | 'REVOKED'; documentUrl?: string; createdAt: Date; updatedAt: Date; } export interface VesselInfo { imo: string; name: string; vesselType?: string; flag?: string; } export interface CrewSchedule { _id?: ObjectId; crewId: string; employeeId: string; vesselId: string; vesselName: string; imo: string; joiningDate: Date; expectedSignOffDate: Date; actualSignOffDate?: Date; contractDuration: number; status: 'SCHEDULED' | 'ONBOARD' | 'SIGNED_OFF' | 'CANCELLED'; rank: string; department: string; createdAt: Date; updatedAt: Date; } export interface PayrollRecord { _id?: ObjectId; crewId: string; employeeId: string; payPeriod: { startDate: Date; endDate: Date; }; basicSalary: number; allowances: { overtime?: number; bonus?: number; other?: number; }; deductions: { tax?: number; insurance?: number; other?: number; }; totalEarnings: number; currency: string; status: 'DRAFT' | 'PROCESSED' | 'PAID'; vesselId?: string; createdAt: Date; updatedAt: Date; } export type ToolResponse = Array<TextContent | ImageContent | EmbeddedResource>; export interface ServerConfig { serverName: string; serverVersion: string; capabilities: { resources: { read: boolean; list: boolean; templates: boolean; }; tools: { list: boolean; call: boolean; }; prompts: { list: boolean; get: boolean; }; }; } export interface CrewDocument { _id?: ObjectId; crewId: string; employeeId: string; vesselId: string | null; imo: string; vesselName: string | null; documentType: string; documentName: string; documentUrl?: string; status: string; summary?: string; importance: number; category: string; createdAt: Date; updatedAt: Date; tags?: string[]; } export interface TypesenseDocument { id: string; crewId: string; employeeId: string; vesselId: string | null; imo: string; vesselName: string | null; fullName: string; rank: string; department: string; nationality: string; status: string; contractStatus?: string; joiningDate: Date; contractEndDate: Date; createdAt: Date; updatedAt: Date; tags?: string[]; importance_score?: number; embedding?: number[]; embedding_text?: string; } export interface SearchResult { found: number; out_of: number; page: number; hits: any[]; } export interface Config { mongoUri: string; mongoDbName: string; typesenseHost: string; typesensePort: number; typesenseProtocol: string; typesenseApiKey: string; openaiApiKey: string; llamaApiKey: string; vendorModel: string; s3ApiToken: string; s3GenerateHtmlUrl: string; perplexityApiKey: string; googleSearchApiKey: string; googleSearchEngineId: string; baseUrl?: string; } export interface ImoValidationResult { isValid: boolean; errorMessage?: string; } export interface FilteringStatistics { totalHits: number; filteredHits: number; unauthorizedImos: Array<{ field: string; value: any; }>; processingTimeMs: number; } export interface TypesenseFilteringResult { filteredHits: any[]; filteringStats: FilteringStatistics; } export interface CompanyImoConfig { companyName: string; companyDbUri: string; companyDbName: string; imoNumbers: string[]; } export interface CrewFilteringContext { companyName: string; companyImos: string[]; shouldBypassFiltering: boolean; } export interface CrewDataWithIMO { CREW_CODE?: string; SEAFARER_NAME?: string; CURRENT_RANK_NAME?: string; VESSEL_NAME?: string; IMO_NUMBER?: string | number; ONBOARD_SAILING_STATUS?: string; SIGN_ON_DATE?: Date | string; CONTRACT_END_DATE?: Date | string; NATIONALITY_NAME?: string; [key: string]: any; } export interface ImoFieldInfo { fieldName: string; value: any; fullPath?: string; } export interface UnauthorizedImoResult { hasUnauthorizedImo: boolean; imoField?: string; imoValue?: any; fullPath?: string; } export type ToolFilteringCategory = 'pre-validation' | 'post-filtering' | 'no-filtering'; export interface ToolFilteringConfig { toolName: string; category: ToolFilteringCategory; requiresImoValidation: boolean; description: string; }