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:116

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:106

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:96

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:85

Set capability tags shared by all tools in this router.

Parameters

ParameterTypeDescription
...tagsstring[]Tag strings for filtering

Returns

this

this for chaining


use()

ts
use(mw): this;

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.

Parameters

ParameterTypeDescription
mw| MiddlewareFn<TContext> | MiddlewareDefinition<TContext, Record<string, unknown>>Middleware function or MiddlewareDefinition

Returns

this

this for chaining