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

# Plugin Generator

> Generate a @Plugin class extending DynamicPlugin

Generates a `@Plugin` class with optional context extension for adding properties like `this.myFeature` to all execution contexts.

## Usage

```bash theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
nx g @frontmcp/nx:plugin audit --project crm
nx g @frontmcp/nx:plugin audit --project crm --withContextExtension
```

## Options

| Option | Type | Default | Description |
| - | - | - | - |
| `name` | `string` | — | **Required.** The name of the plugin |
| `project` | `string` | — | **Required.** The project to add the plugin to |
| `withContextExtension` | `boolean` | `false` | Generate a context extension file |
| `directory` | `string` | — | Subdirectory within `src/plugins/` |

## Generated Files

```
src/plugins/
├── audit.plugin.ts                  # Plugin class
└── audit.context-extension.ts       # (only with --withContextExtension)
```

## Generated Code

```ts audit.plugin.ts theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
import { DynamicPlugin, Plugin, type ProviderType } from '@frontmcp/sdk';

export interface AuditPluginOptions {
  // TODO: define plugin options
}

@Plugin({
  name: 'audit',
  description: 'TODO: describe what this plugin does',
})
export class AuditPlugin extends DynamicPlugin<AuditPluginOptions> {
  options: AuditPluginOptions;

  constructor(options: AuditPluginOptions = {}) {
    super();
    this.options = options;
  }

  // Providers this plugin contributes to the container.
  static override dynamicProviders(_options: AuditPluginOptions): ProviderType[] {
    return [];
  }
}
```

`dynamicProviders` is a **static** method that receives the plugin options; there is no instance `dynamicProviders()` and no `onRegister` hook to implement.

### Context Extension (optional)

When `--withContextExtension` is used, a second file provides module augmentation and runtime prototype extension:

```ts audit.context-extension.ts theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
declare module '@frontmcp/sdk' {
  interface ExecutionContextBase {
    readonly audit: unknown; // TODO: replace with actual type
  }
}

export function installAuditContextExtension(): void {
  const { ExecutionContextBase } = require('@frontmcp/sdk');
  Object.defineProperty(ExecutionContextBase.prototype, 'audit', {
    get: function () {
      // TODO: return value from DI container
      return undefined;
    },
    configurable: true,
    enumerable: false,
  });
}
```

This lets all tools use `this.audit` after the plugin is registered.


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