> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mcprouter.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Filter tools

> Find relevant MCP tools without dispatching a tool or granting permission.

# Filter tools

> **Public documentation preview — incomplete.** The SDK and optional AI SDK peers remain private and unpublished. Ranking and filtering examples do not prove provider compatibility or grant execution permission.

`filterTools({ prompt, tools, context, limit, signal })` returns scored, ordered tool descriptors. Use the trusted [MCP-server array and policy](/integrate/models-servers-policies) from the shared configuration. With no configured ranker or `model` option, ranking is lexical and sends no prompt or catalogue to a model; server discovery may still perform network I/O. Filtering never dispatches a tool.

```ts theme={null}
const selected = await router.filterTools({
  prompt: 'get customer balance',
  tools: mcpServers,
  context: trustedContext,
  limit: 5,
  signal: AbortSignal.timeout(30_000),
});

const summary = selected.map(({ toolId, name, score }) => ({ toolId, name, score }));
```

`trustedContext` must come from your authenticated server, not model text or an untrusted request field. If you opt into named model ranking, add `model: 'general'` to the filter options: it selects `models.general.ranking`, checks model access and can send the prompt, schemas and tool descriptions to your configured provider. It does **not** use a server's routing binding. Do not specify `model` and `ranker` together.

Returned `score` is ranking output, not authorization or a call argument. To reuse a ranked bound descriptor as a source for `execute`, remove the output-only score: `const { score, ...boundDescriptor } = selected[0];`. First check that the descriptor exists and remains current. Raw tool definitions can also be filtered but remain **unbound**; they cannot be executed simply because they were ranked.

For a fully owned router lifetime, wrap creation and filtering in `try`/`finally` with `await router.close()`. The source-controlled `examples/code.ts` module shows this pattern for maintainers with repository access; it is not a tested live MCP run. To perform one governed action, [scope an `execute`](/integrate/execute).


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.