Skip to main content

Router API

Documentation for v0.0.1. Additional guides and API reference coverage are being expanded.
This page is an API orientation, not an exhaustive reference. Import createRouter from @surf-lab/mcprouter. It returns an instance-local Router and does not connect to MCP servers, run a model or dispatch a tool at construction. RouterConfig accepts limits?, policy?, ranker?, models?, model? and audit?; a string model names a configured routing adapter, not a provider. See trusted policy and security boundaries. FilterToolsOptions prohibits supplying model and ranker together. See the complete filter options and defaults, ranker comparison, and separate embedding and LLM scoring examples. ExecuteOptions.model is a routing selector or explicit adapter, independent from retrieval ranking. The shared tools input can contain trusted server configs, bound/unbound descriptors or raw MCP definitions; raw definitions are not executable just because they were filtered. Omitted selection sources use the router’s currently known tools; explicit sources do not silently widen to all registered servers. See bindings and scoped execution. Options may reject malformed configuration with RouterConfigError. Operations can reject with RouterOperationError, or call/execute can return a non-success ExecutionResult. Always inspect both the outcome and side-effect state; a score from a ranked result is not a field in an executable source descriptor. This is an orientation page, not yet the exhaustive field/default/type reference required for the final documentation release.