Skip to main content
Generates a shared library for code reuse across apps. Supports four library types: generic, plugin, adapter, and tool-register.

Usage

Options

The generator refuses an import path that tsconfig.base.json already maps, by its exact key or a wildcard such as @acme/*, or one that names a package the workspace depends on (such as @frontmcp/sdk), so a new library never shadows existing code. Pass --importPath with another name.

Library Types

Generic (default)

A plain TypeScript library with a class and barrel export:

Plugin

A FrontMCP plugin library extending DynamicPlugin. The class is the one the plugin generator writes:

Adapter

A FrontMCP adapter library extending DynamicAdapter. The class is the one the adapter generator writes:

Tool Register

A multi-tool library that exports an array of tools:
Usage in an app, in a workspace whose root package.json is named @acme/source (the default import path is @acme/<name>; pass --importPath to override):

Project Setup

Every library type gets the same project files: The generator registers the import path in tsconfig.base.json as a relative path, "@frontmcp/my-lib": ["./libs/my-lib/src/index.ts"], which TypeScript accepts with or without a baseUrl. Apps import the library through that alias, and nx build <app> bundles it, so a library needs no build target of its own (a workspace that registers @nx/js/typescript still infers one from tsconfig.lib.json). A publishable library gets one, since it is built on its own.
tsconfig.json sets "nx": { "addTypecheckTarget": false } so that, in a workspace that registers the @nx/js/typescript plugin, Nx uses the project’s own typecheck target instead of inferring a tsc --build one.

Publishable Libraries

Generate a library with a package.json for npm publishing:
On top of the project files every library gets, a publishable library has: Build the library, then publish it from its folder: