Skip to main content
Glama
README.md
# Laya-MLX MCP

[laya-mlx](https://github.com/mizorewww/laya-mlx) を **MCP** 経由で使う薄いサーバーです。  
文章生成はしません。`choice` / `score` / `noul` の typed decision だけ返します。

**必要環境:** Apple Silicon(macOS arm64)、Python 3.11+

## ツール

| ツール | 内容 |
|---|---|
| `laya_status` | ロード状態・既定モデル |
| `laya_load` | チェックポイントを事前ロード |
| `laya_predict` | 状態+質問 JSON で判定 |

既定モデルは `aac6fef/laya-multilingual-mlx`(日本語向け)。  
変更は環境変数 `LAYA_MLX_MODEL` / `LAYA_MLX_DTYPE`。

## Cursor への入れ方

推奨(Homebrew の mlx が入っていても安全): `scripts/run-mcp.sh` を叩く。

`~/.cursor/mcp.json`(またはプロジェクトの `.cursor/mcp.json`)に追加:

```json
{
  "mcpServers": {
    "laya-mlx": {
      "command": "/絶対パス/laya-mlx-mcp/scripts/run-mcp.sh"
    }
  }
}
```

例: [`examples/cursor-mcp.json`](examples/cursor-mcp.json)

GitHub クローン後の最短手順:

```bash
gh repo clone Blackphi6/laya-mlx-mcp
cd laya-mlx-mcp
uv sync
chmod +x scripts/run-mcp.sh
# mcp.json の command を scripts/run-mcp.sh の絶対パスにする
```

Cursor を再起動(または MCP を再読込)すると `laya_predict` などが使えます。  
初回の `laya_load` / `laya_predict` で Hugging Face から重みを取得します。

## ローカル開発

```bash
cd laya-mlx-mcp
uv sync --extra dev
uv run pytest -q
uv run laya-mlx-mcp   # stdio MCP(ホストから起動する想定)
```

手動で判定だけ試す例(`laya-mlx-mcp` と同じ dylib 修正を通す):

```bash
uv run python -c '
from laya_mlx_mcp.dyld_fix import ensure_wheel_mlx_dylib
ensure_wheel_mlx_dylib()
from laya_mlx_mcp.runtime import predict
import json
print(json.dumps(predict(
  "二重請求です。返金してください。",
  {
    "department": {
      "type": "choice",
      "instructions": "どの部署が対応すべきか?",
      "criteria": ["billing", "technical", "sales"],
    },
    "refund": {
      "type": "noul",
      "instructions": "返金を求めているか?",
    },
  },
), ensure_ascii=False, indent=2))
'
```

Homebrew の `mlx` が入っていると、pip の mlx wheel と `libmlx.dylib` が衝突することがあります。MCP のエントリポイントは自動で wheel 側を優先します。

## ライセンス・帰属

- この MCP ラッパー: Apache-2.0
- 推論本体: [mizorewww/laya-mlx](https://github.com/mizorewww/laya-mlx)(Apache-2.0)
- 元モデル: Convai Innovations / upstream Laya

TDQS

A3.9/5.0

Scored across 3 tools

Disambiguation5/5

Each tool has a clearly distinct purpose: status reports environment state, load prepares a checkpoint, and predict runs inference. There is no functional overlap between any pair.

Naming Consistency5/5

All tools follow a uniform laya_ prefix with a concise verb suffix (status, load, predict), using consistent snake_case throughout. The pattern is predictable and easy to extend.

Tool Count5/5

Three tools form a tight, well-scoped set for model serving: check status, load a model, and run predictions. No tool feels extraneous, and the count is sufficient for the domain.

Completeness4/5

The core lifecycle of loading and using a model is covered, including a status check for runtime awareness. A minor gap is the lack of an explicit unload or model listing operation, but these are not essential for the stated purpose.

Maintenance

ActivityMaintained
ResponsivenessNo issues