SignalK MCP Server
Enables AI agents to access SignalK marine data with 90-96% token reduction by executing JavaScript code in V8 isolates for client-side filtering and processing.
README
SignalK MCP Server
A Model Context Protocol (MCP) server that provides AI agents with efficient access to SignalK marine data using code execution in V8 isolates. This approach reduces token usage by 90-96% compared to traditional MCP tools.
🚀 Version 1.0.6: Now using code execution engine for massive token savings! See CHANGELOG.md for details.
Why Code Execution?
Traditional MCP tools return ALL data to the AI, consuming massive amounts of tokens. This server uses V8 isolates (like Cloudflare Workers) to let AI agents run JavaScript code that filters data before returning it.
Token Savings:
- Vessel state queries: 94% reduction (2,000 → 120 tokens)
- AIS target filtering: 95% reduction (10,000 → 500 tokens)
- Multi-call workflows: 97% reduction (13,000 → 300 tokens)
Quick Start
Installation
# Via npx (recommended)
npx signalk-mcp-server
# Or install globally
npm install -g signalk-mcp-server
Claude Desktop Configuration
Add to your Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json on macOS):
{
"mcpServers": {
"signalk": {
"command": "npx",
"args": ["signalk-mcp-server"],
"env": {
"SIGNALK_HOST": "localhost",
"SIGNALK_PORT": "3000",
"SIGNALK_TLS": "false"
}
}
}
}
Basic Usage
AI Agent Query: "What's my vessel's position and the 3 closest AIS targets?"
Code Execution (Automatic):
(async () => {
// Get vessel position
const vessel = await getVesselState();
const position = vessel.data["navigation.position"]?.value;
// Get AIS targets and filter in isolate
const ais = await getAisTargets({ pageSize: 50 });
const closest = ais.targets.slice(0, 3);
return JSON.stringify({ position, closest });
})()
// Returns: ~300 tokens (97% savings vs legacy tools!)
Features
Code Execution Engine
- V8 Isolate Sandbox: Secure JavaScript execution
- Client-side Filtering: Process data before returning to AI
- Multiple API Calls: Combine operations in one execution
- 90-96% Token Savings: Massive reduction in context window usage
- Sub-100ms Overhead: Fast execution with memory/timeout limits
Available SDK Functions
When using execute_code, these functions are available. IMPORTANT: ALL functions are async and MUST be awaited:
// Vessel data
const vessel = await getVesselState();
// AIS targets (with pagination and optional distance filter)
const ais = await getAisTargets({ page: 1, pageSize: 50, maxDistance: 5000 });
// System alarms
const alarms = await getActiveAlarms();
// Discover available data paths
const paths = await listAvailablePaths();
// Get specific path value (both string and object syntax work)
const speed = await getPathValue("navigation.speedOverGround");
const heading = await getPathValue({ path: "navigation.headingTrue" });
// Connection status - ALSO requires await!
const status = await getConnectionStatus();
Real-time Marine Data
- Vessel position, heading, speed, wind
- AIS target tracking with distance calculations
- System notifications and alarms
- Dynamic SignalK path discovery
- Connection health monitoring
Configuration
Environment Variables
# SignalK Connection (Required)
SIGNALK_HOST=localhost # SignalK server hostname/IP
SIGNALK_PORT=3000 # SignalK server port
SIGNALK_TLS=false # Use WSS/HTTPS (true/false)
# Execution Mode (Optional)
EXECUTION_MODE=code # code (default) | tools (legacy) | hybrid
# Optional Settings
SERVER_NAME=signalk-mcp-server
SERVER_VERSION=1.0.6
Execution Modes
| Mode | Description | Use Case |
|---|---|---|
| code (default) | V8 isolate execution only | Production use, maximum efficiency |
| tools | Legacy MCP tools | Backward compatibility |
| hybrid | Both approaches available | Migration period |
Examples
Example 1: Filtered Vessel Data
Query: "Get my vessel name and position"
Code:
(async () => {
const vessel = await getVesselState();
return JSON.stringify({
name: vessel.data.name?.value,
position: vessel.data["navigation.position"]?.value
});
})()
Result: ~200 tokens (vs 2,000 with legacy tools)
Example 2: Nearby Vessels
Query: "Show vessels within 1 nautical mile"
Code:
(async () => {
const ais = await getAisTargets({ pageSize: 50 });
// Filter in isolate - huge savings!
const nearby = ais.targets.filter(t =>
t.distanceMeters && t.distanceMeters < 1852
);
return JSON.stringify({
total: ais.count,
nearby: nearby.length,
vessels: nearby.slice(0, 5)
});
})()
Result: ~300 tokens (vs 10,000 with legacy tools)
Example 3: Critical Alarms Only
Query: "Any critical alarms?"
Code:
(async () => {
const alarms = await getActiveAlarms();
const critical = alarms.alarms.filter(a =>
a.state === "alarm" || a.state === "emergency"
);
return JSON.stringify({
hasCritical: critical.length > 0,
count: critical.length,
details: critical
});
})()
Result: ~100 tokens (vs 1,000 with legacy tools)
Example 4: Multi-Call Workflow
Query: "Give me a situation report"
Code:
(async () => {
// All calls in ONE execution!
const vessel = await getVesselState();
const ais = await getAisTargets({ pageSize: 50 });
const alarms = await getActiveAlarms();
// Process everything in isolate
const closeVessels = ais.targets.filter(t =>
t.distanceMeters && t.distanceMeters < 1852
).length;
const criticalAlarms = alarms.alarms.filter(a =>
a.state === "alarm" || a.state === "emergency"
).length;
return JSON.stringify({
position: vessel.data["navigation.position"]?.value,
speed: vessel.data["navigation.speedOverGround"]?.value,
vesselsNearby: closeVessels,
criticalAlarms: criticalAlarms
});
})()
Result: ~300 tokens (vs 13,000 with 3 separate tool calls!)
Development
Prerequisites
- Node.js 18.0.0 or higher
- Access to a SignalK server
Setup
# Clone repository
git clone <repository-url>
cd signalk-mcp-server
# Install dependencies
npm install
# Build
npm run build
# Run tests
npm run test:unit
# Run in development mode
npm run dev
Testing
# Unit tests (fast)
npm run test:unit
# Integration tests (requires live SignalK server)
npm run test:e2e
# Full CI pipeline
npm run ci
Architecture
Code Execution Flow
AI Agent
↓
execute_code tool
↓
V8 Isolate Sandbox (isolated-vm)
↓
SignalK SDK Functions (all async, must await)
↓
SignalK Binding Layer (RPC-style)
↓
SignalK Client (HTTP REST API)
↓
SignalK Server
Note: HTTP-only mode ensures fresh data on every request. WebSocket code is preserved for future streaming support.
Key Components
- Isolate Sandbox (
src/execution-engine/isolate-sandbox.ts): Secure V8 isolate execution - SignalK Binding (
src/bindings/signalk-binding.ts): RPC-style method invocation - SDK Generator (
src/sdk/generator.ts): Auto-generates SDK from tool definitions - SignalK Client (
src/signalk-client.ts): HTTP/WebSocket client for SignalK
Security
- Complete Isolation: No access to Node.js globals
- Memory Limits: 128MB per execution
- Timeout Protection: 30s maximum execution time
- No Credential Exposure: SignalK auth handled by binding layer
- Read-Only: No write operations to SignalK server
Migration from 1.x
Breaking Changes
Version 1.0.6 changes the default mode from hybrid to code. Legacy tools are no longer available by default.
Backward Compatibility
To use legacy tools, set the execution mode:
{
"mcpServers": {
"signalk": {
"env": {
"EXECUTION_MODE": "tools"
}
}
}
}
Migration Guide
See TOOL-MIGRATION-GUIDE.md for complete migration examples.
Before (Legacy):
Tool: get_vessel_state
Returns: All vessel data (~2000 tokens)
After (Code):
(async () => {
const vessel = await getVesselState();
return JSON.stringify({
name: vessel.data.name?.value,
position: vessel.data["navigation.position"]?.value
});
})()
// Returns: ~200 tokens
Troubleshooting
Connection Issues
Check connection status (note: await is required):
(async () => {
const status = await getConnectionStatus(); // await is required!
return JSON.stringify(status);
})()
Legacy Mode
If you need legacy tools temporarily:
EXECUTION_MODE=tools npx signalk-mcp-server
Debug Mode
Enable verbose logging:
DEBUG=true
LOG_LEVEL=debug
Contributing
Contributions welcome! Please see CONTRIBUTING.md for guidelines.
License
MIT License - see LICENSE for details.
Resources
- SignalK Documentation
- Model Context Protocol
- CHANGELOG.md - Version history and migration guide
- TOOL-MIGRATION-GUIDE.md - Detailed migration examples
- Claude Desktop MCP Docs
Credits
Built with:
- isolated-vm - V8 isolate execution
- @modelcontextprotocol/sdk - MCP TypeScript SDK
- SignalK community for the excellent marine data protocol
🚢 Happy sailing with AI-powered marine data!
推荐服务器
Baidu Map
百度地图核心API现已全面兼容MCP协议,是国内首家兼容MCP协议的地图服务商。
Playwright MCP Server
一个模型上下文协议服务器,它使大型语言模型能够通过结构化的可访问性快照与网页进行交互,而无需视觉模型或屏幕截图。
Magic Component Platform (MCP)
一个由人工智能驱动的工具,可以从自然语言描述生成现代化的用户界面组件,并与流行的集成开发环境(IDE)集成,从而简化用户界面开发流程。
Audiense Insights MCP Server
通过模型上下文协议启用与 Audiense Insights 账户的交互,从而促进营销洞察和受众数据的提取和分析,包括人口统计信息、行为和影响者互动。
VeyraX
一个单一的 MCP 工具,连接你所有喜爱的工具:Gmail、日历以及其他 40 多个工具。
graphlit-mcp-server
模型上下文协议 (MCP) 服务器实现了 MCP 客户端与 Graphlit 服务之间的集成。 除了网络爬取之外,还可以将任何内容(从 Slack 到 Gmail 再到播客订阅源)导入到 Graphlit 项目中,然后从 MCP 客户端检索相关内容。
Kagi MCP Server
一个 MCP 服务器,集成了 Kagi 搜索功能和 Claude AI,使 Claude 能够在回答需要最新信息的问题时执行实时网络搜索。
e2b-mcp-server
使用 MCP 通过 e2b 运行代码。
Neon MCP Server
用于与 Neon 管理 API 和数据库交互的 MCP 服务器
Exa MCP Server
模型上下文协议(MCP)服务器允许像 Claude 这样的 AI 助手使用 Exa AI 搜索 API 进行网络搜索。这种设置允许 AI 模型以安全和受控的方式获取实时的网络信息。