litert-lm
Rust wrapper around LiteRT-LM providing MCP and OpenAI-compatible interfaces. Auto-downloads platform binary, manages process pools, exposes model operations as tools.
Install
As a Binary (MCP Server)
As a Library
[]
= "0.2"
Usage
A) MCP Server (Binary)
Run as an MCP server to expose LiteRT-LM as tools for AI assistants like Claude Desktop.
Stdio Transport (Claude Desktop, Cursor)
Claude Desktop config (~/Library/Application Support/Claude/claude_desktop_config.json):
SSE Transport (HTTP)
MCP Features
Tools:
list_models- List downloaded or available modelspull_model- Download a model with real-time progressremove_model- Delete a downloaded modelrun_completion- Generate text completionscheck_download_progress- Query download status
Resources:
litert://downloads/{model} - Subscribe to live download progress for any model in the registry
B) Rust Library
Use litert-lm directly in your Rust code for model inference.
use ;
async
Advanced: Progress Tracking
use ;
async
Streaming Responses
use ;
use StreamExt;
async
OpenAI-Compatible API
Run an OpenAI-compatible server:
Architecture
- Auto-download: Fetches platform-specific lit binary on first run
- Process pools: Multi-model support with per-model process isolation
- Streaming: Character-level streaming with GPU/CPU fallback
- MCP: Resource subscriptions with real download progress tracking
- OpenAI API: SSE streaming for compatibility
Available Models
# List all available models in registry
# List downloaded models only
Some models require a Hugging Face token. Set via environment variable or flag:
Testing
See tests/mcp-tests/ for comprehensive MCP integration tests:
License
MIT