- Rust 77.2%
- TypeScript 15.6%
- JavaScript 6.6%
- Nix 0.4%
- HTML 0.2%
| Filename | Latest commit message | Latest commit date |
|---|---|---|
|
|
||
| .cargo | ||
| .forgejo/workflows | ||
| client | ||
| codec | ||
| common | ||
| crypto | ||
| docs | ||
| example | ||
| files | ||
| host | ||
| mtp-webserver | ||
| src | ||
| test | ||
| transport | ||
| type-map | ||
| wasm | ||
| .gitignore | ||
| Cargo.lock | ||
| Cargo.toml | ||
| clippy.toml | ||
| create-web-release.mjs | ||
| deny.toml | ||
| example-type-maps.yaml | ||
| flake.lock | ||
| flake.nix | ||
| package.json | ||
| pnpm-lock.yaml | ||
| pnpm-workspace.yaml | ||
| README.md | ||
| renovate.json | ||
| rustfmt.toml | ||
| tsconfig.json | ||
| tsconfig.type-tests.json | ||
Methanium Transport Protocol
MTP is a modular transport protocol built on QUIC. It provides versioned type maps, a binary codec, native and browser clients, host and WebTransport server implementations, and optional cryptographic authentication and end-to-end encryption.
Security assumptions, certificate handling, authentication, cryptographic primitives, key storage, and known limitations: Security.
Area-specific guides:
- Architecture
- Connection lifecycle
- Native client
- WASM client
- Native host
- Web server
- Connector and version negotiation
- Protocol reference
- Type maps
- Error reference
- Troubleshooting
- Operations
MTPWebServer owns TCP TLS (HTTP/1.1 and HTTP/2) plus UDP QUIC (HTTP/3 and WebTransport) on one numeric port. It must not bind its UDP address and port as MTPHost: their QUIC ALPN protocols remain incompatible (h3 for the web server, native MTP for the host).
Browser SDK
The JavaScript package is mtp.
mtpexports the SDK-firstMTPClientAPI and codec helpers.mtp/rawexports generated WASM bindings for lower-level integrations.mtp/viteexports the Vite integration that builds app-specific bindings.mtp/type-mapexports generated TypeScript type-name unions.
Use the WASM client guide for installation, type-map configuration, credentials, certificate pins, requests, subscriptions, pipes, and protocol pings. Use the SDK methods before raw bindings because the raw API does not provide the wrapper's validation, persistence, timeout, logging, or lifecycle handling.
The SDK exposes crypto helpers and frame codec helpers from the main mtp export. The security guide describes the available algorithms and their limitations.
Getting Started
Add the umbrella crate with the features required by the application:
[dependencies]
mtp = { path = "..", features = ["client", "crypto"] }
Feature summary:
| Feature | Pulls in | Enables |
|---|---|---|
serde |
Crypto serialization support | Serde implementations for crypto key types |
crypto |
mtp::crypto |
AEAD, signatures, KEM, KDF, hashing, and connection authentication support |
host |
mtp::host |
Native QUIC host and version negotiation |
client |
mtp::client |
Native QUIC client connections |
transport |
mtp-transport dependency |
Low-level transport support; enabled automatically by host and client |
pipes |
Pipe support in transport, host, client, and web server | Raw and encrypted byte streams |
files |
mtp::files |
.mk keyrings and .mpkb public bundles; also enables crypto |
raw |
Raw file APIs | Legacy plaintext keyring migration APIs |
web-server |
mtp::webserver |
HTTPS server with HTTP/1.1, HTTP/2, HTTP/3, and WebTransport MTP sessions |
full-server |
Native host and web-server surface | host, web-server, crypto, and pipes together |
tls |
mtp::crypto::tls |
Development self-signed certificate generation |
insecure-tls |
Lower-level transport | Development-only certificate verification bypass, gated by MTP_INSECURE_TLS=1 |
The core modules always available from the facade are codec, common, and
type_map. Native client and host modules re-export the transport policy
types; the low-level transport crate is not exposed as mtp::transport. See the native client and native host
guides for configuration and usage. See Security for security boundaries.
Sub-crates
The mtp facade re-exports the following modules:
mtp::codec, mtp::common, mtp::type_map, mtp::crypto, mtp::host,
mtp::client, mtp::files, and mtp::webserver when their features are enabled.
Codec
The codec encodes and decodes MTP frames using Communication Types and Data Types resolved through a version-specific type map. It supports self-delimiting containers, integers, booleans, floats, strings, arrays, bytes, null values, and composable Signed<Value> and Encrypted<Value> protection wrappers. Wrap in either order to choose whether signer metadata is public or encrypted. See Type Map for mapping configuration and Connector for negotiated codecs.
Transport
The transport crate wraps QUIC with wtransport. Sender and Receiver exchange framed messages over unidirectional streams. The transport supports a persistent stream and a single-stream-per-message mode, with configurable message limits, timeouts, queues, and stream concurrency.
Certificate verification is controlled by client configuration. Use system roots or explicit certificate and SPKI pinning for production. Development self-signed and insecure modes: Security.
Host
The host crate provides MTPHost, registry-backed version negotiation, optional authentication, and MTPConnection handles. Authentication policies and the challenge-response protocol: Native Host and Security.
Client
The native client provides unauthenticated connections, authenticated login, and registration when the crypto feature is enabled. See Native Client.
The browser client uses the mtp SDK over WebTransport. See WASM Client.
Common
Common defines shared errors such as CodecError and CommunicationError, as well as protocol-level types used by the other crates.
Type Map
The type-map build script reads YAML and generates CommunicationType and DataType enums at compile time. The runtime crate provides TypeMap, Version, ID types, and the multi-version Registry when the registry feature is enabled. See Type Map.
Crypto
mtp-crypto provides AEAD encryption, Ed25519 and ML-DSA-65 signatures, X25519 plus ML-KEM-768 hybrid KEM support, HKDF, SHA-256, keyrings, composable protection envelopes, and certificate generation for development. Feature flags and security boundaries: Security.
Examples
The example/ workspace contains native client, native server, key-generation, WebTransport server, and browser client examples. The example server stores its generated development certificate and host keys locally; use the certificate pin it prints when connecting the example client.