<p align="center">
<a href="https://three.ws"><img src="https://three.ws/three-ws-mcp-icon.svg" alt="three.ws" width="88" height="88"></a>
</p>
<h1 align="center">@three-ws/brain-mcp</h1>
<p align="center"><strong>Any model, one interface — discover LLM providers and run chat completions through the three.ws multi-provider router, from any AI agent.</strong></p>
<p align="center">
<a href="https://www.npmjs.com/package/@three-ws/brain-mcp"><img alt="npm" src="https://img.shields.io/npm/v/@three-ws/brain-mcp?logo=npm&color=cb3837"></a>
<img alt="license" src="https://img.shields.io/npm/l/@three-ws/brain-mcp?color=3b82f6">
<img alt="node" src="https://img.shields.io/node/v/@three-ws/brain-mcp?color=339933&logo=node.js">
<a href="https://registry.modelcontextprotocol.io/?q=io.github.nirholas"><img alt="MCP Registry" src="https://img.shields.io/badge/MCP%20Registry-io.github.nirholas-0ea5e9"></a>
<a href="https://three.ws"><img alt="three.ws" src="https://img.shields.io/badge/built%20by-three.ws-000"></a>
</p>
---
> A [Model Context Protocol](https://modelcontextprotocol.io) server that gives any AI assistant the three.ws **multi-provider LLM router** over stdio. Discover which models are available — Claude, the GPT-5.6 family, o3, Grok, Qwen, DeepSeek, NVIDIA Nemotron, IBM Granite, and more — and run a chat completion through whichever one fits, without wiring each vendor SDK yourself.
The router fronts every provider behind one endpoint and transparently falls back across mirrors and free tiers if the chosen model is briefly down. The free open-weight tiers (GPT-OSS 120B, NVIDIA NIM models) work with **no key**; the paid first-party flagships unlock with a three.ws API key.
## Install
```bash
npm install @three-ws/brain-mcp
```
Or run with `npx` (no install):
```bash
npx @three-ws/brain-mcp
```
## Quick start
**Claude Code**, one line:
```bash
claude mcp add brain -- npx -y @three-ws/brain-mcp
```
To unlock the paid flagships, pass your three.ws API key:
```bash
claude mcp add brain -e THREE_WS_API_KEY=sk_live_… -- npx -y @three-ws/brain-mcp
```
**Claude Desktop / Cursor** (`claude_desktop_config.json` or `mcp.json`):
```json
{
"mcpServers": {
"brain": {
"command": "npx",
"args": ["-y", "@three-ws/brain-mcp"],
"env": { "THREE_WS_API_KEY": "sk_live_…" }
}
}
}
```
Inspect the surface with the MCP Inspector:
```bash
npx -y @modelcontextprotocol/inspector npx @three-ws/brain-mcp
```
## Tools
| Tool | Type | What it does |
| ---------------- | --------- | ------------------------------------------------------------------------------------------------------------------ |
| `list_providers` | read-only | List every LLM the router can reach — key, network, tier, max output, live availability, and whether it needs auth. |
| `chat` | read-only | Run a chat completion through the chosen provider; returns the full reply, the route taken, token usage, and timing. |
Both tools read live data — the provider set and completions vary between calls, so neither is idempotent. `chat` does not mutate any platform state, so it is annotated read-only.
### Input parameters
**`list_providers`** — no parameters.
**`chat`** — `messages` (required: 1–100 turns of `{ role: "user" | "assistant", content }`, content ≤ 16,000 chars), `provider` (provider key from `list_providers`, default `gpt-oss-120b`), `system` (optional system prompt, ≤ 8,000 chars), `maxTokens` (optional, 64–16384, default 4096, clamped to the model's ceiling).
## Example
Both responses below are shape illustrations — the live provider set and generations will differ.
```jsonc
// list_providers (example response)
> {}
{
"ok": true,
"count": 34,
"available": 33,
"default_provider": "gpt-oss-120b",
"providers": [
{ "key": "gpt-oss-120b", "label": "GPT-OSS 120B", "network": "OpenAI · OpenRouter", "tier": "balanced", "maxOutput": 8192, "description": "Open-weight 120B from OpenAI. Fast, capable, free tier. Platform default.", "available": true, "requiresAuth": false },
{ "key": "claude-sonnet-5", "label": "Claude Sonnet 5", "network": "Anthropic", "tier": "balanced", "maxOutput": 16384, "description": "Near-Opus quality on coding and agentic work at Sonnet cost. Best for most tasks.", "available": true, "requiresAuth": true },
{ "key": "deepseek-r1", "label": "DeepSeek R1", "network": "DeepSeek", "tier": "reasoning", "maxOutput": 8192, "description": "Open reasoning model. Strong at math and code.", "available": true, "requiresAuth": true }
/* … */
]
}
```
```jsonc
// chat (example response)
> {
"provider": "claude-sonnet-5",
"system": "You are terse.",
"messages": [{ "role": "user", "content": "Name three Solana RPC methods." }]
}
{
"ok": true,
"provider": "claude-sonnet-5",
"model": "Claude Sonnet 5",
"network": "Anthropic",
"tier": "balanced",
"routed_via": null,
"content": "getBalance, getAccountInfo, getSignaturesForAddress.",
"usage": { "input_tokens": 24, "output_tokens": 14, "total_tokens": 38 },
"timing_ms": { "first_token": 412, "total": 980 }
}
```
`routed_via` is `null` when the requested provider answered directly; otherwise it names the mirror or free-tier route the router fell back to (so you always get an answer even if the first choice is briefly down).
> Model availability is dynamic. Always call `list_providers` first rather than hardcoding a key. The current Claude ids are `claude-fable-5`, `claude-opus-5`, `claude-sonnet-5`, `claude-opus-4-7`, `claude-sonnet-4-6`, and `claude-haiku-4-5`, but the live list is the source of truth.
## Authentication
| Model class | Needs a key? |
| ---------------------------------------------------------------------------- | --------------------------- |
| Free open-weight tiers (GPT-OSS 120B, and the NVIDIA NIM set: Nemotron 3 Super / Nemotron Super 49B / Nemotron Nano / DeepSeek V4 / Kimi K2 / Llama 4 Maverick / MiniMax M2) | No |
| Paid first-party flagships (Claude, GPT-5.6, o3, Qwen Plus, DeepSeek, …) | Yes — set `THREE_WS_API_KEY` |
Create an API key at [three.ws/dashboard/developers](https://three.ws/dashboard/developers). Without it, paid models return a sign-in error and `list_providers` flags them with `requiresAuth: true`.
## Requirements
- **Node.js >= 20.**
- Network access to `https://three.ws` (or your own `THREE_WS_BASE`).
### Environment variables
| Variable | Required | Default | Purpose |
| --------------------- | -------- | ------------------ | ---------------------------------------------------------------- |
| `THREE_WS_BASE` | no | `https://three.ws` | API base URL (override to self-host or target a preview). |
| `THREE_WS_API_KEY` | no | — | Bearer credential that unlocks the paid first-party flagships. |
| `THREE_WS_TIMEOUT_MS` | no | `120000` | Per-request timeout (completions stream server-side). |
## Errors
A failed tool call returns an MCP error result (`isError: true`) whose text is a single JSON object — `{ "ok": false, "error": "<code>", "message": "…" }`, plus `status` and `detail` on upstream rejections:
| `error` | Meaning | Recovery |
| ------- | ------- | -------- |
| `upstream_error` | The router rejected the request — `status` carries the real HTTP code: `400` (bad arguments or an unknown provider key), `401` (paid model without a valid `THREE_WS_API_KEY`), `429` (rate-limited), `502` (the model's stream failed before producing output). | Act on `status`; for `401` set a key, for an unknown key re-run `list_providers`. |
| `timeout` | No complete response within `THREE_WS_TIMEOUT_MS`. Long flagship generations can be slow — the default 120 s matches the router's own ceiling. | Retry, lower `maxTokens`, or pick a `fast`-tier provider. |
| `network_error` | The request never reached the router (DNS, offline, TLS). | Check connectivity / `THREE_WS_BASE`. |
| `bad_config` | `THREE_WS_TIMEOUT_MS` is not a positive number (thrown at startup). | Fix the env var. |
If the requested provider fails mid-flight the router transparently falls back to a mirror or free tier and the reply's `routed_via` names the route taken — you only see an error when every route is exhausted.
## Links
- Homepage: https://three.ws
- Changelog: https://three.ws/changelog
- Issues: https://github.com/nirholas/three.ws/issues
- License: Apache-2.0, see [LICENSE](./LICENSE)
---
<p align="center">
<sub>
Part of the <a href="https://three.ws">three.ws</a> SDK suite — 3D AI agents, on-chain identity, and agent payments.<br/>
<a href="https://three.ws">Website</a> · <a href="https://three.ws/changelog">Changelog</a> · <a href="https://github.com/nirholas/three.ws">GitHub</a>
</sub>
</p>
<!-- three.ws:growth -->
## Support the project
If brain-mcp saves you time, **[star it on GitHub](https://github.com/nirholas/brain-mcp)**. Stars are how other developers and AI agents find the repositories worth trusting, and they cost you one click.
Know someone who would use it? [Post on X](https://twitter.com/intent/tweet?text=brain-mcp%3A%20Any%20model%2C%20one%20interface%3A%20the%20three.ws%20multi-provider%20LLM%20router%20over%20MCP&url=https%3A%2F%2Fgithub.com%2Fnirholas%2Fbrain-mcp) · [Share on Bluesky](https://bsky.app/intent/compose?text=brain-mcp%3A%20Any%20model%2C%20one%20interface%3A%20the%20three.ws%20multi-provider%20LLM%20router%20over%20MCP%20https%3A%2F%2Fgithub.com%2Fnirholas%2Fbrain-mcp) · [Share on LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fgithub.com%2Fnirholas%2Fbrain-mcp) · [Submit to Hacker News](https://news.ycombinator.com/submitlink?u=https%3A%2F%2Fgithub.com%2Fnirholas%2Fbrain-mcp&t=brain-mcp%3A%20Any%20model%2C%20one%20interface%3A%20the%20three.ws%20multi-provider%20LLM%20router%20over%20MCP) · [Share on Reddit](https://www.reddit.com/submit?url=https%3A%2F%2Fgithub.com%2Fnirholas%2Fbrain-mcp&title=brain-mcp%3A%20Any%20model%2C%20one%20interface%3A%20the%20three.ws%20multi-provider%20LLM%20router%20over%20MCP)
## Built for AI agents too
Coding agents and LLM tooling can read this repo directly: [AGENTS.md](./AGENTS.md), [llms.txt](./llms.txt), [llms-full.txt](./llms-full.txt). Point an agent at `https://github.com/nirholas/brain-mcp` and it has the context it needs.
## More from the same author
- [All repositories by nirholas](https://github.com/nirholas/nirholas#readme): the full catalog, grouped by topic
- [three.ws](https://three.ws): the platform for 3D AI agents with Solana wallets, a skill marketplace and x402 payments
- Questions or ideas: [open an issue](https://github.com/nirholas/brain-mcp/issues) or [start a discussion](https://github.com/nirholas/brain-mcp/discussions)
## Contributors
[](https://github.com/nirholas/brain-mcp/graphs/contributors)
## Star history
[](https://www.star-history.com/#nirholas/brain-mcp&Date)
<!-- /three.ws:growth -->
<!-- three.ws:ecosystem -->
## Part of three.ws
[three.ws](https://three.ws) is a platform for 3D AI agents with Solana wallets: avatars, a skill marketplace, x402 payments and more than seventy MCP servers. `@three-ws/brain-mcp` is one package from it.
- Documentation site: https://nirholas.github.io/brain-mcp/
- npm: https://www.npmjs.com/package/@three-ws/brain-mcp
- Canonical source: https://github.com/nirholas/three.ws (this repository is a generated mirror of `packages/brain-mcp`)
- Agent-readable summary: [llms.txt](./llms.txt) and [AGENTS.md](./AGENTS.md)
- Issues and ideas: https://github.com/nirholas/brain-mcp/issues
<!-- /three.ws:ecosystem -->