voyage-and-consumption-mcp-server
v1.0.3
Published
Voyage and consumption management server handling vessel position tracking, ETA monitoring, fuel consumption, lube oil consumption, fresh water production and weather data
Readme
Voyage and Consumption MCP Server
A TypeScript-based server for handling voyage and consumption operations, vessel position tracking, and weather data management.
Features
- Document parsing and processing
- Casefile management
- Vendor search and contact information
- Purchase requisition handling
- Expense tracking
- Budget management
- Typesense integration for search
- MongoDB integration for data storage
Prerequisites
- Node.js (v18 or higher)
- MongoDB
- Typesense
- OpenAI API key
- LlamaParse API key
- Perplexity API key
Configuration
You can configure the server in three ways:
1. Environment-Specific Configuration Files
The server now supports environment-specific configuration files. Create a file named .env.{environment} where {environment} matches your NODE_ENV value:
.env.development # Used when NODE_ENV=development (default)
.env.production # Used when NODE_ENV=production
.env.staging # Used when NODE_ENV=staging
.env # Fallback if no environment-specific file is foundTo use a specific environment:
NODE_ENV=production node dist/index.jsSee the env.production.example file for a template of production environment variables.
2. Environment Variables (.env file)
Create a .env file in the root directory:
MONGO_URI=mongodb://localhost:27017
DB_NAME=mcp_voyage
TYPESENSE_HOST=localhost
TYPESENSE_PORT=8108
TYPESENSE_PROTOCOL=http
TYPESENSE_API_KEY=your_typesense_api_key
OPENAI_API_KEY=your_openai_api_key
LLAMA_API_KEY=your_llama_api_key
VENDOR_MODEL=gpt-4
S3_API_TOKEN=your_s3_api_token
S3_GENERATE_HTML_URL=your_s3_generate_html_url
LLAMA_PARSE_URL=your_llama_parse_url
PERPLEXITY_API_KEY=your_perplexity_api_key
GOOGLE_CLIENT_ID=your_google_client_id
GOOGLE_CLIENT_SECRET=your_google_client_secret
GOOGLE_REDIRECT_URI=your_google_redirect_uri
GOOGLE_API_KEY=your_google_api_key
GOOGLE_SEARCH_ENGINE_ID=your_google_search_engine_id
COHERE_API_KEY=your_cohere_api_key
COMPANY_NAME=your_company_name
# API Configuration
SNAPSHOT_URL=https://dev-api.siya.com/v1.0/vessel-info/qna-snapshot
JWT_TOKEN=your_jwt_token_here3. Command Line Arguments
Command line arguments will override values from the .env file:
node dist/index.js \
--mongo-uri mongodb://localhost:27017 \
--db-name mcp_voyage \
--typesense-host localhost \
--typesense-port 8108 \
--typesense-protocol http \
--typesense-api-key your_api_key \
--openai-api-key your_openai_key \
--llama-api-key your_llama_key \
--vendor-model gpt-4 \
--s3-api-token your_s3_token \
--perplexity-api-key your_perplexity_key \
--company-name your_company_nameAvailable Command Line Arguments
| Argument | Environment Variable | Default | Description |
|----------|---------------------|---------|-------------|
| --mongo-uri | MONGO_URI | mongodb://localhost:27017 | MongoDB connection URI |
| --db-name | DB_NAME | mcp_voyage | MongoDB database name |
| --typesense-host | TYPESENSE_HOST | localhost | Typesense server host |
| --typesense-port | TYPESENSE_PORT | 8108 | Typesense server port |
| --typesense-protocol | TYPESENSE_PROTOCOL | http | Typesense protocol (http/https) |
| --typesense-api-key | TYPESENSE_API_KEY | (empty) | Typesense API key |
| --openai-api-key | OPENAI_API_KEY | (empty) | OpenAI API key |
| --llama-api-key | LLAMA_API_KEY | (empty) | LlamaParse API key |
| --vendor-model | VENDOR_MODEL | gpt-4 | Default LLM model |
| --s3-api-token | S3_API_TOKEN | (empty) | S3 API token |
| --s3-generate-html-url | S3_GENERATE_HTML_URL | (empty) | S3 HTML generation URL |
| --llama-parse-url | LLAMA_PARSE_URL | (empty) | LlamaParse service URL |
| --perplexity-api-key | PERPLEXITY_API_KEY | (empty) | Perplexity API key |
| --google-client-id | GOOGLE_CLIENT_ID | (empty) | Google OAuth client ID |
| --google-client-secret | GOOGLE_CLIENT_SECRET | (empty) | Google OAuth client secret |
| --google-redirect-uri | GOOGLE_REDIRECT_URI | (empty) | Google OAuth redirect URI |
| --google-api-key | GOOGLE_API_KEY | (empty) | Google API key |
| --google-search-engine-id | GOOGLE_SEARCH_ENGINE_ID | (empty) | Google Custom Search Engine ID |
| --cohere-api-key | COHERE_API_KEY | (empty) | Cohere API key |
| --company-name | COMPANY_NAME | (required) | Company name (mandatory) |
| --snapshot-url | SNAPSHOT_URL | https://dev-api.siya.com/v1.0/vessel-info/qna-snapshot | API endpoint for vessel QnA snapshots |
| --jwt-token | JWT_TOKEN | (default dev token) | JWT token for API authentication |
Installation
- Clone the repository:
git clone https://github.com/yourusername/voyage_and_consumption_mcp_server.git
cd voyage_and_consumption_mcp_server- Install dependencies:
npm install- Build the project:
npm run build- Start the server:
npm startDevelopment
For development with hot reload:
npm run devTesting
Test the server with MCP Inspector:
npm testMCP Tools and Resources
Document Tools
parse_document_link: Parse documents from URLs or local fileswrite_casefile_data: Create and update casefilesretrieve_casefile_data: Search and retrieve casefilesget_live_position_from_navtor: Get vessel live position and ETAget_live_weather_by_coordinates: Get weather data for coordinatesget_complete_vessel_budget_data: Get comprehensive vessel budget information
Vendor Tools
find_relevant_vendors: Search for vendors by name, service, or locationget_vendor_contact_details: Retrieve vendor contact information
Search Tools
google_search: Perform Google searchesuniversal_voyage_search: Advanced voyage search with filterssmart_consumption_search: Advanced consumption search with filterssmart_expense_search: Advanced expense search with filtersvessel_info_search: Search for vessel informationmongodb_find: Direct MongoDB queries
Voyage Management Tools
get_vessel_eta_cargo_activity: Get vessel ETA and cargo activity detailsget_voyage_details_from_shippalm: Get voyage details from Shippalmget_fleet_eta_cargo_activity: Get fleet ETA and cargo activityget_vessel_fuel_consumption_rob: Get vessel fuel consumption and ROBget_fresh_water_status: Get fresh water production statusget_charter_party_compliance_status: Get charter party compliance statusget_fleet_vessels_cii_rating: Get fleet CII rating
Project Structure
src/
├── tools/
│ ├── documentTools.ts # Document processing and casefile management
│ ├── vesselPositionTools.ts # Vessel position and weather management
│ ├── searchTools.ts # Search functionality
│ ├── vendorTools.ts # Vendor management
│ └── index.ts # Main tool handler
├── utils/
│ ├── config.ts # Configuration management with CLI support
│ ├── logger.ts # Logging utilities
│ ├── mongodb.ts # MongoDB client
│ ├── typesense.ts # Typesense client
│ └── llm.ts # LLM integration
├── types/
│ └── index.ts # TypeScript type definitions
└── index.ts # Main application entry pointKey Features
Document Processing
- Parse documents from URLs or local files
- Generate markdown and JSON outputs
- Support for various document formats
Casefile Management
- Create and update casefiles
- Track casefile status and importance
- Manage casefile pages and indexes
- Generate casefile URLs
Vendor Management
- Search for vendors by name, service, and location
- Retrieve vendor contact information
- Store and update vendor data
Vessel Data
- Track vessel positions
- Monitor fuel consumption
- Manage budgets
- Link data to vessels by IMO
Search Integration
- Full-text search using Typesense
- Vector search for semantic matching
- Filtering and pagination support
Error Handling
The application implements comprehensive error handling:
- Input validation
- Database operation error handling
- API integration error handling
- Proper error logging
- User-friendly error messages
Logging
Logging is implemented using Winston that:
- Logs to console with timestamps
- Includes different log levels (debug, info, error)
- Provides detailed error information
- Supports structured logging
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
