Expand description
Kubernetes-native Rust microservice framework with telemetry, auth, and MCP built in.
§Example
use tonin::prelude::*;
#[tokio::main]
async fn main() -> tonin::Result<()> {
// Service::new installs OTLP tracing + a log subscriber.
// Add `.handler(GreeterServer::new(MyImpl))` once you have a
// tonic-generated service to bind.
Service::new("greeter").run().await
}§Re-exports
Service— builder that wires telemetry, auth, MCP, and tonic.Error— framework error type (Result<T>alias also available).State— typed shared state container for handlers.prelude— glob-import the essentials (Service,Error,State,AuthCtx,tonic::{Request, Response, Status}).mcp_expose— proc-macro attribute; auto-derive an MCP adapter from a gRPCimplblock (one tool per method).auth— JWT validation,AuthCtx,AuthLayer.telemetry— zero-config OTLP tracing + W3C TraceContext.transport— tonic/gRPC wiring (mTLS delegated to the mesh).discovery— k8s DNS resolution for peer services.mcp— MCP sidecar runtime and tool registry.
Result<T> is reachable as tonin::Result but is intentionally not
in prelude — it would shadow std::result::Result and break
macro-generated code emitting unqualified Result<T, E>.
§Sample app
Full end-to-end gRPC + MCP service: https://github.com/Rushit/tonin/tree/main/examples/greeter
§Sibling crates
tonin-core— runtime, traits, and submodules (transport,discovery,mcp,telemetry,auth,state,job). Depend on this directly for lighter builds.tonin-client— peer-service client primitives (AuthCtx, retry, breaker, header propagation) without the server framework.tonin-mcp-macros— the#[mcp_expose]proc-macro crate.tonin-build—build.rshelper wrappingtonic-buildwith tonin conventions.
§CLI
This crate also ships the tonin binary (scaffold services, run codegen,
render k8s manifests). Default features include cli so cargo install tonin installs the binary. Library consumers who don’t want the CLI’s
dep tree should pass default-features = false.
Re-exports§
pub use tonin_core as core;
Modules§
- auth
- Authentication and authorization layer.
- codegen
- tonin-codegen
- commands
- discovery
- tonin-discovery: build endpoint URLs from service names.
- job
- Background-job entry point.
- mcp
- In-process MCP listener — real wire protocol via
rmcp. - prelude
- state
- Pre-wired DB + cache connections.
- telemetry
- Zero-config OTLP tracing + W3C TraceContext propagation.
- transport
- tonin-transport: thin wrapper around tonic’s gRPC server/client.
Structs§
- Service
- Service builder. Holds name, bind address, the tonic router being assembled, the optional auth layer, and the optional in-process MCP listener config + custom spawner.
- State
- Bundle of optional connection handles. Cheap to clone — all inner types are reference-counted.
Enums§
Type Aliases§
Attribute Macros§
- main
- Placeholder for
#[tonin::main]: an attribute macro that wires the tracing subscriber + tokio runtime. Today this is just a re-export of#[tokio::main]; the dedicated proc-macro will land in a follow-up. Marks async function to be executed by the selected runtime. This macro helps set up aRuntimewithout requiring the user to use Runtime or Builder directly. - mcp_
expose