MCP server routing prompts to web AI providers via CloakBrowser
Project description
ai-router
Python MCP server that routes prompts to web AI providers (Gemini, ChatGPT*) via CloakBrowser.
PyPI package: mcp-ai-router · CLI command: ai-router
* ChatGPT is registered but not implemented in v1.
Requirements
| Tool | Version |
|---|---|
| Python | 3.11+ |
| pipx | latest |
| Chrome | stable channel |
Install
python -m pip install --user pipx
python -m pipx ensurepath
# restart terminal
pipx install mcp-ai-router
Verify:
ai-router --version
ai-router --help
On first browser launch, CloakBrowser downloads a stealth Chromium binary (~200 MB) to ~/.cloakbrowser/. You do not need to run playwright install.
Login to Gemini (one-time)
ai-router browser login
- A headed Chrome window opens at Gemini.
- Log in with your Google account.
- Close all browser windows when done.
Session is saved to ~/.ai-router/profile/.
Verify login:
ai-router browser status
Expected output: gemini: logged_in
Connect Cursor
GUI apps (Cursor on Windows/macOS) often use a PATH that differs from your shell. Use the exact path from your system:
# macOS/Linux
command -v ai-router
# Windows
where ai-router
Add to Cursor MCP settings (mcp.json):
{
"mcpServers": {
"ai-router": {
"command": "/full/path/from-command-v-or-where",
"args": ["serve"]
}
}
}
Example paths (yours may differ):
- macOS/Linux:
~/.local/bin/ai-router - Windows:
C:\\Users\\<you>\\.local\\bin\\ai-router.exe
No separate terminal for the server. Login remains CLI-only (ai-router browser login).
Upgrade:
pipx upgrade mcp-ai-router
Use in Cursor
The agent can call these MCP tools:
| Tool | Description |
|---|---|
ask |
Send a prompt, get raw text answer from Gemini |
ask_multi |
Send one prompt to several providers in parallel |
list_providers |
List providers (gemini = available, chatgpt = coming_soon) |
session_status |
Check whether providers are logged in |
Login is CLI only — there is no MCP login tool. Run ai-router browser login manually.
Conversation behavior:
Each ask opens a new provider chat. Follow-up context is not preserved across calls. Cursor conversation context and provider chat context are separate; ai-router does not reuse the previous provider chat. Browser login (Google session) is persistent via ~/.ai-router/profile/.
CLI reference
ai-router --version
ai-router serve [--transport stdio|http] [--host 127.0.0.1] [--port 8087]
ai-router browser login [--provider gemini]
ai-router browser status [--provider gemini]
Default transport is stdio (for Cursor). Use --transport http for debugging.
Config (optional)
Create ~/.ai-router/config.yaml:
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
Environment variable overrides:
| Variable | Default | Description |
|---|---|---|
AI_ROUTER_PROFILE_DIR |
~/.ai-router/profile |
CloakBrowser persistent profile |
AI_ROUTER_DEFAULT_PROVIDER |
gemini |
Default provider for ask |
AI_ROUTER_HOST |
127.0.0.1 |
MCP HTTP server bind address |
AI_ROUTER_PORT |
8087 |
MCP HTTP server port |
AI_ROUTER_ANSWER_TIMEOUT_S |
120 |
Per-request answer timeout |
Troubleshooting
| Problem | Fix |
|---|---|
pipx: command not found right after install |
Use python -m pipx instead |
ai-router: command not found |
Run python -m pipx ensurepath and open a new terminal |
Cursor cannot find ai-router |
Paste exact path from command -v ai-router / where ai-router |
| Cursor MCP fails mysteriously | Stdio stdout must be MCP-only — ensure no startup banner on stdout |
pipx install mcp-ai-router fails |
Package may not be on PyPI yet, or name taken |
gemini: logged_out |
Run ai-router browser login again |
NOT_LOGGED_IN from ask |
Run ai-router browser login |
| Browser does not open | Requires cloakbrowser ≥ 0.4.4 |
BROWSER_BUSY |
Wait for the current ask to finish |
Slow first ask after Cursor restart |
Expected cold start; browser tabs are in-memory only |
| Profile lock / browser errors | Possible concurrent MCP processes — run one active server |
| Need HTTP debug | ai-router serve --transport http |
HTTP debug (advanced)
ai-router serve --transport http
Optional bridge (requires Node.js):
npx -y mcp-remote@latest http://127.0.0.1:8087/mcp
Development
Maintainers use Poetry in a repo checkout:
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 # local HTTP debug
Before release, test against:
- The
mcpversion locked inpoetry.lock(currently 1.12.4) - Latest stable
mcp<2 - A clean wheel install from an empty directory outside the repo
Build and smoke-test a wheel locally:
poetry build
pipx install --force dist/ai_router-*.whl
mkdir -p /tmp/ai-router-smoke && cd /tmp/ai-router-smoke
ai-router --help
ai-router --version
ai-router browser status
Publish:
poetry check
poetry publish -r testpypi # dry run
poetry publish
git tag v0.1.1
git push origin v0.1.1
Security
- HTTP server binds to
127.0.0.1only (localhost). - Profile dir (
~/.ai-router/profile/) contains live Google session credentials — treat it like a password.
Branches
python— current Python rewrite (this README)main— previous TypeScript implementation
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mcp_ai_router-0.1.1.tar.gz.
File metadata
- Download URL: mcp_ai_router-0.1.1.tar.gz
- Upload date:
- Size: 27.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.13.2 Darwin/24.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7377297a7e0e891b0f2268a3813afd78cda1f8f69c1c397bb775387c91df539e
|
|
| MD5 |
8889c38c9afc879fc04bc3005e2e141a
|
|
| BLAKE2b-256 |
d208532b1887925aafa766733e979ec688d00673ad5a5becfad50ea26298f46e
|
File details
Details for the file mcp_ai_router-0.1.1-py3-none-any.whl.
File metadata
- Download URL: mcp_ai_router-0.1.1-py3-none-any.whl
- Upload date:
- Size: 39.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.1.2 CPython/3.13.2 Darwin/24.5.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
388d9029aac89a561b1b504856e7d83ab8b331cb61cfd90b49fd4bc5ecb61d2a
|
|
| MD5 |
ade0055de6efd92ec83fedfbd855a415
|
|
| BLAKE2b-256 |
9fe00d3d3d9cd72f136e04ad1ff813af849f91aa0bec2f2fb2fa23a4dbed3c91
|