AI Router
AI Router is a Python stdio MCP server. Install the mcp-ai-router package from PyPI, run the ai-router CLI, and connect any MCP client with "command": "ai-router" and "args": ["serve"].
It automates authenticated Gemini, ChatGPT, Claude, DeepSeek, and Kimi web sessions through CloakBrowser — no API keys, but you do need provider web accounts and a one-time CLI login.
| Name | |
|---|---|
| PyPI / pipx | mcp-ai-router |
| CLI command | ai-router |
| GitHub | scriptkid23/ai-router |
Quick start
pipx install mcp-ai-router # 1. install
ai-router browser login # 2. log in (opens browser windows)
ai-router browser status # 3. expect gemini/chatgpt/claude/deepseek/kimi: logged_in
Add MCP config (see Connect MCP client), reload your client, then verify:
Ask your agent: "Call list_providers, then ask Gemini to reply with exactly: router working"
Requirements
| Tool | Version |
|---|---|
| Python | 3.11+ |
| pipx | latest |
| Disk + network | ~200 MB free for first browser download |
Tested on macOS, Linux, and Windows. No Poetry, Node.js, or repo clone required for normal stdio MCP use.
Provider accounts: valid Gemini, ChatGPT, Claude, DeepSeek, and/or Kimi web accounts (free tiers work). Login is manual via the browser UI.
Install
python3 -m pip install --user pipx # use py -m pip on Windows if needed
python3 -m pipx ensurepath
# open a new terminal
pipx install mcp-ai-router
See pipx installation docs if the commands above fail. On Unix, pipx ensurepath usually adds ~/.local/bin to your shell PATH.
Verify:
ai-router --version
ai-router --help
Upgrade later:
pipx upgrade mcp-ai-router
Uninstall:
pipx uninstall mcp-ai-router
# optional manual cleanup:
# rm -rf ~/.ai-router ~/.cloakbrowser
Login (one-time)
ai-router browser login # all available providers
ai-router browser login --provider gemini
ai-router browser login --provider chatgpt
ai-router browser login --provider claude
ai-router browser login --provider deepseek
ai-router browser login --provider kimi
- Visible browser windows open (one per provider being configured).
- Log in with your provider account in each window.
- Close all browser windows when done — this saves the session to disk.
Sessions are stored in ~/.ai-router/profile/. Logging in to one provider only is fine; use ai-router browser status to check.
ai-router browser status
# gemini: logged_in
# chatgpt: logged_in
# claude: logged_in
# deepseek: logged_in
CloakBrowser download (first use)
pipx installdoes not download the browser. The firstbrowser loginorasktriggers a one-time download of a CloakBrowser-managed Chromium binary (~200 MB) to~/.cloakbrowser/. You do not needplaywright installor a separate Chrome install — automation uses the CloakBrowser binary, not your local Chrome app.
Connect MCP client
Works with any MCP client that supports stdio — Cursor, Claude Code, Claude Desktop, and others.
Cursor — ~/.cursor/mcp.json or project .cursor/mcp.json:
{
"mcpServers": {
"ai-router": {
"type": "stdio",
"command": "ai-router",
"args": ["serve"]
}
}
}
Claude Code — ~/.claude/settings.json:
{
"mcpServers": {
"ai-router": {
"command": "ai-router",
"args": ["serve"]
}
}
}
Claude Desktop — MCP config file for your OS (Anthropic docs); same command / args.
The client spawns ai-router serve (stdio, default). No separate terminal, no Node.js.
If "command": "ai-router" fails
GUI apps often use a different PATH than your terminal. Use the absolute path from:
command -v ai-router # macOS/Linux
where ai-router # Windows
{
"mcpServers": {
"ai-router": {
"type": "stdio",
"command": "/absolute/path/to/ai-router",
"args": ["serve"]
}
}
}
Use a full absolute path in JSON — do not use ~ (most clients do not expand it).
Reload MCP in your client after saving.
MCP tools
| Tool | Description |
|---|---|
ask(prompt, provider?) |
Send a prompt; default provider is Gemini. Set provider to "chatgpt", "claude", "deepseek", or "kimi". |
ask_multi(prompt, providers?, strategy?) |
Fan out to multiple providers in parallel (strategy: all, first, longest). |
list_providers() |
List providers and status. |
session_status(provider?) |
Check login state without opening a chat. |
Login is CLI only — run ai-router browser login manually; there is no MCP login tool.
Conversation behavior: each ask opens a new provider web chat. Follow-up context is not preserved across calls. Your MCP client's thread and the provider's web chat are separate.
Concurrency: one MCP server process handles requests through a page queue. Concurrent ask calls to the same provider may return BROWSER_BUSY — wait and retry. ask_multi fans out across providers in parallel within one server.
CLI reference
ai-router --version
ai-router serve [--transport stdio|http] [--host 127.0.0.1] [--port 8087]
ai-router browser login [--provider gemini|chatgpt|claude|deepseek|kimi]
ai-router browser status [--provider gemini|chatgpt|claude|deepseek|kimi]
| Transport | Use case |
|---|---|
stdio (default) |
MCP clients — "args": ["serve"] |
http |
Local debugging only — see below |
Config (optional)
Create ~/.ai-router/config.yaml. Values merge with built-in defaults:
default_provider: gemini
host: 127.0.0.1
port: 8087
answer_timeout_s: 120
profile_dir: ~/.ai-router/profile
providers:
gemini:
url: https://gemini.google.com/app
chatgpt:
url: https://chatgpt.com/
claude:
url: https://claude.ai/new
deepseek:
url: https://chat.deepseek.com/
kimi:
url: https://www.kimi.com/?chat_enter_method=new_chat
Precedence: environment variables override YAML; YAML overrides defaults.
| Variable | Default | Description |
|---|---|---|
AI_ROUTER_PROFILE_DIR |
~/.ai-router/profile |
Browser profile directory |
AI_ROUTER_DEFAULT_PROVIDER |
gemini |
Default provider for ask |
AI_ROUTER_HOST |
127.0.0.1 |
HTTP bind address |
AI_ROUTER_PORT |
8087 |
HTTP port |
AI_ROUTER_ANSWER_TIMEOUT_S |
120 |
Per-request timeout (seconds) |
AI_ROUTER_DEEPSEEK_ANSWER_TIMEOUT_S |
600 |
DeepSeek per-request timeout (seconds; supports long thinking runs) |
AI_ROUTER_KIMI_ANSWER_TIMEOUT_S |
600 |
Kimi per-request timeout (seconds; supports long thinking runs) |
Troubleshooting
| Problem | Fix |
|---|---|
pipx: command not found |
Use python3 -m pipx |
ai-router: command not found |
Run pipx ensurepath, open a new terminal |
MCP client cannot find ai-router |
Use absolute path in "command" |
pipx install mcp-ai-router fails |
Check Python ≥ 3.11 and https://pypi.org/project/mcp-ai-router/ |
gemini: logged_out / NOT_LOGGED_IN |
Run ai-router browser login |
Slow first login or first ask |
CloakBrowser downloading ~200 MB, or cold browser start |
| Browser does not open | Needs network + disk; requires cloakbrowser ≥ 0.4.4 |
BROWSER_BUSY |
Another request is in progress — wait and retry |
| Profile lock / browser errors | Only one MCP server per profile; restart client to clear stale processes |
| Need HTTP debug | ai-router serve --transport http |
HTTP debug (advanced)
Not needed for stdio MCP. Run the server in a terminal, then bridge with Node.js:
ai-router serve --transport http
{
"mcpServers": {
"ai-router": {
"command": "npx",
"args": ["-y", "mcp-remote@latest", "http://127.0.0.1:8087/mcp"]
}
}
}
HTTP binds to localhost only and has no authentication — do not expose it beyond your machine.
Development
git clone https://github.com/scriptkid23/ai-router.git
cd ai-router
poetry install
poetry run pytest -v
poetry run ruff check src tests
poetry run ai-router serve --transport http
Smoke-test a wheel (macOS/Linux example):
poetry build
pipx install --force dist/mcp_ai_router-*.whl
mkdir -p /tmp/ai-router-smoke && cd /tmp/ai-router-smoke
ai-router --help && ai-router --version && ai-router browser status
Security
- Prompts are sent to Gemini, ChatGPT, Claude, DeepSeek, and Kimi web UIs — provider privacy and terms apply. Review each provider's terms; web automation may violate some account policies.
~/.ai-router/profile/holds live session cookies — treat like a password. Deleting it logs you out locally.- Logs may be written to
~/.ai-router/logs/and stderr. - HTTP debug mode binds to
127.0.0.1with no auth — localhost only.
License
MIT — see LICENSE.
Metadata
Release files for mcp-ai-router 0.1.9
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| mcp_ai_router-0.1.9.tar.gz | 39.5 kB | Without provenance | Details for mcp_ai_router-0.1.9.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| mcp_ai_router-0.1.9-py3-none-any.whl | Python 3 | none | any | Details for mcp_ai_router-0.1.9-py3-none-any.whl |
Total release size: 99.9 kB
Release files / mcp_ai_router-0.1.9.tar.gz
| Download URL | mcp_ai_router-0.1.9.tar.gz |
|---|---|
| Size | 39.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a678d3a69cc7452fccdbbb191ac7686035f5351717189e80915bd7eb6cd4160a
|
|
BLAKE2b-256 checksum How to use checksums |
168e1c7c28d7c27f402e62a5f46f4103a648d85dced866a679a39175f5852083
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.2 CPython/3.11.1 Windows/10
|
Release files / mcp_ai_router-0.1.9-py3-none-any.whl
| Download URL | mcp_ai_router-0.1.9-py3-none-any.whl |
|---|---|
| Size | 60.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
89c74647ec3a4c1ad7f0ece6ad703775103062dbb05f29213483b601c9297d4e
|
|
BLAKE2b-256 checksum How to use checksums |
801c066c9f623ec2b8774bc30631717a39ea7c8d9e731bba7415bda926e4ec70
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/2.1.2 CPython/3.11.1 Windows/10
|
Security for mcp-ai-router 0.1.9
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.