# lm [Health: Active]

**Category:** 🗣️ Conversational AI  
**Repository:** https://github.com/houtini-ai/houtini-lm  
**GitHub Stars:** 122  
**npm Downloads (last month):** 1517  
**Views:** 7  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/lm

## Description
Connect Claude to any OpenAI-compatible LLM endpoint and offload routine work to a local model.

## Tools
Capabilities this server exposes over MCP:

- **chat** — Send a task to a local LLM - a sidekick running on the user's hardware or a configured OpenAI-compatible endpoint. It does not consume the user's Claude quota. Trades latency for tokens: local inference is typically 3-30× slower than frontier models, so delegation wins when the task is bounded and self-contained.

Good fit:
• Explain or summarise code/docs you already have in context
• Generate boilerplate, test stubs, type definitions, mock data
• Answer factual questions about languages, frameworks, APIs
• Draft commit messages, PR descriptions, comments
• Translate or reformat content (JSON↔YAML, snake_case↔camelCase)
• Brainstorm approaches before committing to one

Less good when: the task needs tool access, depends on multi-file context you have not captured, or is quick enough for you to answer directly before the round-trip completes.

Prompt tips (local models take instructions literally):
(1) Send COMPLETE context - the local LLM cannot read files.
(2) Be explicit about output format ("respond as a JSON array", "return only the function").
(3) Specific system persona beats generic - "Senior TypeScript dev" not "helpful assistant".
(4) State constraints - "no preamble", "reference line numbers", "max 5 bullets".
(5) Leave max_tokens UNSET - the server sizes the budget from the model's real context window. Tiny caps like 256 waste the model: reasoning burns the budget before any visible output.

Routing picks the best loaded model automatically. Call `discover` to see what is loaded and, after the first real call, its measured speed. The footer shows cumulative tokens offloaded.
- **custom_prompt** — Structured analysis via the local LLM with explicit system/context/instruction separation. The 3-part format prevents context bleed in smaller models - the local LLM acknowledges the context in a fake assistant turn before receiving the instruction.

Good fit when prompt structure matters:
• Code review - paste full source, ask for bugs/improvements
• Comparison - paste two implementations, ask which is better and why
• Refactoring suggestions - paste code, ask for a cleaner version
• Content analysis - paste text, ask for structure/tone/issues
• Any task where separating context from instruction improves clarity

Field guidance (each has a job - keep them focused):
• system: persona + constraints, under 30 words. "Expert Python developer focused on performance and correctness."
• context: COMPLETE data - full source, full logs, full text. Never truncate.
• instruction: exactly what to produce, under 50 words. Specify format: "Return a JSON array of {line, issue, fix}."

Review the output before acting on it - local model capability varies.
- **code_task** — Send a code-specific task to the local LLM, wrapped with an optimised code-review system prompt. Temperature is locked low (0.2 or the routed model's hint) for deterministic output.

Good fit:
• Explain what a function/class does
• Find bugs or suggest improvements
• Generate unit tests or type definitions for existing code
• Add error handling, logging, or validation
• Convert between languages or patterns

For best results:
• Provide COMPLETE source - the local LLM cannot read files.
• Include imports and type definitions so the model has full context.
• Be specific: "Write 3 Jest tests for the error paths in fetchUser" beats "Write tests".
• Set the language field - it shapes the system prompt and improves accuracy.

Verify generated code compiles, handles edge cases, and follows project conventions before committing.
- **code_task_files** — Like code_task, but the local LLM reads files directly from disk - source never passes through the MCP client's context window. Use when reviewing multiple files or a single large file.

How it works:
• Provide absolute paths. Relative paths are rejected.
• Files are read in parallel (Promise.allSettled) - one unreadable file does not sink the call.
• Files are concatenated with `=== filename ===` headers and sent to the same code-review pipeline as code_task.
• Read failures are surfaced inline with the reason so the LLM can still reason about the rest.
• Pre-flight prefill estimate: if measured per-model data shows the input would exceed the MCP client's ~60s request timeout during prompt processing, the call is refused early with a diagnostic instead of hanging. Split or trim when this fires.

Good fit:
• Reviewing related files together (module + its tests, client + server pair)
• Auditing a single large file too big to paste comfortably
• Any code_task where keeping source out of the Claude context window matters

Size guidance: on slow hardware (< 25 tok/s generation), keep total input under ~8,000 tokens (~32,000 chars) to stay safely under the client timeout. Faster hardware handles much more - the pre-flight estimator adapts once you've done a few calls and real per-model timings are in the SQLite cache.

Same review discipline as code_task - verify the output before acting on it.
- **discover** — Check whether the local LLM is online and what model is loaded. Returns model name, context window size, response latency, and cumulative session stats (tokens offloaded so far). Call this if you are unsure whether the local LLM is available before delegating work. Fast - typically responds in under 1 second, or returns an offline status within 5 seconds if the host is unreachable.
- **list_models** — List all models on the local LLM server - both loaded (ready) and available (downloaded but not active). Shows rich metadata for each model: type (llm/vlm/embeddings), architecture, quantization, context window, and a capability profile describing what the model is best at. Use this to understand which models are available and suggest switching when a different model would suit the task better.
- **embed** — Generate text embeddings via the local LLM server. Requires an embedding model to be loaded (e.g. Nomic Embed). Returns a vector representation of the input text for semantic search, similarity comparison, or RAG pipelines. Uses the OpenAI-compatible /v1/embeddings endpoint.
- **stats** — Show user stats: tokens offloaded, calls made, per-model performance - for the current session AND lifetime (persisted in SQLite at ~/.houtini-lm/model-cache.db). Unlike `discover` which includes the model catalog, `stats` returns just the numbers in a compact markdown table - cheap to call repeatedly to see the 💰 offloaded counter climb. Useful for quantifying how much work the local model is genuinely doing, and for noticing when a model's reasoning-token ratio is drifting.

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "lm": {
    "command": "npx",
    "args": ["-y","@houtini/lm"],
    "env": {
      "HOUTINI_LM_ENDPOINT_URL": "",
      "HOUTINI_LM_API_KEY": "",
      "HOUTINI_LM_MODEL": "",
      "HOUTINI_LM_SERIALISE": ""
    }
  }
}
```

**Requires environment variables:** `HOUTINI_LM_ENDPOINT_URL`, `HOUTINI_LM_API_KEY`, `HOUTINI_LM_MODEL`, `HOUTINI_LM_SERIALISE` — the values above are empty placeholders; fill in real credentials before running (see the repository for what each one is for).

## Documentation

## What lm does

lm connects an MCP client to a local LLM or another OpenAI-compatible endpoint. Supported deployment patterns include LM Studio, Ollama, vLLM, SGLang, llama.cpp, LiteLLM routers, OpenRouter, OpenAI, DeepSeek, Groq, Cerebras, and similar compatible services. The main use case is handing off bounded work while the primary AI platform retains responsibility for planning, tool use, and review.

Delegated requests do not use the user's Claude quota. A local endpoint can also keep source code on the user's hardware. Cloud endpoints remain available when local inference is unavailable or a different model is preferred.

## How it works

Install the package as an MCP server and configure the endpoint URL when the default is not suitable. The server discovers available models, routes requests to a loaded model, and records model timings and usage statistics in a SQLite cache at `~/.houtini-lm/model-cache.db`.

`chat` handles self-contained prompts. `custom_prompt` separates a short system role, complete context, and an explicit instruction, which helps prevent context and instruction mixing in smaller models. `code_task` applies a code-oriented review prompt and uses low temperature for more deterministic output. `code_task_files` reads absolute file paths in parallel, adds filename headers, and sends the collected content through the same code pipeline without placing the source in the MCP client's context window.

The file-based tool reports individual read failures and estimates prompt-processing time before sending a request. Calls that are likely to exceed the MCP client's roughly 60-second request timeout are refused early. `discover` reports availability, the loaded model, context size, latency, and session totals; `list_models` describes loaded and downloaded models; `stats` shows session and lifetime usage; and `embed` calls the endpoint's OpenAI-compatible embeddings API.

## Setup and configuration

Node.js 22.5 or newer is required. With LM Studio on its default local address, Claude Code can register the server with:

```bash
claude mcp add houtini-lm -- npx -y @houtini/lm
```

For another endpoint, set `HOUTINI_LM_ENDPOINT_URL`. Endpoints requiring authentication can use `HOUTINI_LM_API_KEY`, and `HOUTINI_LM_MODEL` can pin a model. `HOUTINI_LM_SERIALISE=0` is available in configurations where serialized requests should be disabled.

An OpenAI-compatible endpoint is required. An embedding model must be loaded before using `embed`. For file reviews, provide absolute paths. Complete source, imports, type definitions, output formats, and explicit constraints generally produce better results; avoid small `max_tokens` limits because reasoning can consume the available budget before visible output.

## Tools and capabilities

- `chat`: Send a bounded task to the routed model.
- `custom_prompt`: Provide separate system, context, and instruction fields.
- `code_task`: Review or transform supplied source with a code-focused prompt.
- `code_task_files`: Review one or more files directly from disk.
- `discover`: Check endpoint availability and inspect the loaded model.
- `list_models`: View model types, architectures, quantization, context windows, and capability profiles.
- `embed`: Generate vectors for semantic search, similarity comparison, or RAG pipelines.
- `stats`: Display session and lifetime token, call, and per-model performance data.

## Limitations and notes

Local inference is commonly 3–30 times slower than frontier-model inference, so short tasks may take longer than answering directly. The delegated model cannot read files unless `code_task_files` is used or the relevant content is included in the prompt. File-review inputs should stay below roughly 8,000 tokens on hardware generating under 25 tokens per second; the estimator adapts after measured calls are cached.

Model quality varies, so generated code and review findings should be checked for compilation, edge cases, and project conventions before use. `embed` depends on an available embedding model, and `code_task_files` rejects relative paths.

_Full upstream README: https://allmcps.com/mcp/lm/readme_

