toolc
by L00PLeGeNd
README.md
# toolc
[](https://github.com/L00PLeGeNd/toolc/actions/workflows/ci.yml)
[](https://l00plegend.github.io/toolc/)
**[Live playground](https://l00plegend.github.io/toolc/)** — type a task, watch 42 tools collapse into 3.
**MCP Context Compiler** — turn a fat tool catalog into three tools the model can actually use.
`search_tools` · `describe_tool` · `call_tool`

42 tools → 3 meta-tools. **11.0x** fewer tokens. Hit rate still **8/8**. Cursor MCP handshake: **PASS**.
## Install
```bash
npm install
npm run benchmark
npm run verify:cursor
```
## Before / After
| Mode | Tools exposed | Token estimate | Hit rate |
| --- | --- | --- | --- |
| Raw | 42 | 2174 | 8/8 |
| Compiled | 3 meta-tools | 198 | 8/8 |
The model stops swallowing every schema up front. It discovers on demand, expands only what it needs, and calls through a compiled facade.
## Why toolc
Agent stacks keep hitting the same wall:
- too many tools
- too much schema
- sibling-tool confusion
- context burned before the task starts
Raw MCP is fine with a handful of tools. It gets expensive and noisy with dozens of servers.
`toolc` treats that as a **compiler problem**, not a prompt problem.
## What it does
1. **Collect** tools from mocks or live MCP (`stdio` / `http` / `sse`)
2. **Select** task-relevant tools with domain + action ranking
3. **Rewrite** descriptions to cut ambiguity
4. **Consolidate** near-duplicates into families
5. **Facade** as `search_tools` / `describe_tool` / `call_tool`
6. **Serve** over MCP stdio for Cursor and other hosts
7. **Benchmark** raw vs compiled tokens and hit rate
## Use with Cursor
1. Merge `examples/mcp.cursor.json` into `~/.cursor/mcp.json` (set `cwd` to this repo).
2. Reload MCP / restart Cursor.
3. Confirm the host only sees three tools: `search_tools`, `describe_tool`, `call_tool`.
```json
{
"mcpServers": {
"toolc": {
"command": "npx",
"args": [
"tsx",
"src/cli.ts",
"serve",
"--config",
"examples/config.example.json"
],
"cwd": "/absolute/path/to/toolc"
}
}
}
```
Verify without opening the IDE:
```bash
npm run verify:cursor
```
Expected:
```text
tools/list: call_tool, describe_tool, search_tools
search_tools: hit filesystem.read_file
describe_tool: schema ok
call_tool: mock dispatch ok
Cursor-equivalent MCP handshake: PASS
```
## Quick start
```bash
npm install
npm run benchmark
npm run serve
```
Compile one query:
```bash
npx tsx src/cli.ts compile --config examples/config.example.json --query "Find and read the repository README file."
```
Live upstream collect + call:
```bash
npm run collect:live
npm run serve:live
```
## CLI
```bash
toolc collect --config <path> [--live]
toolc compile --config <path> --query <text> [--limit <n>] [--live]
toolc serve --config <path> [--query <seed>] [--demo <query>] [--jsonl] [--live]
toolc benchmark --config <path> --tasks <path> [--limit <n>] [--live]
```
- servers with `mockTools` stay offline-friendly by default
- `--live` collects from real MCP servers and forwards `call_tool`
- `serve` defaults to MCP stdio
- `--demo` prints a one-shot search → describe → call walkthrough
## Not another router
`toolc` is not just semantic search, lazy loading, or dynamic discovery.
Those stop at retrieval. `toolc` compiles the interface:
- rewrites descriptions
- merges duplicate families
- emits facade tools
- measures the before/after tradeoff
## Who this is for
- MCP-heavy agent builders
- framework authors
- local-model hackers
- teams whose tool catalogs grow faster than their context windows
Skip it if you only have a few tiny tools, or your provider's built-in tool search is already enough.
## Layout
```text
src/
catalog/ collect + normalize
compile/ select → rewrite → consolidate → facade
runtime/ MCP server + upstream pool
benchmark/ raw vs compiled reports
examples/ mock catalog, live echo, Cursor config
bench/tasks/ example suite
tests/
.github/ CI
```
## Status
MVP end-to-end:
- collect from mocks or live MCP
- compile with clean selection
- serve three meta-tools over MCP stdio
- forward live `call_tool` to upstream servers
- publishable numbers: **42 → 3 tools, 11.0x, 8/8**
## License
MIT
This server cannot be deployed
Maintenance
ActivityMaintained
ResponsivenessNo recent community issues