laya-mcp
# laya-mcp
[Laya](https://github.com/NandhaKishorM/laya) as an **MCP server**: typed
decisions (`choice` / `score` / `noul`) with real probabilities in ~20-40 ms,
on your own machine. No LLM calls, no tokens, no API keys, 100+ languages.
Same tool interface as `jev-local`, so it is a drop-in replacement wherever
those tools are used.
## Install
```bash
pip install git+https://github.com/jerepaira/laya-mcp.git
```
This pulls `laya` (which pulls `torch`) — for NVIDIA GPU you get CUDA
support out of the box; on CPU-only machines it just runs slower
(~15 s for the first call, milliseconds after warmup).
Model weights (~2 GB) download automatically from
[HuggingFace](https://huggingface.co/convaiinnovations/laya) on first use.
## Use with your agent
**opencode** (`~/.config/opencode/opencode.json`):
```json
"mcp": {
"laya": {
"type": "local",
"command": ["laya-mcp"],
"enabled": true
}
}
```
**Claude Code** (`claude mcp add`):
```bash
claude mcp add laya -- laya-mcp
```
Any other MCP client: stdio command `laya-mcp`.
## Tools
| tool | what it does |
|---|---|
| `decide(state, questions)` | answer any set of typed questions at once |
| `classify(text, labels, instructions?)` | pick one label + confidence + scores |
| `score(text, criteria, instructions?)` | rate on an ordered scale + distribution |
| `check(state, question)` | yes/no → `P(yes)` in `[0,1]` |
Example — route a support message:
```json
classify("me cobraron dos veces, quiero la devolución",
["billing", "technical", "sales", "other"])
→ {"label": "billing", "confidence": 0.845, "scores": {...}}
```
## Config
| env | default | meaning |
|---|---|---|
| `LAYA_DEVICE` | auto (`cuda` if available, else `cpu`) | force `"cpu"` if VRAM is tight |
| `LAYA_MODEL` | auto-router per request | pin `"english"`, `"multilingual"` or `"typed-decisions"` |
Tip: Spanish text routes to the multilingual checkpoint. Pinning one model
with `LAYA_MODEL` avoids checkpoint reloads when requests mix languages.
## Accuracy notes
Out of the box it is fast and decent, not magic — wording of the question
matters a lot and thresholds should be calibrated on your own labeled
examples before trusting the probabilities. Measure, don't assume.
## Credits
Decision model by [Nandakishor M (Convai Innovations)](https://github.com/NandhaKishorM/laya),
Apache-2.0. This repo is only the MCP wrapper (MIT).
TDQS
Scored across 4 tools
decide is a generic decision engine that can handle choice and score types, which substantially overlaps with classify and score. The specialized tools add context (text vs. state), but the boundaries are not crisp, and an agent could easily misselect decide for tasks the others are designed for.
All four tool names are single lowercase verbs with no mixed conventions or inconsistent patterns. The imperative style is consistent and easy to predict, even if the verbs are somewhat generic.
Four tools is a reasonable number for a decision/classification/rating server. However, decide's broad scope makes classify, score, and check feel somewhat redundant, so the count earns slightly less than full marks.
The set covers common decision tasks: choice/classification, ordered scoring, and yes/no checking, plus the generic noul type through decide. Minor gaps exist around batch processing or clearer support for unstructured outputs, but the core decision surface appears well covered.