Skip to content

Class: FluentRouter<TContext>

Defined in: packages/core/src/core/builder/FluentRouter.ts:44

Fluent router that shares prefix, description, and middleware across child tools created via .query(), .mutation(), .action().

Type Parameters

Type ParameterDescription
TContextBase application context

Constructors

Constructor

ts
new FluentRouter<TContext>(prefix): FluentRouter<TContext>;

Defined in: packages/core/src/core/builder/FluentRouter.ts:50

Parameters

ParameterType
prefixstring

Returns

FluentRouter<TContext>

Methods

action()

ts
action(action): FluentToolBuilder<TContext>;

Defined in: packages/core/src/core/builder/FluentRouter.ts:120

Create a neutral action tool under this router's prefix.

Parameters

ParameterTypeDescription
actionstringAction name (e.g. 'update' → tool name 'prefix.update')

Returns

FluentToolBuilder<TContext>

A FluentToolBuilder with the prefixed name and inherited config


describe()

ts
describe(text): this;

Defined in: packages/core/src/core/builder/FluentRouter.ts:60

Set the shared description for all tools in this router.

Parameters

ParameterTypeDescription
textstringHuman-readable description

Returns

this

this for chaining


mutation()

ts
mutation(action): FluentToolBuilder<TContext>;

Defined in: packages/core/src/core/builder/FluentRouter.ts:110

Create a destructive mutation tool under this router's prefix.

Parameters

ParameterTypeDescription
actionstringAction name (e.g. 'delete' → tool name 'prefix.delete')

Returns

FluentToolBuilder<TContext>

A FluentToolBuilder with the prefixed name and inherited config


query()

ts
query(action): FluentToolBuilder<TContext>;

Defined in: packages/core/src/core/builder/FluentRouter.ts:100

Create a read-only query tool under this router's prefix.

Parameters

ParameterTypeDescription
actionstringAction name (e.g. 'list' → tool name 'prefix.list')

Returns

FluentToolBuilder<TContext>

A FluentToolBuilder with the prefixed name and inherited config


tags()

ts
tags(...tags): this;

Defined in: packages/core/src/core/builder/FluentRouter.ts:89

Set capability tags shared by all tools in this router.

Parameters

ParameterTypeDescription
...tagsstring[]Tag strings for filtering

Returns

this

this for chaining


use()

Call Signature

ts
use<TDerived>(mw): FluentRouter<TContext & TDerived>;

Defined in: packages/core/src/core/builder/FluentRouter.ts:74

Add middleware shared by all tools in this router.

Accepts both MiddlewareDefinition from f.middleware() and raw MiddlewareFn functions.

Type Parameters
Type Parameter
TDerived extends Record<string, unknown>
Parameters
ParameterTypeDescription
mwMiddlewareDefinition<TContext, TDerived>Middleware function or MiddlewareDefinition
Returns

FluentRouter<TContext & TDerived>

Router with narrowed TContext type (when using MiddlewareDefinition)

Call Signature

ts
use(mw): this;

Defined in: packages/core/src/core/builder/FluentRouter.ts:77

Add middleware shared by all tools in this router.

Accepts both MiddlewareDefinition from f.middleware() and raw MiddlewareFn functions.

Parameters
ParameterTypeDescription
mwMiddlewareFn<TContext>Middleware function or MiddlewareDefinition
Returns

this

Router with narrowed TContext type (when using MiddlewareDefinition)