mcp-sieve
by thinkmodule
README.md
# mcp-sieve
[](https://github.com/thinkmodule/mcp-sieve/actions/workflows/ci.yml)
[](LICENSE)
[](package.json)
[](package.json)
**Local STDIO MCP multiplexing proxy that cuts agent tool-schema context bloat by 94.8% via in-memory BM25 search and lazy schema loading.**
Connecting 5–10 MCP servers (GitHub, PostgreSQL, Docker, Filesystem, Slack, Jira, AWS, Browser) injects 100+ full JSON schemas into every prompt, burning tens of thousands of tokens and degrading tool-selection accuracy. `mcp-sieve` sits between your AI client and upstream MCP servers, indexing all tools in memory and exposing only **3 lightweight meta-tools**.
---
## Architecture
```text
+--------------------+ STDIO (JSON-RPC 2.0) +-----------------------+
| | <---------------------------------> | mcp-sieve |
| AI Coding Agent | Exposes ONLY 3 meta-tools (~368t): | - BM25 Tool Indexer |
| (Cursor / Claude | 1. search_tools(query, limit) | - Lazy Schema Store |
| / Antigravity) | 2. get_tool_schema(tool_names) | - Upstream Router |
| | 3. call_tool(tool_name, args) | - Token Telemetry |
+--------------------+ +-----------+-----------+
|
+---------------------+---------------------+---------+-----------+
| STDIO | STDIO | STDIO | STDIO
v v v v
+---------------+ +---------------+ +---------------+ +---------------+
| GitHub MCP | | Postgres MCP | | Docker MCP | ... | N-th Server |
+---------------+ +---------------+ +---------------+ +---------------+
```
### Meta-Tools Exposed
1. `search_tools(query, limit?)` — Searches tool names, server names, parameter keys, and descriptions using a local multi-field Okapi BM25 engine with `camelCase` / `snake_case` / acronym splitting. Returns compact `{ name, server, summary, score }` matches in sub-millisecond time.
2. `get_tool_schema(tool_names)` — Lazy-loads full JSON `inputSchema` definitions only for the exact tools the agent selects.
3. `call_tool(tool_name, arguments)` — Routes execution transparently to the owning upstream STDIO server (with automatic `${server}__${tool}` collision namespacing) and returns the upstream result.
---
## Benchmark
Measured with `npm run benchmark` across **120 simulated tools** spanning **8 MCP servers** (`github`, `postgres`, `docker`, `filesystem`, `slack`, `jira`, `aws`, `browser`) and **20 realistic developer intent queries**:
| Total Tools | Baseline Prompt Tokens | `mcp-sieve` Prompt Tokens | Token Reduction % | Top-5 Recall % | Avg Search Latency (ms) |
| ---: | ---: | ---: | ---: | ---: | ---: |
| 120 | 13,798 | 718 | 94.8% | 100% (20/20) | 0.102 ms |
- **Upfront footprint:** `368` tokens for the 3 meta-tools (**97.33% upfront reduction** vs. `13,798` baseline schema tokens).
- **Active turn footprint:** `718` tokens (`368` upfront meta-tools + `~214` top-5 `search_tools` results + `~136` lazy-loaded `get_tool_schema` payload).
- **Zero external APIs:** Pure local BM25 indexing and tokenization in Node.js with zero runtime dependencies.
---
## Quick Start
### 1. Create an upstream `mcp.servers.json`
Use the standard `mcpServers` format (compatible with Claude Desktop, Cursor, and Antigravity):
```json
{
"mcpServers": {
"github": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-github"],
"env": {
"GITHUB_PERSONAL_ACCESS_TOKEN": "ghp_..."
}
},
"postgres": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-postgres", "postgresql://localhost:5432/app"]
},
"filesystem": {
"command": "npx",
"args": ["-y", "@modelcontextprotocol/server-filesystem", "/path/to/workspace"]
}
}
}
```
### 2. Point your AI client to `mcp-sieve`
Drop this into your Cursor (`.cursor/mcp.json`), Claude Desktop (`claude_desktop_config.json`), or Antigravity MCP config:
```json
{
"mcpServers": {
"mcp-sieve": {
"command": "npx",
"args": ["-y", "mcp-sieve", "--config", "/absolute/path/to/mcp.servers.json"]
}
}
}
```
### 3. CLI Usage
```bash
# Start the STDIO MCP proxy
npx mcp-sieve --config mcp.servers.json
# Inspect connected upstream servers and baseline vs. mcp-sieve token counts
npx mcp-sieve --config mcp.servers.json --stats
# Run the reproducible 120-tool / 20-query BM25 benchmark
npx mcp-sieve --benchmark
```
---
## Project Layout
- `src/index.ts` — CLI entry point (`--config`, `--stats`, `--benchmark`)
- `src/config.ts` — `mcpServers` JSON loader and schema validator
- `src/indexer.ts` — Multi-field Okapi BM25 engine with identifier tokenizer
- `src/upstream.ts` — Upstream STDIO MCP process manager with pagination, collision namespacing, and error isolation
- `src/proxy.ts` — Downstream STDIO MCP server exposing the 3 meta-tools
- `src/telemetry.ts` — Token estimator (`chars / 4 + JSON framing overhead`) and session savings tracker
- `src/jsonrpc.ts` — Shared newline-delimited JSON-RPC 2.0 STDIO framing
- `benchmarks/run.ts` — 120-tool / 8-server / 20-query benchmark suite
- `tests/` — Unit and end-to-end STDIO tests built on `node:test`
---
## Development
```bash
npm install
npm run build # Compile TypeScript to dist/
npm test # Build and run offline hermetic unit + STDIO tests
npm run test:e2e-real # Run live E2E test against @modelcontextprotocol/server-filesystem
npm run benchmark # Build and run the 120-tool BM25 benchmark
```
> **Real-World Verification:** `mcp-sieve` is verified end-to-end (`npm run test:e2e-real`) over STDIO against the official [`@modelcontextprotocol/server-filesystem`](https://www.npmjs.com/package/@modelcontextprotocol/server-filesystem) server (`search_tools` discovery, `get_tool_schema` lazy-loading, and live `call_tool` file reads).
---
## License
MIT — Copyright (c) 2026 [Mehmet Ruşen Ayvaz](LICENSE).
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues