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

Usage

nx g @frontmcp/nx:plugin audit --project crm
nx g @frontmcp/nx:plugin audit --project crm --withContextExtension

Options

OptionTypeDefaultDescription
namestringRequired. The name of the plugin
projectstringRequired. The project to add the plugin to
withContextExtensionbooleanfalseGenerate a context extension file
directorystringSubdirectory within src/plugins/

Generated Files

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

Generated Code

audit.plugin.ts
import { Plugin, DynamicPlugin, type PluginRegistrationContext } 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> {
  async dynamicProviders() {
    return [];
  }

  async onRegister(ctx: PluginRegistrationContext): Promise<void> {
    // TODO: register tools, resources, prompts, or context extensions
  }
}

Context Extension (optional)

When --withContextExtension is used, a second file provides module augmentation and runtime prototype extension:
audit.context-extension.ts
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.