Barentswatch MCP Server
March 16, 2025 ยท View on GitHub
This is a Model Context Protocol (MCP) server for the Barentswatch AIS (Automatic Identification System) API that provides access to maritime vessel tracking data in Norwegian waters.
Features
- Real-time vessel position tracking
- Vessel details lookup by MMSI number
- Geographic area vessel search
- Vessel filtering by ship type
- Access to raw AIS data through resources
- Prompt templates for common maritime analysis tasks
Prerequisites
Before using this server, you need:
- A Barentswatch.no account
- API credentials (Client ID and Client Secret) from Barentswatch.no
- Python 3.8 or later
Setup
- Clone this repository
- Install dependencies:
pip install mcp httpx python-dotenv - Create a
.envfile with your credentials:BARENTSWATCH_USERNAME=your_username BARENTSWATCH_PASSWORD=your_password BARENTSWATCH_CLIENT_ID=your_client_id BARENTSWATCH_CLIENT_SECRET=your_client_secret
Running the Server
Development Mode
The fastest way to test and debug the server is with the MCP Inspector:
mcp dev barentswatch_server.py
Claude Desktop Integration
To install the server in Claude Desktop:
mcp install barentswatch_server.py --name "Barentswatch AIS"
Or manually add it to your claude_desktop_config.json:
{
"mcpServers": {
"barentswatch": {
"command": "python",
"args": ["/path/to/barentswatch_server.py"],
"env": {
"BARENTSWATCH_USERNAME": "your_username",
"BARENTSWATCH_PASSWORD": "your_password",
"BARENTSWATCH_CLIENT_ID": "your_client_id",
"BARENTSWATCH_CLIENT_SECRET": "your_client_secret"
}
}
}
}
Available Tools
This MCP server provides the following tools:
- get_vessel_positions: Get the latest vessel positions, optionally filtered by time
- get_vessel_details: Get detailed information about a specific vessel by MMSI
- find_vessels_in_area: Find vessels within a geographic area defined by coordinates
- search_vessels_by_type: Search for vessels of a specific type using AIS ship type codes
Available Resources
- barentswatch://ais/latest: The latest AIS data for all vessels
- barentswatch://ais/vessel/{mmsi}: Data for a specific vessel by MMSI
Available Prompts
- analyze_vessel_traffic: Template for analyzing vessel traffic in a specific area
- track_specific_vessel: Template for tracking and analyzing a specific vessel
AIS Ship Type Codes
Some common AIS ship type codes for use with the search_vessels_by_type tool:
- 30-39: Fishing vessels
- 40-49: High-speed craft
- 60-69: Passenger vessels
- 70-79: Cargo vessels
- 80-89: Tankers
Authentication
The server handles authentication with the Barentswatch API automatically. Tokens are refreshed as needed, so you don't need to manage them manually.
Rate Limiting and Usage
Please be aware of Barentswatch's rate limits and terms of service when using this MCP server. The server includes automatic token refresh but doesn't implement backoff for rate limiting.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Acknowledgments
- Data provided by The Norwegian Coastal Administration (Kystverket) through Barentswatch.no
- Built using the Model Context Protocol (MCP) for AI assistants