Skip to main content

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
  1. Visible browser windows open (one per provider being configured).
  2. Log in with your provider account in each window.
  3. 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 install does not download the browser. The first browser login or ask triggers a one-time download of a CloakBrowser-managed Chromium binary (~200 MB) to ~/.cloakbrowser/. You do not need playwright install or 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.1 with no auth — localhost only.

License

MIT — see LICENSE.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mcp_ai_router-0.1.8.tar.gz (39.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mcp_ai_router-0.1.8-py3-none-any.whl (60.4 kB view details)

Uploaded Python 3

File details

Details for the file mcp_ai_router-0.1.8.tar.gz.

File metadata

  • Download URL: mcp_ai_router-0.1.8.tar.gz
  • Upload date:
  • Size: 39.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.11.1 Windows/10

File hashes

Hashes for mcp_ai_router-0.1.8.tar.gz
Algorithm Hash digest
SHA256 d681bc1d98a3f8ee958a74f9a891ad54b45699a25d92f306f8a3f2db71caef91
MD5 c6a7e462d57e2cf24156a65fbb4b13db
BLAKE2b-256 f8fa135c7b55572372cbbe0a6b35e37a16f176ffc0dbc370876d9d2cc022e9d0

See more details on using hashes here.

File details

Details for the file mcp_ai_router-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: mcp_ai_router-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 60.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.2 CPython/3.11.1 Windows/10

File hashes

Hashes for mcp_ai_router-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 cf9decd5ceed49aa9776fd545a604b1280f0ce7a659e59b36cadc4e88504c739
MD5 69e969ee5d60f4988bfd4c052b45a29c
BLAKE2b-256 e76196cafd0cc1c1424bed9f8d9e92fd24a85f5348d69687265883f9d458b255

See more details on using hashes here.

Release history Release notifications | RSS feed

0.1.9

2 files

This release

0.1.8 This release

2 files

0.1.7

2 files

0.1.6

2 files

0.1.5

2 files

0.1.4

2 files

0.1.3

2 files

0.1.2

2 files

0.1.1

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page