# Architecture ```mermaid flowchart TD Client[MCP client] --> HTTP[Signal K HTTP/TLS and readonly route classification] HTTP --> Guard[Enabled / Host / Origin / MCP key / explicit native bearer] Guard --> Transport[Stateless Streamable HTTP transport] Transport --> Tools[Explicit read-only tools] Tools --> Adapter[Signal K read adapter] Adapter --> Policy[Configured prefixes and native path/source ACLs] Policy --> Public[getSelfPath / admin-only getFeatures] Tools --> Output[Field projection / redaction / bounds] Output --> Client ``` ## Modules `src/index.ts` owns the Signal K lifecycle, schema, route registration and transport disposal. It exports a CommonJS factory. Invalid configuration or a missing environment key leaves the route disabled. Stop first disables admission, then closes active transports. Existing router handlers refer to current state, so requests after stop receive 503; no private Express router structures are modified. Reconfiguration follows the host's stop/start lifecycle. `src/tools.ts` registers nine implemented tools and defines their input schemas, response envelopes and generic error boundary. Connection inventory/status use the isolated internal adapter. Full connection config, plugin config/status and error-log tools remain unregistered. A fresh MCP server is connected for each POST, following the SDK's stateless approach; state is not shared between clients. This is appropriate for snapshot diagnostics, without notification streams or resumable sessions. `src/adapter.ts` reads the public Signal K data model. Its narrowed `ReadAPI` type exposes just `getSelfPath` and `getFeatures`. It projects plugin inventory fields (`id`, `name`, `version`, `enabled`) and traverses only allowed telemetry roots. It does not receive a caller-controlled URL, file path, executable or method name. Full config/log export adapters intentionally do not exist. `src/auth.ts` isolates the native authentication/ACL bridge (since 1.1.0). It requires enabled, synchronous Signal K security hooks and constructs a fresh bearer-only authentication object per check. A request-scoped access context binds the identity, plugin lifecycle and exact self-context path/source grants. All telemetry/discovery/source tools use that context. Admin-only inventory checks run before host access and again after async reads. Non-admin server information and diagnosis omit internal provider details. The native router may be registered after startup; admission remains closed until its permission-aware classification is available. See [permission contract and tests](docs/READ-ONLY-USERS.md). `src/safety.ts` holds validation, prefix checks, constant-length hashed secret comparison and bounded safe copying. Redaction is defense in depth. It is not a substitute for field allowlists or an authorization boundary. `src/version.ts` reads the installed package version for consistent MCP and OpenAPI metadata. Development-only scripts verify a clean tarball installation and direct Signal K log access; they are not loaded by the plugin. See [server log investigation](docs/SERVER-LOGS.md). ## Decisions - Run inside Signal K to reuse its lifecycle, network listener and official data access. No additional service, hostname, certificate or port is assumed. - From 1.1.0, classify MCP routes as readonly and verify existing native bearer identities, including per-path/source ACLs; keep operational inventories admin-only. Retain the separate environment-held key and exact Host/Origin policy. Version 1.0.x uses the earlier admin-only model. - Use named tools for discoverability and small, bounded responses. No code execution tool is exposed. - Prefer supported APIs. Server-internal functions need isolated, versioned adapters and an explicit unsupported state. Published API types do not establish runtime compatibility by themselves. - Return native units, timestamps and unknown values honestly. Do not infer system health from absence of data. ## Internal provider diagnostics reference Provider diagnostics were successfully live-tested on OpenPlotter / Raspberry Pi with Signal K Server **2.31.0** and Node.js **22.23.2**, using a remote Windows MCP client over the existing authenticated HTTPS endpoint. See the [compatibility record](docs/COMPATIBILITY.md) for the completed validation. The candidate retains public API types 2.33.0 and upgrades MCP SDK to 1.32.2. The historical live result does not validate the candidate dependency set. Runtime shape detection, not an assumed package version, gates internal access. No broad server-version range is claimed. The original adapter is based on tag [v2.31.0](https://github.com/SignalK/signalk-server/tree/v2.31.0), commit `5a3c945ca3f8a0427302ca37a4ae476ee2276adc`: - [src/interfaces/providers.ts](https://github.com/SignalK/signalk-server/blob/v2.31.0/src/interfaces/providers.ts): configured connection shape; a single providers/simple element uses options.type, otherwise the first pipe element type is used. - [src/pipedproviders.ts](https://github.com/SignalK/signalk-server/blob/v2.31.0/src/pipedproviders.ts): omitted enabled means enabled. - [src/index.ts](https://github.com/SignalK/signalk-server/blob/v2.31.0/src/index.ts): getProviderStatus returns an array; type is status/error, statusType distinguishes provider/plugin; historical error fields may be absent. Source labels from upstream may be preserved, so identifier matching is not proof of local connection ownership. Only src/internal/signalK231Adapter.ts accesses app.config.settings.pipedProviders and app.getProviderStatus(). The public layer continues to use getSelfPath() and getFeatures(). Missing/malformed internals return UNSUPPORTED; limits return RESULT_TOO_LARGE. A valid empty configuration is distinct from an unavailable API. An unavailable diagnostic context never prevents the existing path-state diagnosis. ## Compatibility and release work Compiled against `@signalk/server-api` 2.33.0, MCP SDK 1.32.2 and Zod 4.6.7. The official FeatureInfo API is asynchronous and returns a plugin array. Unexpected shapes yield `UNSUPPORTED`. Tests use fixtures matching those types, plus an actual SDK client over HTTP. The operator reported successful live baseline validation on a real OpenPlotter / Signal K installation: plugin loading/enabling, the plugin MCP route, existing Signal K TLS, admin authentication and the extra key, plus remote Streamable HTTP from an external Windows client. Remote `tools/list`, `get_server_info` and `read_path("navigation.datetime")` succeeded. See [compatibility record](docs/COMPATIBILITY.md) for scope and provenance. Signal K Server 2.31.0 is the confirmed reference runtime for the existing baseline; a broader release range is not established. Provider diagnostics validation also confirmed nine tools, compatible internal adapter detection, projected connection inventory, live status with text withholding, and evidence-only fresh/missing path diagnosis ([compatibility record](docs/COMPATIBILITY.md)). Remaining release work includes broader version coverage, negative authentication cases, pre-parsed JSON, disable/re-enable behavior and additional proxy scenarios. Add internal adapters only with tests derived from that exact server source and a documented upgrade strategy. In-process execution shares Signal K's event loop. Result and traversal bounds constrain work but cannot interrupt a slow host API call. Use a deployment rate limiter if exposing the endpoint beyond a trusted network. There is no background polling, persistence or added stream subscription. ## Design references [sailingnaturali/signalk-mcp](https://github.com/sailingnaturali/signalk-mcp) demonstrates discrete tools and path discovery. [VesselSense/signalk-mcp-server](https://github.com/VesselSense/signalk-mcp-server) demonstrates compact results and flexible Signal K querying. This project adopts the ideas of discoverable tools and bounded responses, with an in-process operations focus. Its implementation is original; no code from either repository was copied. Arbitrary code execution and vessel-specific voice/navigation behavior are outside this project's scope. The native identity/ACL design was also informed by a comparison with [arodus/signalk-mcp 0.3.1](https://github.com/arodus/signalk-mcp/tree/v0.3.1), then verified against Signal K's router/security sources and real 2.31.0/2.35.1 runtime fixtures. This plugin retains a narrower, read-only diagnostic scope, the additional MCP key and its own implementation/tests. Primary interface references: [Signal K plugin documentation](https://demo.signalk.org/documentation/Developing/Plugins.html), [Signal K server API](https://github.com/SignalK/signalk-server/tree/master/packages/server-api), and the [official MCP TypeScript SDK](https://github.com/modelcontextprotocol/typescript-sdk). See `package-lock.json` for the exact dependency resolution. MIT licensed. Publication remains a separate maintainer action; see the release checklist.