Skip to main content
Glama
README.md
# unified-search-mcp

A smart multi-signal **MCP search proxy**, **CLI (`omni-search`)**, and **Agent Skill** that pools **Tavily**, **Exa**, and **Linkup** API keys with intra-provider round-robin load balancing, weighted intent routing, tiered circuit breakers, and zero raw-key disk persistence.

> **Bilingual by design (English & Vietnamese):** Weighted routing natively handles both English technical/academic/startup queries and Vietnamese legal, tax, labor, and real-time market queries.

---

## Key Features

- **Multi-Provider Key Pooling & Round-Robin:** Configure 1 to N keys per provider (`TAVILY_KEY_POOL`, `EXA_KEY_POOL`, `LINKUP_KEY_POOL`). Rotates keys within the primary provider before failing over to secondary providers.
- **Weighted Multi-Signal Intent Router:** Scores legal/regulatory, breaking news, academic papers, code/GitHub, startup/market, and deep-synthesis signals with anti-hijacking rules (e.g., regulatory queries mentioning *"company"* still route to Legal RAG rather than Company profiles).
- **Hybrid Parallel Mode (`mode="hybrid"`):** Runs the top two providers concurrently (`asyncio.gather`) and deduplicates normalized URLs.
- **Empty-Result Fast-Jump (HTTP 204):** Zero-result responses jump immediately to the next provider without penalizing the active key.
- **Tiered Circuit Breaker & Secure Shared State:**
  - `401 / 402 / 403 / 432 / 433` (quota/auth) → `3600s` cooldown
  - `429` (rate limit) → `60s` cooldown
  - `5xx / timeout` → `30s` cooldown
  - State persisted to `$TMPDIR/unified_search_pool_state.json` (`chmod 0600`) using 16-hex `SHA-256` `key_id()` digests - **raw API keys are never written to disk**.
- **TTL Cache (300s) & Shared HTTP/2 Connection Pool:** Cuts duplicate API credit spend.
- **OmniSearch Engine (`omni-search`):** 10-intent classifier, URL tracking-parameter sanitizer (`utm_*`, `fbclid`, `gclid`), sentence-boundary context trimming, and numeric conflict detection.

---

## Architecture

```text
  [ AI Clients: Claude / Cursor / Antigravity / Gemini CLI / Codex / Zed ]
                                      │
                                      ▼
                     [ unified-search-mcp (FastMCP) ]
                     tools: web_search | web_extract | pool_status
                                      │
          ┌───────────────────────────┼───────────────────────────┐
          ▼                           ▼                           ▼
   [ Tavily Pool ]              [ Exa Pool ]               [ Linkup Pool ]
  Legal / News / RAG       Academic / Code / Market        Deep Synthesis
```

---

## 3-Step Quickstart

### 1. Clone & Configure Keys (Never Committed)

```bash
git clone https://github.com/lucas-dunght/unified-search-mcp.git
cd unified-search-mcp
cp .env.example .env
chmod 600 .env
```

Edit `.env` (gitignored) with your own API keys from Tavily, Exa, and/or Linkup:

```bash
TAVILY_KEY_POOL=tvly-your-key-1-here,tvly-your-key-2-here
EXA_KEY_POOL=exa-your-key-1-here
LINKUP_KEY_POOL=linkup-your-key-1-here
```

### 2. Install

**Automatic installer (macOS / Linux):**

```bash
chmod +x scripts/install.sh
./scripts/install.sh
```

**Windows (PowerShell):**

```powershell
.\scripts\install.ps1
```

**Or manually with `uv`:**

```bash
uv venv --python 3.12
uv pip install --python .venv/bin/python -e .
```

### 3. Verify Locally

```bash
.venv/bin/omni-search --self-test --json
.venv/bin/omni-search --status
.venv/bin/omni-search -q "Python httpx async client timeout" --dry-run --json
```

---

## MCP Client Integration

After running `./scripts/install.sh`, point your MCP client to `.venv/bin/unified-search-mcp` (or `.venv\Scripts\unified-search-mcp.exe` on Windows):

### Claude Desktop / Cursor / Antigravity / Gemini CLI

```json
{
  "mcpServers": {
    "unified-search": {
      "command": "/path/to/unified-search-mcp/.venv/bin/unified-search-mcp",
      "args": []
    }
  }
}
```

### Claude Code CLI

```bash
claude mcp add unified-search "/path/to/unified-search-mcp/.venv/bin/unified-search-mcp"
```

### OpenAI Codex CLI (`~/.codex/config.toml`)

```toml
[mcp_servers.unified-search]
  command = "/path/to/unified-search-mcp/.venv/bin/unified-search-mcp"
  args = []
  enabled = true
  startup_timeout_sec = 15
  tool_timeout_sec = 120
```

See [docs/SETUP.md](docs/SETUP.md) for full instructions covering Zed, OpenCode, Hermes Agent, DeepSeek Harness, Windows PowerShell, and environment variable precedence.

---

## CLI & Agent Skill

### `omni-search` CLI

```bash
# Quick lookup
omni-search -q "FastMCP tool decorator examples" --profile quick

# Deep research JSON output
omni-search -q "Deep dive multi-agent orchestration patterns" --profile deep --json

# Hybrid mode across top 2 providers
omni-search -q "PostgreSQL vs MySQL concurrency" --mode hybrid

# Check key pool & round-robin pointers
omni-search --status
```

### Installing the Agent Skill

Copy `skills/omni-search/` into your agent's global skills directory (for example `~/.gemini/config/skills/omni-search` or `~/.claude/skills/omni-search`).

---

## Documentation

Full Diataxis documentation lives in `docs/`:

| Document | Quadrant | Description |
| :--- | :--- | :--- |
| [Getting Started Tutorial](docs/tutorial-getting-started.md) | Tutorial | Zero-to-working walkthrough: install, self-test, `.env` keys, live search, and MCP setup |
| [Setup & Multi-Client Guide](docs/SETUP.md) | How-to | Cross-platform setup for Claude Desktop, Claude Code, Antigravity, Cursor, Codex, Zed, OpenCode, Hermes, Windows |
| [How to Operate & Audit Secrets](docs/howto-operate-and-extend.md) | How-to | Key rotation, hot-reload, cooldown resets, routing overrides, pre-commit secret audits, and skill installation |
| [API, CLI & Configuration Reference](docs/reference-api-and-cli.md) | Reference | Exact MCP tool schemas, CLI flags, Python API signatures, env precedence, and constants |
| [Architecture & Design Decisions](docs/explanation-architecture.md) | Explanation | Weighted multi-signal router, anti-hijacking rules, HTTP 204 fast-jump, and SHA-256 state trade-offs |
| [Hướng Dẫn Nhanh Tiếng Việt](docs/huong-dan-nhanh-vi.md) | Quick Guide (VI) | Cài đặt 3 bước, bảng tra cứu nhanh MCP/CLI/Router và checklist chống lộ API key |
| [Security Policy](SECURITY.md) | Security | Key precedence, SHA-256 `key_id()` hashing, log scrubbing, and rotation checklist |

---

## Security & Secret Hygiene

- All API keys are loaded at runtime via process environment variables, `UNIFIED_SEARCH_ENV_FILE`, `.env`, or `~/.mcp_env` (see [SECURITY.md](SECURITY.md)).
- Run the built-in secret scanner before pushing:

```bash
python3 scripts/audit_secrets.py
python3 scripts/audit_secrets.py --check-git-history
```

- GitHub Actions CI runs `pytest`, `omni-search --self-test`, `audit_secrets.py --check-git-history`, and `gitleaks` on every push and pull request.

---

## License

[MIT](LICENSE)

TDQS

A3.5/5.0

Scored across 3 tools

Disambiguation5/5

Each tool has a clearly distinct purpose: web_search performs searches, web_extract retrieves page text from a URL, and pool_status reports operational state. There is no meaningful overlap between search, extraction, and pool inspection.

Naming Consistency4/5

All names use snake_case and follow a noun-oriented pattern, which is readable. However, pool_status breaks the web_ prefix used by the two primary tools, making the convention only mostly consistent rather than uniform.

Tool Count5/5

Three tools is a well-scoped surface for a unified search server: search, extract, and inspect the key pool. Each tool earns its place with no filler.

Completeness4/5

The core lifecycle of search and extraction is covered, along with operational visibility into the API pool. Minor gaps could include batch extraction or structured result controls, but these are workable omissions rather than dead ends.

Maintenance

ActivityMaintained
ResponsivenessNo recent community issues