|
5 | 5 |
|
6 | 6 | ## Table of Contents |
7 | 7 |
|
| 8 | +- [When and why to use Toolception](#when-and-why-to-use-toolception) |
8 | 9 | - [Starter guide](#starter-guide) |
9 | 10 | - [Static startup](#static-startup) |
10 | 11 | - [API](#api) |
|
14 | 15 | - [Startup modes](#startup-modes) |
15 | 16 | - [License](#license) |
16 | 17 |
|
| 18 | +## When and why to use Toolception |
| 19 | + |
| 20 | +Building MCP servers with dozens or hundreds of tools often harms LLM performance and developer experience: |
| 21 | +- **Too many tools overwhelm selection**: Larger tool lists increase confusion and mis-selection rates. |
| 22 | +- **Token and schema bloat**: Long tool catalogs inflate prompts and latency. |
| 23 | +- **Name collisions and ambiguity**: Similar tool names across domains cause failures and fragile integrations. |
| 24 | +- **Operational overhead**: Loading every tool up-front wastes resources; many tools are task-specific. |
| 25 | + |
| 26 | +Toolception addresses this by grouping tools into toolsets and letting you expose only what’s needed, when it’s needed. |
| 27 | + |
| 28 | +### When to use Toolception |
| 29 | +- **Large or multi-domain catalogs**: You have >20–50 tools or multiple domains (e.g., search, data, billing) and don’t want to expose them all at once. |
| 30 | +- **Task-specific workflows**: You want the client/agent to enable only the tools relevant to the current task. |
| 31 | +- **Multi-tenant or policy needs**: Different users/tenants require different tool access or limits. |
| 32 | +- **Collision-safe naming**: You need predictable, namespaced tool names to avoid conflicts. |
| 33 | +- **Lazy loading**: Some tools are heavy and should be loaded on demand. |
| 34 | + |
| 35 | +### Why Toolception helps |
| 36 | +- **Toolsets**: Group related tools and expose minimal, coherent subsets per task. |
| 37 | +- **Dynamic mode (runtime control)**: |
| 38 | + - Enable toolsets on demand via meta-tools (`enable_toolset`, `disable_toolset`, `list_toolsets`, `describe_toolset`, `list_tools`). |
| 39 | + - Reduce prompt/tool surface area → better tool selection and lower latency. |
| 40 | + - Lazy-load module-produced tools only when needed; pass shared `context` safely to loaders. |
| 41 | + - Supports `tools.listChanged` notifications so clients can react to updated tool lists. |
| 42 | +- **Static mode (predictable startup)**: |
| 43 | + - Preload known toolsets (or ALL) at startup for fixed pipelines and simpler environments. |
| 44 | + - Keep only the required sets for your deployment footprint. |
| 45 | +- **Exposure policy**: |
| 46 | + - **maxActiveToolsets**: Cap concurrently active sets to prevent bloat. |
| 47 | + - **allowlist/denylist**: Enforce which toolsets can be enabled. |
| 48 | + - **namespaceToolsWithSetKey**: Default on; registers tools as `set.tool` to avoid collisions and clarify intent. |
| 49 | +- **Operational safety**: |
| 50 | + - Central `ToolRegistry` validates names and prevents collisions. |
| 51 | + - `ModuleLoaders` are deterministic/idempotent for repeatable runs and caching. |
| 52 | + |
| 53 | +### Choosing a mode |
| 54 | +- **Prefer DYNAMIC** when tool needs vary by task, you want tighter prompts, or you need runtime gating and lazy loading. |
| 55 | +- **Choose STATIC** when your tool needs are stable and small, or when your client cannot (or should not) perform runtime enable/disable operations. |
| 56 | + |
| 57 | +### Typical flows |
| 58 | +- **Discovery-first (dynamic)**: Client calls `list_toolsets` → enables a set → calls namespaced tools (e.g., `core.ping`). |
| 59 | +- **Fixed pipeline (static)**: Server preloads named toolsets (or ALL) at startup; clients call `list_tools` and invoke as usual. |
| 60 | + |
17 | 61 | ## Starter guide |
18 | 62 |
|
19 | 63 | ### Step 1: Install |
|
0 commit comments